From 3728b6f647b4bce2df2d9a09b379f857d9eb4a01 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Thu, 11 Sep 2025 13:57:28 +0800 Subject: [PATCH] Remove deprecated --wait-retries flag support to fix Helm compatibility error (#2179) * Remove --wait-retries flag support and update documentation Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com> * Fix unused helm parameter in appendWaitFlags function Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com> --- docs/index.md | 8 +++++--- pkg/state/helmx.go | 21 +++------------------ pkg/state/helmx_test.go | 38 ++++++++++++-------------------------- pkg/state/state.go | 4 +++- 4 files changed, 23 insertions(+), 48 deletions(-) diff --git a/docs/index.md b/docs/index.md index 399f356b..59d3442f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -194,8 +194,9 @@ helmDefaults: skipSchemaValidation: false # wait for k8s resources via --wait. (default false) wait: true - # if set and --wait enabled, will retry any failed check on resource state subject to the specified number of retries (default 0) - waitRetries: 3 + # DEPRECATED: waitRetries is no longer supported as the --wait-retries flag was removed from Helm. + # This configuration is ignored and preserved only for backward compatibility. + # waitRetries: 3 # if set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout (default false, Implemented in Helm3.5) waitForJobs: true # time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks, and waits on pod/pvc/svc/deployment readiness) (default 300) @@ -318,7 +319,8 @@ releases: # --skip-schema-validation flag to helm 'install', 'upgrade' and 'lint', starts with helm 3.16.0 (default false) skipSchemaValidation: false wait: true - waitRetries: 3 + # DEPRECATED: waitRetries is no longer supported - see documentation above + # waitRetries: 3 waitForJobs: true timeout: 60 recreatePods: true diff --git a/pkg/state/helmx.go b/pkg/state/helmx.go index eca4b2cb..c906f61d 100644 --- a/pkg/state/helmx.go +++ b/pkg/state/helmx.go @@ -6,7 +6,6 @@ import ( "path/filepath" "slices" "sort" - "strconv" "strings" "github.com/helmfile/chartify" @@ -158,31 +157,17 @@ func (st *HelmState) appendWaitForJobsFlags(flags []string, release *ReleaseSpec return flags } -func (st *HelmState) appendWaitFlags(flags []string, helm helmexec.Interface, release *ReleaseSpec, ops *SyncOpts) []string { - var hasWait bool +func (st *HelmState) appendWaitFlags(flags []string, release *ReleaseSpec, ops *SyncOpts) []string { switch { case release.Wait != nil && *release.Wait: - hasWait = true flags = append(flags, "--wait") case ops != nil && ops.Wait: - hasWait = true flags = append(flags, "--wait") case release.Wait == nil && st.HelmDefaults.Wait: - hasWait = true flags = append(flags, "--wait") } - // see https://github.com/helm/helm/releases/tag/v3.15.0 - // https://github.com/helm/helm/commit/fc74964 - if hasWait && helm.IsVersionAtLeast("3.15.0") { - switch { - case release.WaitRetries != nil && *release.WaitRetries > 0: - flags = append(flags, "--wait-retries", strconv.Itoa(*release.WaitRetries)) - case ops != nil && ops.WaitRetries > 0: - flags = append(flags, "--wait-retries", strconv.Itoa(ops.WaitRetries)) - case release.WaitRetries == nil && st.HelmDefaults.WaitRetries > 0: - flags = append(flags, "--wait-retries", strconv.Itoa(st.HelmDefaults.WaitRetries)) - } - } + // Note: --wait-retries flag has been removed from Helm and is no longer supported + // WaitRetries configuration is preserved for backward compatibility but ignored return flags } diff --git a/pkg/state/helmx_test.go b/pkg/state/helmx_test.go index 90bfb83e..78c0c3d1 100644 --- a/pkg/state/helmx_test.go +++ b/pkg/state/helmx_test.go @@ -76,7 +76,6 @@ func TestAppendWaitFlags(t *testing.T) { name string release *ReleaseSpec syncOpts *SyncOpts - helm helmexec.Interface helmSpec HelmSpec expected []string }{ @@ -85,7 +84,6 @@ func TestAppendWaitFlags(t *testing.T) { name: "release wait", release: &ReleaseSpec{Wait: &[]bool{true}[0]}, syncOpts: nil, - helm: testutil.NewVersionHelmExec("3.11.0"), helmSpec: HelmSpec{}, expected: []string{"--wait"}, }, @@ -93,7 +91,6 @@ func TestAppendWaitFlags(t *testing.T) { name: "cli flags wait", release: &ReleaseSpec{}, syncOpts: &SyncOpts{Wait: true}, - helm: testutil.NewVersionHelmExec("3.11.0"), helmSpec: HelmSpec{}, expected: []string{"--wait"}, }, @@ -101,7 +98,6 @@ func TestAppendWaitFlags(t *testing.T) { name: "helm defaults wait", release: &ReleaseSpec{}, syncOpts: nil, - helm: testutil.NewVersionHelmExec("3.11.0"), helmSpec: HelmSpec{Wait: true}, expected: []string{"--wait"}, }, @@ -109,7 +105,6 @@ func TestAppendWaitFlags(t *testing.T) { name: "release wait false", release: &ReleaseSpec{Wait: &[]bool{false}[0]}, syncOpts: nil, - helm: testutil.NewVersionHelmExec("3.11.0"), helmSpec: HelmSpec{Wait: true}, expected: []string{}, }, @@ -117,7 +112,6 @@ func TestAppendWaitFlags(t *testing.T) { name: "cli flags wait false", release: &ReleaseSpec{}, syncOpts: &SyncOpts{}, - helm: testutil.NewVersionHelmExec("3.11.0"), helmSpec: HelmSpec{Wait: true}, expected: []string{"--wait"}, }, @@ -125,66 +119,58 @@ func TestAppendWaitFlags(t *testing.T) { name: "helm defaults wait false", release: &ReleaseSpec{}, syncOpts: nil, - helm: testutil.NewVersionHelmExec("3.11.0"), helmSpec: HelmSpec{Wait: false}, expected: []string{}, }, - // --wait-retries + // --wait-retries flag has been removed from Helm { name: "release wait and retry unsupported", release: &ReleaseSpec{Wait: &[]bool{true}[0], WaitRetries: &[]int{1}[0]}, syncOpts: nil, - helm: testutil.NewVersionHelmExec("3.11.0"), helmSpec: HelmSpec{}, expected: []string{"--wait"}, }, { - name: "release wait and retry supported", + name: "release wait and retry - retries ignored", release: &ReleaseSpec{Wait: &[]bool{true}[0], WaitRetries: &[]int{1}[0]}, syncOpts: nil, - helm: testutil.NewVersionHelmExec("3.15.0"), helmSpec: HelmSpec{}, - expected: []string{"--wait", "--wait-retries", "1"}, + expected: []string{"--wait"}, }, { name: "no wait retry", release: &ReleaseSpec{WaitRetries: &[]int{1}[0]}, syncOpts: nil, - helm: testutil.NewVersionHelmExec("3.15.0"), helmSpec: HelmSpec{}, expected: []string{}, }, { - name: "cli flags wait and retry", + name: "cli flags wait and retry - retries ignored", release: &ReleaseSpec{}, syncOpts: &SyncOpts{Wait: true, WaitRetries: 2}, - helm: testutil.NewVersionHelmExec("3.15.0"), helmSpec: HelmSpec{}, - expected: []string{"--wait", "--wait-retries", "2"}, + expected: []string{"--wait"}, }, { - name: "helm defaults wait retry", + name: "helm defaults wait retry - retries ignored", release: &ReleaseSpec{}, syncOpts: nil, - helm: testutil.NewVersionHelmExec("3.15.0"), helmSpec: HelmSpec{Wait: true, WaitRetries: 3}, - expected: []string{"--wait", "--wait-retries", "3"}, + expected: []string{"--wait"}, }, { - name: "release wait default retries", + name: "release wait default retries - retries ignored", release: &ReleaseSpec{Wait: &[]bool{true}[0]}, syncOpts: nil, - helm: testutil.NewVersionHelmExec("3.15.0"), helmSpec: HelmSpec{WaitRetries: 4}, - expected: []string{"--wait", "--wait-retries", "4"}, + expected: []string{"--wait"}, }, { - name: "release retries default wait", + name: "release retries default wait - retries ignored", release: &ReleaseSpec{WaitRetries: &[]int{5}[0]}, syncOpts: nil, - helm: testutil.NewVersionHelmExec("3.15.0"), helmSpec: HelmSpec{Wait: true}, - expected: []string{"--wait", "--wait-retries", "5"}, + expected: []string{"--wait"}, }, } @@ -192,7 +178,7 @@ func TestAppendWaitFlags(t *testing.T) { t.Run(tt.name, func(t *testing.T) { st := &HelmState{} st.HelmDefaults = tt.helmSpec - got := st.appendWaitFlags([]string{}, tt.helm, tt.release, tt.syncOpts) + got := st.appendWaitFlags([]string{}, tt.release, tt.syncOpts) require.Equalf(t, tt.expected, got, "appendWaitFlags() = %v, want %v", got, tt.expected) }) } diff --git a/pkg/state/state.go b/pkg/state/state.go index 19d576d7..85f8dee9 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -163,6 +163,7 @@ type HelmSpec struct { // Wait, if set to true, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful Wait bool `yaml:"wait"` // WaitRetries, if set and --wait enabled, will retry any failed check on resource state, except if HTTP status code < 500 is received, subject to the specified number of retries + // DEPRECATED: This field is ignored as the --wait-retries flag was removed from Helm. Preserved for backward compatibility. WaitRetries int `yaml:"waitRetries"` // WaitForJobs, if set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout WaitForJobs bool `yaml:"waitForJobs"` @@ -264,6 +265,7 @@ type ReleaseSpec struct { // Wait, if set to true, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment are in a ready state before marking the release as successful Wait *bool `yaml:"wait,omitempty"` // WaitRetries, if set and --wait enabled, will retry any failed check on resource state, except if HTTP status code < 500 is received, subject to the specified number of retries + // DEPRECATED: This field is ignored as the --wait-retries flag was removed from Helm. Preserved for backward compatibility. WaitRetries *int `yaml:"waitRetries,omitempty"` // WaitForJobs, if set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout WaitForJobs *bool `yaml:"waitForJobs,omitempty"` @@ -2797,7 +2799,7 @@ func (st *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSp flags = st.appendChartVersionFlags(flags, release) flags = st.appendEnableDNSFlags(flags, release) - flags = st.appendWaitFlags(flags, helm, release, opt) + flags = st.appendWaitFlags(flags, release, opt) flags = st.appendWaitForJobsFlags(flags, release, opt) // non-OCI chart should be verified here