Skip to content

olm,catalog: only validate the resources we label #3165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions pkg/lib/ownerutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,13 @@ func AddNonBlockingOwner(object metav1.Object, owner Owner) {
ownerRefs = []metav1.OwnerReference{}
}

// Infer TypeMeta for the target
if err := InferGroupVersionKind(owner); err != nil {
log.Warn(err.Error())
}
gvk := owner.GetObjectKind().GroupVersionKind()

nonBlockingOwner := NonBlockingOwner(owner)
for _, item := range ownerRefs {
if item.Kind == gvk.Kind {
if item.Name == owner.GetName() && item.UID == owner.GetUID() {
return
}
if item.Kind == nonBlockingOwner.Kind && item.Name == nonBlockingOwner.Name && item.UID == nonBlockingOwner.UID {
return
}
}
ownerRefs = append(ownerRefs, NonBlockingOwner(owner))
ownerRefs = append(ownerRefs, nonBlockingOwner)
object.SetOwnerReferences(ownerRefs)
}

Expand Down Expand Up @@ -284,14 +277,20 @@ func AddOwner(object metav1.Object, owner Owner, blockOwnerDeletion, isControlle
}
gvk := owner.GetObjectKind().GroupVersionKind()
apiVersion, kind := gvk.ToAPIVersionAndKind()
ownerRefs = append(ownerRefs, metav1.OwnerReference{
ownerRef := metav1.OwnerReference{
APIVersion: apiVersion,
Kind: kind,
Name: owner.GetName(),
UID: owner.GetUID(),
BlockOwnerDeletion: &blockOwnerDeletion,
Controller: &isController,
})
}
for _, ref := range ownerRefs {
if ref.Kind == ownerRef.Kind && ref.Name == ownerRef.Name && ref.UID == ownerRef.UID {
return
}
Comment on lines +289 to +291
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any chance that we call this function with the same object, but with different blockOwnerDeletion or isController values?

Curious if we find the owner ref, rather than leaving what's there untouched, we should update what's there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe the codebase does any of that today. Generally speaking I would not expect isController to be something that logically could change.

}
ownerRefs = append(ownerRefs, ownerRef)
object.SetOwnerReferences(ownerRefs)
}

Expand Down
11 changes: 9 additions & 2 deletions pkg/lib/testobj/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,21 @@ func WithOwner(owner, obj RuntimeMetaObject) RuntimeMetaObject {
out := obj.DeepCopyObject().(RuntimeMetaObject)
gvk := owner.GetObjectKind().GroupVersionKind()
apiVersion, kind := gvk.ToAPIVersionAndKind()
refs := append(out.GetOwnerReferences(), metav1.OwnerReference{

nonBlockingOwner := metav1.OwnerReference{
APIVersion: apiVersion,
Kind: kind,
Name: owner.GetName(),
UID: owner.GetUID(),
BlockOwnerDeletion: &dontBlockOwnerDeletion,
Controller: &notController,
})
}
for _, item := range out.GetOwnerReferences() {
if item.Kind == nonBlockingOwner.Kind && item.Name == nonBlockingOwner.Name && item.UID == nonBlockingOwner.UID {
return out
}
}
refs := append(out.GetOwnerReferences(), nonBlockingOwner)
out.SetOwnerReferences(refs)

return out
Expand Down