Skip to content
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

manifest generation: remove metadata.namespace from manifests #3813

Merged

Conversation

joelanford
Copy link
Member

Description of the change:
When generating bundles and packagemanifests, remove metadata.namespace from namespaced resources when writing them into the manifests directory to avoid validation errors.

OLM installs namespaced manifests in the namespace that the operator is installed, so it is invalid to hardcode a specific namespace in these manifests.

Motivation for the change:
Closes #3809

Checklist

If the pull request includes user-facing changes, extra documentation is required:

@estroz
Copy link
Member

estroz commented Aug 29, 2020

@joelanford do you know which validator is returning this error? Also I’m not sure why this is a requirement at all. Much like for a CSV, OLM should be able to substitute whatever namespace it wants into a bundled manifest regardless of whether one is set or not. Is this so operator authors won’t get the idea that their object will be installed into the namespace specified in the manifest?

@dinhxuanvu @gallettilance thoughts on this?

Relates to #3748.

@joelanford
Copy link
Member Author

/hold

For discussion about whether this validator is appropriate (and if it is, I want to add some unit tests to prevent regressions)

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 29, 2020
@estroz
Copy link
Member

estroz commented Aug 31, 2020

From @dinhxuanvu:

If non-CSV manifests (such as CRD) have namespace information, they will fail validation. It is "kubectlable" validation. OLM will overwrite namespace info so you shouldn't include namespace info by default given it won't be honored

@@ -212,6 +212,7 @@ func (c *Manifests) addRoles(rawManifests ...[]byte) error {
if err := yaml.Unmarshal(rawManifest, &role); err != nil {
return err
}
role.SetNamespace("")
Copy link
Member

Choose a reason for hiding this comment

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

It would be easier to just remove an object's namespace before writing it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, the package and naming of WriteObjectsToFiles makes me hesitate a little putting this logic there since it seems like a very general-purpose and obvious function. I interpret it as "please serialize these objects directly to files".

WDYT of removing the namespace of all objects just before they're passed into this function and only when we're using it in the context of writing a manifests directory?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, how about here?

Copy link
Member

Choose a reason for hiding this comment

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

👍 to your last comment.

@joelanford joelanford force-pushed the gen-bundle-namespaced branch from 7e932da to e548936 Compare August 31, 2020 19:26
@joelanford
Copy link
Member Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 1, 2020
Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 1, 2020
@joelanford joelanford merged commit 1a4ed60 into operator-framework:master Sep 1, 2020
@joelanford joelanford deleted the gen-bundle-namespaced branch September 1, 2020 03:20
joelanford added a commit to joelanford/operator-sdk that referenced this pull request Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Operator SDK 1.0.0 - explicit service account for operator causes bundle build to fail
3 participants