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

ensure kubeclient ns is release ns for helm actions #2652

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thorbenbelow
Copy link

Fixes #2634

Also looks like this is the same issue as with #1033

From my understanding helm will use the namespace from flags to determine where it runs actions. Imo this should always be the release namespace.

Copy link
Owner

@derailed derailed left a comment

Choose a reason for hiding this comment

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

@thorbenbelow Thank you for this update Thornben!

internal/dao/helm_chart.go Show resolved Hide resolved
Comment on lines 147 to 160
func ensureHelmConfig(flags *genericclioptions.ConfigFlags, ns string) (*action.Configuration, error) {
settings := &genericclioptions.ConfigFlags{
Namespace: &ns,
Context: flags.Context,
BearerToken: flags.BearerToken,
APIServer: flags.APIServer,
CAFile: flags.CAFile,
KubeConfig: flags.KubeConfig,
Impersonate: flags.Impersonate,
Insecure: flags.Insecure,
TLSServerName: flags.TLSServerName,
ImpersonateGroup: flags.ImpersonateGroup,
WrapConfigFn: flags.WrapConfigFn,
}
cfg := new(action.Configuration)
Copy link
Author

Choose a reason for hiding this comment

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

Hi @derailed, unfortunately I'm not too familiar with k9s' and Helms' codebase, so I've just been trying to orient myself on how helm constructs their client.

Just to be clear: You are suggesting to do this instead?

Suggested change
func ensureHelmConfig(flags *genericclioptions.ConfigFlags, ns string) (*action.Configuration, error) {
settings := &genericclioptions.ConfigFlags{
Namespace: &ns,
Context: flags.Context,
BearerToken: flags.BearerToken,
APIServer: flags.APIServer,
CAFile: flags.CAFile,
KubeConfig: flags.KubeConfig,
Impersonate: flags.Impersonate,
Insecure: flags.Insecure,
TLSServerName: flags.TLSServerName,
ImpersonateGroup: flags.ImpersonateGroup,
WrapConfigFn: flags.WrapConfigFn,
}
cfg := new(action.Configuration)
func ensureHelmConfig(flags *genericclioptions.ConfigFlags, ns string) (*action.Configuration, error) {
settings := &genericclioptions.ConfigFlags{
Namespace: &ns,
}
cfg := new(action.Configuration)

Copy link
Owner

Choose a reason for hiding this comment

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

@thorbenbelow nw Thank you Thorben! right I think flags.Namespace = &ns should be all we need.

Copy link
Author

Choose a reason for hiding this comment

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

I see what you mean. However, in this case usePersistentConfig must be false. Would you still prefer that over copying the config for helm operations?

There is also a PR in helm that should fix this issue as well. Not sure if that gets merged any time soon though.

Copy link
Owner

Choose a reason for hiding this comment

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

@thorbenbelow Thank you Thorben! I think the core issue here is helm does not use the passed in ns and create their own api client via a factory. Let's keep your original impl for the time being and make a copy of the flags prior to calling the helm api which I think is the safest course of action.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry for the late reply. I squashed my changes and rebased.
Do we need tests for this or is there anything else needed to make this PR mergeable?

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.

Helm rollback uses default namespace
2 participants