Skip to content

Skip setting owner refs for objects that don't support it #184

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
Merged
Changes from all commits
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
9 changes: 6 additions & 3 deletions pkg/patterns/declarative/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,12 @@ func (r *Reconciler) injectOwnerRef(ctx context.Context, instance DeclarativeObj
continue
}

// TODO, error/skip if:
// - owner is namespaced and o is not
// - owner is in a different namespace than o
if owner.GetNamespace() != "" && owner.GetNamespace() != o.Namespace {
// a namespaced object can only own objects within the same namespace, not objects in other namespaces or cluster-scoped objects
// for any other combination, skip setting owner reference here, to allow declarative.SourceAsOwner to be used for the
// subset of objects that make up a supported combination
Copy link
Contributor

Choose a reason for hiding this comment

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

This condition should be logged like above.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree we should alert, but I've been thinking about who we are alerting for. I think the answer is that we are alerting for the addon operator developer, but not the addon operator user. There's actually a whole set of these, particularly as we improve the functionality (e.g. reuse of the RESTMapper), which include recommended but not required code changes.

I think I'm going to merge this PR as-is therefore, but then try to implement a "developer notification" mode.

Copy link
Member Author

Choose a reason for hiding this comment

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

@justinsb I'm happy to amend this PR with logging if you'd like, but we currently have a rather ugly workaround with a custom declarative.WithObjectTransform that would be nice to get rid of, so if merging this and then adding new logging mechanism can be done in separate step's I'll be happy about it :)

continue
}

ownerRefs := []interface{}{
map[string]interface{}{
Expand Down