Ignore "" namespaces in collectHelmReleasesNamespaces #4568
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #3311
Related: N/A
Merge before/after: N/A
Description
This fixes an issue specific to helm deployments , when the skaffold enduser is running with RBAC restriction scoped to a single namespace.
Behaviour on v1.12.1 - pod watcher logs this error
starting logger: initializing pod watcher for "": unknown (get pods)
and exits.This also seems to, inadvertently 😄 , fix a new issue (potentially introduced as part of the fixes in this PR - #4460) whereby user with similar restrictions, single-ns scoped permissions, cannot list helm-released deployments anymore despite having
SKAFFOLD_NAMESPACE
env-variable or adding--namepsace
/-n
flag. This other issue logs the error below before exiting:The only work around for both these issue is to hardcode a
namespace
field in skaffold.yaml underdeploy.helm.releases
.User facing changes (remove if N/A)
Before:
Running
skaffold dev
with a user permitted to only a single namespace would run into this error before exiting:starting logger: initializing pod watcher for "": unknown (get pods)
.The cause for this error appears related to the runner context that merges all namespaces into a single array (user RBAC, -n/--namespace
SKAFFOLD_NAMESPACE
and every helmRelease namespace specified). When the namespace field isn't included underdeploy.helm.releases
, this seems to add a blank (or""
) namespace in the list of namespaces which may require cluster-scope permissions.There's a work-around for this before this fix - adding the namespace under each helm-release will make this work:
However we have users sharing the same repo/skaffold.yaml and attempt to deploy each to their own namespace, therefore hardcoding the namespace isn't ideal.
After:
Pod watcher and deployment status works without adding the namespace field under
deploy.helm.releases
. I've tested also using admin user (with cluster-wide rbac) and the behaviour works the same. Also tested multiple helmReleases with different namespaces, seems to work as well with this change.Question to the contributors on this project: was there an intended reason to have this behaviour? (i.e. having an empty ns in namespaces list) The reason I ask is as you can see I had to change the test as well and remove
""
from expected output.Let me know.
Follow-up Work (remove if N/A)