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>
This commit is contained in:
Copilot 2025-09-11 13:57:28 +08:00 committed by GitHub
parent 2ad21b3df0
commit 3728b6f647
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 48 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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)
})
}

View File

@ -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