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:
parent
2ad21b3df0
commit
3728b6f647
|
|
@ -194,8 +194,9 @@ helmDefaults:
|
||||||
skipSchemaValidation: false
|
skipSchemaValidation: false
|
||||||
# wait for k8s resources via --wait. (default false)
|
# wait for k8s resources via --wait. (default false)
|
||||||
wait: true
|
wait: true
|
||||||
# if set and --wait enabled, will retry any failed check on resource state subject to the specified number of retries (default 0)
|
# DEPRECATED: waitRetries is no longer supported as the --wait-retries flag was removed from Helm.
|
||||||
waitRetries: 3
|
# 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)
|
# 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
|
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)
|
# 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)
|
# --skip-schema-validation flag to helm 'install', 'upgrade' and 'lint', starts with helm 3.16.0 (default false)
|
||||||
skipSchemaValidation: false
|
skipSchemaValidation: false
|
||||||
wait: true
|
wait: true
|
||||||
waitRetries: 3
|
# DEPRECATED: waitRetries is no longer supported - see documentation above
|
||||||
|
# waitRetries: 3
|
||||||
waitForJobs: true
|
waitForJobs: true
|
||||||
timeout: 60
|
timeout: 60
|
||||||
recreatePods: true
|
recreatePods: true
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"slices"
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/helmfile/chartify"
|
"github.com/helmfile/chartify"
|
||||||
|
|
@ -158,31 +157,17 @@ func (st *HelmState) appendWaitForJobsFlags(flags []string, release *ReleaseSpec
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
func (st *HelmState) appendWaitFlags(flags []string, helm helmexec.Interface, release *ReleaseSpec, ops *SyncOpts) []string {
|
func (st *HelmState) appendWaitFlags(flags []string, release *ReleaseSpec, ops *SyncOpts) []string {
|
||||||
var hasWait bool
|
|
||||||
switch {
|
switch {
|
||||||
case release.Wait != nil && *release.Wait:
|
case release.Wait != nil && *release.Wait:
|
||||||
hasWait = true
|
|
||||||
flags = append(flags, "--wait")
|
flags = append(flags, "--wait")
|
||||||
case ops != nil && ops.Wait:
|
case ops != nil && ops.Wait:
|
||||||
hasWait = true
|
|
||||||
flags = append(flags, "--wait")
|
flags = append(flags, "--wait")
|
||||||
case release.Wait == nil && st.HelmDefaults.Wait:
|
case release.Wait == nil && st.HelmDefaults.Wait:
|
||||||
hasWait = true
|
|
||||||
flags = append(flags, "--wait")
|
flags = append(flags, "--wait")
|
||||||
}
|
}
|
||||||
// see https://github.com/helm/helm/releases/tag/v3.15.0
|
// Note: --wait-retries flag has been removed from Helm and is no longer supported
|
||||||
// https://github.com/helm/helm/commit/fc74964
|
// WaitRetries configuration is preserved for backward compatibility but ignored
|
||||||
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))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,6 @@ func TestAppendWaitFlags(t *testing.T) {
|
||||||
name string
|
name string
|
||||||
release *ReleaseSpec
|
release *ReleaseSpec
|
||||||
syncOpts *SyncOpts
|
syncOpts *SyncOpts
|
||||||
helm helmexec.Interface
|
|
||||||
helmSpec HelmSpec
|
helmSpec HelmSpec
|
||||||
expected []string
|
expected []string
|
||||||
}{
|
}{
|
||||||
|
|
@ -85,7 +84,6 @@ func TestAppendWaitFlags(t *testing.T) {
|
||||||
name: "release wait",
|
name: "release wait",
|
||||||
release: &ReleaseSpec{Wait: &[]bool{true}[0]},
|
release: &ReleaseSpec{Wait: &[]bool{true}[0]},
|
||||||
syncOpts: nil,
|
syncOpts: nil,
|
||||||
helm: testutil.NewVersionHelmExec("3.11.0"),
|
|
||||||
helmSpec: HelmSpec{},
|
helmSpec: HelmSpec{},
|
||||||
expected: []string{"--wait"},
|
expected: []string{"--wait"},
|
||||||
},
|
},
|
||||||
|
|
@ -93,7 +91,6 @@ func TestAppendWaitFlags(t *testing.T) {
|
||||||
name: "cli flags wait",
|
name: "cli flags wait",
|
||||||
release: &ReleaseSpec{},
|
release: &ReleaseSpec{},
|
||||||
syncOpts: &SyncOpts{Wait: true},
|
syncOpts: &SyncOpts{Wait: true},
|
||||||
helm: testutil.NewVersionHelmExec("3.11.0"),
|
|
||||||
helmSpec: HelmSpec{},
|
helmSpec: HelmSpec{},
|
||||||
expected: []string{"--wait"},
|
expected: []string{"--wait"},
|
||||||
},
|
},
|
||||||
|
|
@ -101,7 +98,6 @@ func TestAppendWaitFlags(t *testing.T) {
|
||||||
name: "helm defaults wait",
|
name: "helm defaults wait",
|
||||||
release: &ReleaseSpec{},
|
release: &ReleaseSpec{},
|
||||||
syncOpts: nil,
|
syncOpts: nil,
|
||||||
helm: testutil.NewVersionHelmExec("3.11.0"),
|
|
||||||
helmSpec: HelmSpec{Wait: true},
|
helmSpec: HelmSpec{Wait: true},
|
||||||
expected: []string{"--wait"},
|
expected: []string{"--wait"},
|
||||||
},
|
},
|
||||||
|
|
@ -109,7 +105,6 @@ func TestAppendWaitFlags(t *testing.T) {
|
||||||
name: "release wait false",
|
name: "release wait false",
|
||||||
release: &ReleaseSpec{Wait: &[]bool{false}[0]},
|
release: &ReleaseSpec{Wait: &[]bool{false}[0]},
|
||||||
syncOpts: nil,
|
syncOpts: nil,
|
||||||
helm: testutil.NewVersionHelmExec("3.11.0"),
|
|
||||||
helmSpec: HelmSpec{Wait: true},
|
helmSpec: HelmSpec{Wait: true},
|
||||||
expected: []string{},
|
expected: []string{},
|
||||||
},
|
},
|
||||||
|
|
@ -117,7 +112,6 @@ func TestAppendWaitFlags(t *testing.T) {
|
||||||
name: "cli flags wait false",
|
name: "cli flags wait false",
|
||||||
release: &ReleaseSpec{},
|
release: &ReleaseSpec{},
|
||||||
syncOpts: &SyncOpts{},
|
syncOpts: &SyncOpts{},
|
||||||
helm: testutil.NewVersionHelmExec("3.11.0"),
|
|
||||||
helmSpec: HelmSpec{Wait: true},
|
helmSpec: HelmSpec{Wait: true},
|
||||||
expected: []string{"--wait"},
|
expected: []string{"--wait"},
|
||||||
},
|
},
|
||||||
|
|
@ -125,66 +119,58 @@ func TestAppendWaitFlags(t *testing.T) {
|
||||||
name: "helm defaults wait false",
|
name: "helm defaults wait false",
|
||||||
release: &ReleaseSpec{},
|
release: &ReleaseSpec{},
|
||||||
syncOpts: nil,
|
syncOpts: nil,
|
||||||
helm: testutil.NewVersionHelmExec("3.11.0"),
|
|
||||||
helmSpec: HelmSpec{Wait: false},
|
helmSpec: HelmSpec{Wait: false},
|
||||||
expected: []string{},
|
expected: []string{},
|
||||||
},
|
},
|
||||||
// --wait-retries
|
// --wait-retries flag has been removed from Helm
|
||||||
{
|
{
|
||||||
name: "release wait and retry unsupported",
|
name: "release wait and retry unsupported",
|
||||||
release: &ReleaseSpec{Wait: &[]bool{true}[0], WaitRetries: &[]int{1}[0]},
|
release: &ReleaseSpec{Wait: &[]bool{true}[0], WaitRetries: &[]int{1}[0]},
|
||||||
syncOpts: nil,
|
syncOpts: nil,
|
||||||
helm: testutil.NewVersionHelmExec("3.11.0"),
|
|
||||||
helmSpec: HelmSpec{},
|
helmSpec: HelmSpec{},
|
||||||
expected: []string{"--wait"},
|
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]},
|
release: &ReleaseSpec{Wait: &[]bool{true}[0], WaitRetries: &[]int{1}[0]},
|
||||||
syncOpts: nil,
|
syncOpts: nil,
|
||||||
helm: testutil.NewVersionHelmExec("3.15.0"),
|
|
||||||
helmSpec: HelmSpec{},
|
helmSpec: HelmSpec{},
|
||||||
expected: []string{"--wait", "--wait-retries", "1"},
|
expected: []string{"--wait"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "no wait retry",
|
name: "no wait retry",
|
||||||
release: &ReleaseSpec{WaitRetries: &[]int{1}[0]},
|
release: &ReleaseSpec{WaitRetries: &[]int{1}[0]},
|
||||||
syncOpts: nil,
|
syncOpts: nil,
|
||||||
helm: testutil.NewVersionHelmExec("3.15.0"),
|
|
||||||
helmSpec: HelmSpec{},
|
helmSpec: HelmSpec{},
|
||||||
expected: []string{},
|
expected: []string{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "cli flags wait and retry",
|
name: "cli flags wait and retry - retries ignored",
|
||||||
release: &ReleaseSpec{},
|
release: &ReleaseSpec{},
|
||||||
syncOpts: &SyncOpts{Wait: true, WaitRetries: 2},
|
syncOpts: &SyncOpts{Wait: true, WaitRetries: 2},
|
||||||
helm: testutil.NewVersionHelmExec("3.15.0"),
|
|
||||||
helmSpec: HelmSpec{},
|
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{},
|
release: &ReleaseSpec{},
|
||||||
syncOpts: nil,
|
syncOpts: nil,
|
||||||
helm: testutil.NewVersionHelmExec("3.15.0"),
|
|
||||||
helmSpec: HelmSpec{Wait: true, WaitRetries: 3},
|
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]},
|
release: &ReleaseSpec{Wait: &[]bool{true}[0]},
|
||||||
syncOpts: nil,
|
syncOpts: nil,
|
||||||
helm: testutil.NewVersionHelmExec("3.15.0"),
|
|
||||||
helmSpec: HelmSpec{WaitRetries: 4},
|
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]},
|
release: &ReleaseSpec{WaitRetries: &[]int{5}[0]},
|
||||||
syncOpts: nil,
|
syncOpts: nil,
|
||||||
helm: testutil.NewVersionHelmExec("3.15.0"),
|
|
||||||
helmSpec: HelmSpec{Wait: true},
|
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) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
st := &HelmState{}
|
st := &HelmState{}
|
||||||
st.HelmDefaults = tt.helmSpec
|
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)
|
require.Equalf(t, tt.expected, got, "appendWaitFlags() = %v, want %v", got, tt.expected)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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, 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"`
|
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
|
// 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"`
|
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, 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"`
|
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, 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"`
|
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
|
// 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"`
|
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, 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"`
|
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.appendChartVersionFlags(flags, release)
|
||||||
flags = st.appendEnableDNSFlags(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)
|
flags = st.appendWaitForJobsFlags(flags, release, opt)
|
||||||
|
|
||||||
// non-OCI chart should be verified here
|
// non-OCI chart should be verified here
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue