Skip to content

Commit ebf902f

Browse files
Merge pull request openstack-k8s-operators#1554 from abays/fix-OSPRH-18744
[OSPRH-18744] Handle variant apiVersions for refData cleanup
2 parents 1483c08 + 83adc21 commit ebf902f

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
@@ -875,12 +875,20 @@ func (r *OpenStackReconciler) postCleanupObsoleteResources(ctx context.Context,
875875
obj.SetNamespace(namespace.(string))
876876
}
877877

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

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

0 commit comments

Comments
 (0)