Skip to content

Commit

Permalink
Only delete individual components if the datacenter can not be deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
NotTheEvilOne committed Nov 30, 2021
1 parent 56598c5 commit 2cb86a7
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions pkg/controller/infrastructure/actuator_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,7 @@ func (a *actuator) delete(ctx context.Context, infra *extensionsv1alpha1.Infrast
infraStatus, _ := transcoder.DecodeInfrastructureStatusFromInfrastructure(infra)

if nil != infraStatus {
err = ensurer.EnsureDHCPServerDeleted(ctx, client, infraStatus.DatacenterID, infraStatus.DHCPServerConfiguration.ServerID)
if err != nil {
return err
}

err = ensurer.EnsureNetworksDeleted(ctx, client, infraStatus.DatacenterID, infraStatus.NetworkIDs)
if err != nil {
return err
}

err = ensurer.EnsureFloatingPoolDeleted(ctx, client, infraStatus.FloatingPoolID)
if err != nil {
return err
}
isDeleted := false

labels, _, err := client.LabelApi.DatacentersLabelsGet(ctx, infraStatus.DatacenterID).Depth(1).Execute()
if nil != err {
Expand All @@ -83,10 +70,28 @@ func (a *actuator) delete(ctx context.Context, infra *extensionsv1alpha1.Infrast
return err
}

isDeleted = true
break
}
}
}

if !isDeleted {
err = ensurer.EnsureDHCPServerDeleted(ctx, client, infraStatus.DatacenterID, infraStatus.DHCPServerConfiguration.ServerID)
if err != nil {
return err
}

err = ensurer.EnsureNetworksDeleted(ctx, client, infraStatus.DatacenterID, infraStatus.NetworkIDs)
if err != nil {
return err
}

err = ensurer.EnsureFloatingPoolDeleted(ctx, client, infraStatus.FloatingPoolID)
if err != nil {
return err
}
}
}

return a.updateProviderStatus(ctx, infra, nil)
Expand Down

0 comments on commit 2cb86a7

Please sign in to comment.