Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-0.6] Streamline the vpc cluster deletion process #1391

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cloud/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ func (s *ClusterScope) CreateVPC() (*vpcv1.VPC, error) {

// DeleteVPC deletes IBM VPC associated with a VPC id.
func (s *ClusterScope) DeleteVPC() error {
if s.IBMVPCCluster.Status.VPC.ID == "" {
return nil
}

deleteVpcOptions := &vpcv1.DeleteVPCOptions{}
deleteVpcOptions.SetID(s.IBMVPCCluster.Status.VPC.ID)
_, err := s.IBMVPCClient.DeleteVPC(deleteVpcOptions)
Expand Down Expand Up @@ -267,6 +271,10 @@ func (s *ClusterScope) ensureFIPUnique(fipName string) (*vpcv1.FloatingIP, error

// DeleteFloatingIP deletes a Floating IP associated with floating ip id.
func (s *ClusterScope) DeleteFloatingIP() error {
if s.IBMVPCCluster.Status.VPCEndpoint.FIPID == nil {
return nil
}

if fipID := *s.IBMVPCCluster.Status.VPCEndpoint.FIPID; fipID != "" {
deleteFIPOption := &vpcv1.DeleteFloatingIPOptions{}
deleteFIPOption.SetID(fipID)
Expand Down Expand Up @@ -410,6 +418,10 @@ func (s *ClusterScope) ensureSubnetUnique(subnetName string) (*vpcv1.Subnet, err

// DeleteSubnet deletes a subnet associated with subnet id.
func (s *ClusterScope) DeleteSubnet() error {
if s.IBMVPCCluster.Status.Subnet.ID == nil {
return nil
}

subnetID := *s.IBMVPCCluster.Status.Subnet.ID

// Lists the subnet available and compare before deleting to avoid any failure(404) later
Expand Down Expand Up @@ -703,6 +715,10 @@ func (s *ClusterScope) SetLoadBalancerID(id *string) {

// GetLoadBalancerID will get the id for the load balancer.
func (s *ClusterScope) GetLoadBalancerID() string {
if s.IBMVPCCluster.Status.VPCEndpoint.LBID == nil {
return ""
}

return *s.IBMVPCCluster.Status.VPCEndpoint.LBID
}

Expand Down