mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-22 07:51:01 +02:00
Enable --wait-for-jobs flag introduced in helm 3.5 (#1715)
Fixes #1650 Fixes #785 This change introduces: - `--wait-for-jobs` CLI override option to helmfile binary - `waitForJobs` helmDefaults parameter (default `false`) - `waitForJobs` release parameter (default `false`) Note that `--wait-for-jobs` was introduced in Helm 3.5 (https://github.com/helm/helm/pull/8363)
This commit is contained in:
@@ -130,6 +130,8 @@ type HelmSpec struct {
|
||||
Devel bool `yaml:"devel"`
|
||||
// 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"`
|
||||
// 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"`
|
||||
// Timeout is the time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks, and waits on pod/pvc/svc/deployment readiness) (default 300)
|
||||
Timeout int `yaml:"timeout"`
|
||||
// RecreatePods, when set to true, instruct helmfile to perform pods restart for the resource if applicable
|
||||
@@ -186,6 +188,8 @@ type ReleaseSpec struct {
|
||||
Devel *bool `yaml:"devel,omitempty"`
|
||||
// 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"`
|
||||
// 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"`
|
||||
// Timeout is the time in seconds to wait for any individual Kubernetes operation (like Jobs for hooks, and waits on pod/pvc/svc/deployment readiness) (default 300)
|
||||
Timeout *int `yaml:"timeout,omitempty"`
|
||||
// RecreatePods, when set to true, instruct helmfile to perform pods restart for the resource if applicable
|
||||
@@ -512,6 +516,10 @@ func (st *HelmState) prepareSyncReleases(helm helmexec.Interface, additionalValu
|
||||
flags = append(flags, "--wait")
|
||||
}
|
||||
|
||||
if opts.WaitForJobs {
|
||||
flags = append(flags, "--wait-for-jobs")
|
||||
}
|
||||
|
||||
if len(errs) > 0 {
|
||||
results <- syncPrepareResult{errors: errs, files: files}
|
||||
continue
|
||||
@@ -587,6 +595,7 @@ type SyncOpts struct {
|
||||
Set []string
|
||||
SkipCleanup bool
|
||||
Wait bool
|
||||
WaitForJobs bool
|
||||
}
|
||||
|
||||
type SyncOpt interface{ Apply(*SyncOpts) }
|
||||
@@ -886,6 +895,7 @@ type ChartPrepareOptions struct {
|
||||
SkipDeps bool
|
||||
SkipResolve bool
|
||||
Wait bool
|
||||
WaitForJobs bool
|
||||
}
|
||||
|
||||
type chartPrepareResult struct {
|
||||
@@ -2243,6 +2253,10 @@ func (st *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSp
|
||||
flags = append(flags, "--wait")
|
||||
}
|
||||
|
||||
if release.WaitForJobs != nil && *release.WaitForJobs || release.WaitForJobs == nil && st.HelmDefaults.WaitForJobs {
|
||||
flags = append(flags, "--wait-for-jobs")
|
||||
}
|
||||
|
||||
flags = append(flags, st.timeoutFlags(helm, release)...)
|
||||
|
||||
if release.Force != nil && *release.Force || release.Force == nil && st.HelmDefaults.Force {
|
||||
|
||||
@@ -313,6 +313,24 @@ func TestHelmState_flagsForUpgrade(t *testing.T) {
|
||||
"--namespace", "test-namespace",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "wait-for-jobs",
|
||||
defaults: HelmSpec{
|
||||
WaitForJobs: false,
|
||||
},
|
||||
release: &ReleaseSpec{
|
||||
Chart: "test/chart",
|
||||
Version: "0.1",
|
||||
WaitForJobs: &enable,
|
||||
Name: "test-charts",
|
||||
Namespace: "test-namespace",
|
||||
},
|
||||
want: []string{
|
||||
"--version", "0.1",
|
||||
"--wait-for-jobs",
|
||||
"--namespace", "test-namespace",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "devel",
|
||||
defaults: HelmSpec{
|
||||
|
||||
@@ -37,39 +37,39 @@ func TestGenerateID(t *testing.T) {
|
||||
run(testcase{
|
||||
subject: "baseline",
|
||||
release: ReleaseSpec{Name: "foo", Chart: "incubator/raw"},
|
||||
want: "foo-values-67b55dc69b",
|
||||
want: "foo-values-779795898b",
|
||||
})
|
||||
|
||||
run(testcase{
|
||||
subject: "different bytes content",
|
||||
release: ReleaseSpec{Name: "foo", Chart: "incubator/raw"},
|
||||
data: []byte(`{"k":"v"}`),
|
||||
want: "foo-values-5988bf4947",
|
||||
want: "foo-values-6b7ffbccc",
|
||||
})
|
||||
|
||||
run(testcase{
|
||||
subject: "different map content",
|
||||
release: ReleaseSpec{Name: "foo", Chart: "incubator/raw"},
|
||||
data: map[string]interface{}{"k": "v"},
|
||||
want: "foo-values-5d6fb4db97",
|
||||
want: "foo-values-6d57bbfccf",
|
||||
})
|
||||
|
||||
run(testcase{
|
||||
subject: "different chart",
|
||||
release: ReleaseSpec{Name: "foo", Chart: "stable/envoy"},
|
||||
want: "foo-values-58db655b79",
|
||||
want: "foo-values-5c45b58947",
|
||||
})
|
||||
|
||||
run(testcase{
|
||||
subject: "different name",
|
||||
release: ReleaseSpec{Name: "bar", Chart: "incubator/raw"},
|
||||
want: "bar-values-797d6df4dc",
|
||||
want: "bar-values-99d5fdbcc",
|
||||
})
|
||||
|
||||
run(testcase{
|
||||
subject: "specific ns",
|
||||
release: ReleaseSpec{Name: "foo", Chart: "incubator/raw", Namespace: "myns"},
|
||||
want: "myns-foo-values-5f867c6d49",
|
||||
want: "myns-foo-values-544cb97d7f",
|
||||
})
|
||||
|
||||
for id, n := range ids {
|
||||
|
||||
Reference in New Issue
Block a user