Skip to content

Don't set ownership for namespaces#41

Merged
bigkevmcd merged 2 commits intomainfrom
dont-set-ownership-namespaces
Mar 14, 2023
Merged

Don't set ownership for namespaces#41
bigkevmcd merged 2 commits intomainfrom
dont-set-ownership-namespaces

Conversation

@bigkevmcd
Copy link
Copy Markdown
Collaborator

We can't set ownership for resources that are global resources.

@bigkevmcd bigkevmcd requested a review from foot March 13, 2023 17:18
@bigkevmcd bigkevmcd force-pushed the dont-set-ownership-namespaces branch from 0d0aa87 to 11972e4 Compare March 13, 2023 17:18
A bug creating namespaces because the service account is namespaced
scoped, and we can't set the ownership.
@bigkevmcd bigkevmcd force-pushed the dont-set-ownership-namespaces branch from 11972e4 to cfb8e79 Compare March 13, 2023 17:33
Comment thread controllers/gitopsset_controller.go Outdated
if err := controllerutil.SetOwnerReference(gitOpsSet, newResource, r.Scheme); err != nil {
return nil, fmt.Errorf("failed to set ownership: %w", err)
// cluster-scoped resources must not have a namespace-scoped owner
if newResource.GetKind() != "Namespace" {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we talked about this recently, but a shame there doesn't seem to be an isNamespacedObject helper.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, I'll sort that out :-)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm curious! It sounds like a tricky one.. even namespaces/clusteroles seem to able to have namespaces.

Copy link
Copy Markdown
Collaborator

@foot foot left a comment

Choose a reason for hiding this comment

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

👌

This reduces our checks on "Namespace" resources.
@bigkevmcd bigkevmcd merged commit cb36e76 into main Mar 14, 2023
@bigkevmcd bigkevmcd deleted the dont-set-ownership-namespaces branch March 14, 2023 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants