Skip to content

Commit 83adc21

Browse files
committed
[OSPRH-18744] Handle variant apiVersions for refData cleanup
1 parent 69d50de commit 83adc21

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

controllers/operator/openstack_controller.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -874,12 +874,20 @@ func (r *OpenStackReconciler) postCleanupObsoleteResources(ctx context.Context,
874874
obj.SetNamespace(namespace.(string))
875875
}
876876

877-
apiParts := strings.Split(refData["apiVersion"].(string), "/")
877+
apiVersion := refData["apiVersion"].(string)
878+
apiParts := strings.Split(apiVersion, "/")
878879
objGvk := schema.GroupVersionResource{
879-
Group: apiParts[0],
880-
Version: apiParts[1],
881880
Resource: refData["kind"].(string),
882881
}
882+
// Some of the references have an apiVersion that lacks a group prefix
883+
if len(apiParts) > 1 {
884+
objGvk.Group = apiParts[0]
885+
objGvk.Version = apiParts[1]
886+
Log.Info("postCleanupObsoleteResources: Found apiVersion with group prefix", "apiVersion", apiVersion)
887+
} else {
888+
objGvk.Version = apiParts[0]
889+
Log.Info("postCleanupObsoleteResources: Found apiVersion without group prefix", "apiVersion", apiVersion)
890+
}
883891
obj.SetGroupVersionKind(objGvk.GroupVersion().WithKind(refData["kind"].(string)))
884892

885893
// references from CRD's should be removed before this function is called

0 commit comments

Comments
 (0)