Skip to content

Commit 3021bc8

Browse files
britaniarCopilot
andauthored
Update pkg/controllers/workapplier/preprocess.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 05be6dc commit 3021bc8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pkg/controllers/workapplier/preprocess.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -560,12 +560,14 @@ func removeOwnerRef(obj *unstructured.Unstructured, expectedAppliedWorkOwnerRef
560560

561561
// Re-build the owner references; remove the given one from the list.
562562
for idx := range ownerRefs {
563-
if ownerRefs[idx].UID != expectedAppliedWorkOwnerRef.UID &&
564-
ownerRefs[idx].Name != expectedAppliedWorkOwnerRef.Name &&
565-
ownerRefs[idx].Kind != expectedAppliedWorkOwnerRef.Kind &&
566-
ownerRefs[idx].APIVersion != expectedAppliedWorkOwnerRef.APIVersion {
567-
updatedOwnerRefs = append(updatedOwnerRefs, ownerRefs[idx])
563+
if ownerRefs[idx].UID == expectedAppliedWorkOwnerRef.UID &&
564+
ownerRefs[idx].Name == expectedAppliedWorkOwnerRef.Name &&
565+
ownerRefs[idx].Kind == expectedAppliedWorkOwnerRef.Kind &&
566+
ownerRefs[idx].APIVersion == expectedAppliedWorkOwnerRef.APIVersion {
567+
// Skip the expected owner reference.
568+
continue
568569
}
570+
updatedOwnerRefs = append(updatedOwnerRefs, ownerRefs[idx])
569571
}
570572
obj.SetOwnerReferences(updatedOwnerRefs)
571573
}

0 commit comments

Comments
 (0)