Skip to content

Commit 5dd5c92

Browse files
Merge pull request #1557 from openshift-cherrypick-robot/cherry-pick-1554-to-18.0-fr3
[18.0-fr3] [OSPRH-18744] Handle variant apiVersions for refData cleanup
2 parents 45eb2bd + 9216bb3 commit 5dd5c92

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
@@ -871,12 +871,20 @@ func (r *OpenStackReconciler) postCleanupObsoleteResources(ctx context.Context,
871871
obj.SetNamespace(namespace.(string))
872872
}
873873

874-
apiParts := strings.Split(refData["apiVersion"].(string), "/")
874+
apiVersion := refData["apiVersion"].(string)
875+
apiParts := strings.Split(apiVersion, "/")
875876
objGvk := schema.GroupVersionResource{
876-
Group: apiParts[0],
877-
Version: apiParts[1],
878877
Resource: refData["kind"].(string),
879878
}
879+
// Some of the references have an apiVersion that lacks a group prefix
880+
if len(apiParts) > 1 {
881+
objGvk.Group = apiParts[0]
882+
objGvk.Version = apiParts[1]
883+
Log.Info("postCleanupObsoleteResources: Found apiVersion with group prefix", "apiVersion", apiVersion)
884+
} else {
885+
objGvk.Version = apiParts[0]
886+
Log.Info("postCleanupObsoleteResources: Found apiVersion without group prefix", "apiVersion", apiVersion)
887+
}
880888
obj.SetGroupVersionKind(objGvk.GroupVersion().WithKind(refData["kind"].(string)))
881889

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

0 commit comments

Comments
 (0)