Skip to content

Commit

Permalink
Fix infrastructure delete handling of already deleted datacenters
Browse files Browse the repository at this point in the history
  • Loading branch information
NotTheEvilOne committed Mar 24, 2022
1 parent 23d92f0 commit 2d3d34e
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions pkg/controller/infrastructure/actuator_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,30 @@ func (a *actuator) delete(ctx context.Context, infra *extensionsv1alpha1.Infrast
if nil != infraStatus {
isDeleted := false

labels, _, err := client.LabelApi.DatacentersLabelsGet(ctx, infraStatus.DatacenterID).Depth(1).Execute()
if nil != err {
labels, httpResponse, err := client.LabelApi.DatacentersLabelsGet(ctx, infraStatus.DatacenterID).Depth(1).Execute()
if 404 == httpResponse.StatusCode {
isDeleted = true
} else {
return err
}

for _, label := range *labels.Items {
if nil != label.Properties && "cluster" == *label.Properties.Key {
clusterValue, err := hex.DecodeString(*label.Properties.Value)
if nil != err {
continue
}

if infra.Namespace == string(clusterValue) {
err = ensurer.EnsureDatacenterDeleted(ctx, client, infraStatus.DatacenterID)
if err != nil {
return err
if !isDeleted {
for _, label := range *labels.Items {
if nil != label.Properties && "cluster" == *label.Properties.Key {
clusterValue, err := hex.DecodeString(*label.Properties.Value)
if nil != err {
continue
}

isDeleted = true
break
if infra.Namespace == string(clusterValue) {
err = ensurer.EnsureDatacenterDeleted(ctx, client, infraStatus.DatacenterID)
if err != nil {
return err
}

isDeleted = true
break
}
}
}
}
Expand Down

0 comments on commit 2d3d34e

Please sign in to comment.