From 83adc21de70bb20a908a10bfd5b75ce624b79260 Mon Sep 17 00:00:00 2001 From: Andrew Bays Date: Wed, 6 Aug 2025 10:31:24 +0000 Subject: [PATCH] [OSPRH-18744] Handle variant apiVersions for refData cleanup --- controllers/operator/openstack_controller.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/controllers/operator/openstack_controller.go b/controllers/operator/openstack_controller.go index fa03f6cb14..acb34d2127 100644 --- a/controllers/operator/openstack_controller.go +++ b/controllers/operator/openstack_controller.go @@ -874,12 +874,20 @@ func (r *OpenStackReconciler) postCleanupObsoleteResources(ctx context.Context, obj.SetNamespace(namespace.(string)) } - apiParts := strings.Split(refData["apiVersion"].(string), "/") + apiVersion := refData["apiVersion"].(string) + apiParts := strings.Split(apiVersion, "/") objGvk := schema.GroupVersionResource{ - Group: apiParts[0], - Version: apiParts[1], Resource: refData["kind"].(string), } + // Some of the references have an apiVersion that lacks a group prefix + if len(apiParts) > 1 { + objGvk.Group = apiParts[0] + objGvk.Version = apiParts[1] + Log.Info("postCleanupObsoleteResources: Found apiVersion with group prefix", "apiVersion", apiVersion) + } else { + objGvk.Version = apiParts[0] + Log.Info("postCleanupObsoleteResources: Found apiVersion without group prefix", "apiVersion", apiVersion) + } obj.SetGroupVersionKind(objGvk.GroupVersion().WithKind(refData["kind"].(string))) // references from CRD's should be removed before this function is called