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

Error: "cannot re-use a name that is still in use" #161

Open
zchenyu opened this issue May 1, 2023 · 3 comments · May be fixed by #162
Open

Error: "cannot re-use a name that is still in use" #161

zchenyu opened this issue May 1, 2023 · 3 comments · May be fixed by #162

Comments

@zchenyu
Copy link

zchenyu commented May 1, 2023

I'm using

_, err := client.InstallOrUpgradeChart(ctx, &helmclient.ChartSpec{
    ReleaseName:     chart.releaseName,
    Namespace:       chart.namespace,
    Version:         chart.version,
    ChartName:       chart.chartName,
})

to install or upgrade a chart to a new version, but am getting this error: "cannot re-use a name that is still in use"

I thought this function would upgrade the chart if the release already exists. Is there some other function or parameter that I should be using to make it upgrade if there's a newer version and the release already exists?

@zchenyu
Copy link
Author

zchenyu commented May 1, 2023

Okay I think I found the issue:

if r.Name == spec.ReleaseName && r.Namespace == spec.Namespace {

If Namespace is not set in ChartSpec to default to the "default" namespace, this equality will fail. I think we need to update this function to account for that.

The workaround is to always explicitly set Namespace in ChartSpec.

@zchenyu
Copy link
Author

zchenyu commented May 3, 2023

Actually, this doesn't work 100% of the time since sometimes r.Namespace is "default" and sometimes it's "". I think it might depend on how the chart was installed.

@zchenyu
Copy link
Author

zchenyu commented May 4, 2023

PR with fix: #162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant