go-helm-client icon indicating copy to clipboard operation
go-helm-client copied to clipboard

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

Open zchenyu opened this issue 2 years ago • 3 comments

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 avatar May 01 '23 19:05 zchenyu

Okay I think I found the issue: https://github.com/mittwald/go-helm-client/blob/43db5e2a1d107a2e3a845ad228b8a14824f8cc32/client.go#L784

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 avatar May 01 '23 19:05 zchenyu

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 avatar May 03 '23 23:05 zchenyu

PR with fix: https://github.com/mittwald/go-helm-client/pull/162

zchenyu avatar May 04 '23 18:05 zchenyu