fixup! Fix preapply hook behavior
Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
parent
c2ea0f0355
commit
111a248523
|
|
@ -960,13 +960,17 @@ func withDAG(templated *state.HelmState, helm helmexec.Interface, logger *zap.Su
|
||||||
return false, []error{err}
|
return false, []error{err}
|
||||||
}
|
}
|
||||||
|
|
||||||
return withBatches(templated, batches, helm, logger, converge)
|
return withBatches(opts.Purpose, templated, batches, helm, logger, converge)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withBatches(templated *state.HelmState, batches [][]state.Release, helm helmexec.Interface, logger *zap.SugaredLogger, converge func(*state.HelmState, helmexec.Interface) (bool, []error)) (bool, []error) {
|
func withBatches(purpose string, templated *state.HelmState, batches [][]state.Release, helm helmexec.Interface, logger *zap.SugaredLogger, converge func(*state.HelmState, helmexec.Interface) (bool, []error)) (bool, []error) {
|
||||||
numBatches := len(batches)
|
numBatches := len(batches)
|
||||||
|
|
||||||
logger.Debugf("processing %d groups of releases in this order:\n%s", numBatches, printBatches(batches))
|
if purpose == "" {
|
||||||
|
purpose = "processing"
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Debugf("%s %d groups of releases in this order:\n%s", purpose, numBatches, printBatches(batches))
|
||||||
|
|
||||||
any := false
|
any := false
|
||||||
|
|
||||||
|
|
@ -983,7 +987,7 @@ func withBatches(templated *state.HelmState, batches [][]state.Release, helm hel
|
||||||
releaseIds = append(releaseIds, state.ReleaseToID(&release))
|
releaseIds = append(releaseIds, state.ReleaseToID(&release))
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Debugf("processing releases in group %d/%d: %s", i+1, numBatches, strings.Join(releaseIds, ", "))
|
logger.Debugf("%s releases in group %d/%d: %s", purpose, i+1, numBatches, strings.Join(releaseIds, ", "))
|
||||||
|
|
||||||
batchSt := *templated
|
batchSt := *templated
|
||||||
batchSt.Releases = targets
|
batchSt.Releases = targets
|
||||||
|
|
@ -1360,7 +1364,7 @@ Do you really want to apply?
|
||||||
st.Releases = selectedAndNeededReleases
|
st.Releases = selectedAndNeededReleases
|
||||||
|
|
||||||
if !interactive || interactive && r.askForConfirmation(confMsg) {
|
if !interactive || interactive && r.askForConfirmation(confMsg) {
|
||||||
if _, preapplyErrors := withDAG(st, helm, a.Logger, state.PlanOptions{Reverse: true, SelectedReleases: toDelete, SkipNeeds: true}, a.WrapWithoutSelector(func(subst *state.HelmState, helm helmexec.Interface) []error {
|
if _, preapplyErrors := withDAG(st, helm, a.Logger, state.PlanOptions{Purpose: "invoking preapply hooks for", Reverse: true, SelectedReleases: toApplyWithNeeds, SkipNeeds: true}, a.WrapWithoutSelector(func(subst *state.HelmState, helm helmexec.Interface) []error {
|
||||||
for _, r := range subst.Releases {
|
for _, r := range subst.Releases {
|
||||||
release := r
|
release := r
|
||||||
if _, err := st.TriggerPreapplyEvent(&release, "apply"); err != nil {
|
if _, err := st.TriggerPreapplyEvent(&release, "apply"); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,13 @@ Affected releases are:
|
||||||
bar (stable/mychart2) DELETED
|
bar (stable/mychart2) DELETED
|
||||||
foo (stable/mychart1) UPDATED
|
foo (stable/mychart1) UPDATED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default//bar
|
||||||
|
2 default//foo
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default//bar
|
||||||
|
invoking preapply hooks for releases in group 2/2: default//foo
|
||||||
processing 1 groups of releases in this order:
|
processing 1 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default//bar
|
1 default//bar
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,13 @@ Affected releases are:
|
||||||
bar (stable/mychart2) DELETED
|
bar (stable/mychart2) DELETED
|
||||||
foo (stable/mychart1) UPDATED
|
foo (stable/mychart1) UPDATED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default//foo
|
||||||
|
2 default//bar
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default//foo
|
||||||
|
invoking preapply hooks for releases in group 2/2: default//bar
|
||||||
processing 1 groups of releases in this order:
|
processing 1 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default//bar
|
1 default//bar
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,13 @@ Affected releases are:
|
||||||
bar (stable/mychart2) DELETED
|
bar (stable/mychart2) DELETED
|
||||||
foo (stable/mychart1) DELETED
|
foo (stable/mychart1) DELETED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default//bar
|
||||||
|
2 default//foo
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default//bar
|
||||||
|
invoking preapply hooks for releases in group 2/2: default//foo
|
||||||
processing 2 groups of releases in this order:
|
processing 2 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default//bar
|
1 default//bar
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,13 @@ Affected releases are:
|
||||||
bar (stable/mychart2) DELETED
|
bar (stable/mychart2) DELETED
|
||||||
foo (stable/mychart1) DELETED
|
foo (stable/mychart1) DELETED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default//foo
|
||||||
|
2 default//bar
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default//foo
|
||||||
|
invoking preapply hooks for releases in group 2/2: default//bar
|
||||||
processing 2 groups of releases in this order:
|
processing 2 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default//foo
|
1 default//foo
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,13 @@ Affected releases are:
|
||||||
bar (stable/mychart2) UPDATED
|
bar (stable/mychart2) UPDATED
|
||||||
foo (stable/mychart1) DELETED
|
foo (stable/mychart1) DELETED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default//bar
|
||||||
|
2 default//foo
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default//bar
|
||||||
|
invoking preapply hooks for releases in group 2/2: default//foo
|
||||||
processing 1 groups of releases in this order:
|
processing 1 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default//foo
|
1 default//foo
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,13 @@ Affected releases are:
|
||||||
bar (stable/mychart2) UPDATED
|
bar (stable/mychart2) UPDATED
|
||||||
foo (stable/mychart1) DELETED
|
foo (stable/mychart1) DELETED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default//foo
|
||||||
|
2 default//bar
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default//foo
|
||||||
|
invoking preapply hooks for releases in group 2/2: default//bar
|
||||||
processing 1 groups of releases in this order:
|
processing 1 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default//foo
|
1 default//foo
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,13 @@ Affected releases are:
|
||||||
bar (stable/mychart2) UPDATED
|
bar (stable/mychart2) UPDATED
|
||||||
foo (stable/mychart1) UPDATED
|
foo (stable/mychart1) UPDATED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default/tns1/foo
|
||||||
|
2 default/tns2/bar
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default/tns1/foo
|
||||||
|
invoking preapply hooks for releases in group 2/2: default/tns2/bar
|
||||||
processing 2 groups of releases in this order:
|
processing 2 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default/tns2/bar
|
1 default/tns2/bar
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,13 @@ Affected releases are:
|
||||||
baz (stable/mychart3) UPDATED
|
baz (stable/mychart3) UPDATED
|
||||||
foo (stable/mychart1) UPDATED
|
foo (stable/mychart1) UPDATED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default//foo
|
||||||
|
2 default//baz, default//bar
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default//foo
|
||||||
|
invoking preapply hooks for releases in group 2/2: default//baz, default//bar
|
||||||
processing 2 groups of releases in this order:
|
processing 2 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default//baz, default//bar
|
1 default//baz, default//bar
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,19 @@ Affected releases are:
|
||||||
logging (charts/fluent-bit) UPDATED
|
logging (charts/fluent-bit) UPDATED
|
||||||
servicemesh (charts/istio) UPDATED
|
servicemesh (charts/istio) UPDATED
|
||||||
|
|
||||||
|
invoking preapply hooks for 5 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default//frontend-v1, default//frontend-v2, default//frontend-v3
|
||||||
|
2 default//backend-v1, default//backend-v2
|
||||||
|
3 default//anotherbackend
|
||||||
|
4 default//database, default//servicemesh
|
||||||
|
5 default//logging, default//front-proxy
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/5: default//frontend-v1, default//frontend-v2, default//frontend-v3
|
||||||
|
invoking preapply hooks for releases in group 2/5: default//backend-v1, default//backend-v2
|
||||||
|
invoking preapply hooks for releases in group 3/5: default//anotherbackend
|
||||||
|
invoking preapply hooks for releases in group 4/5: default//database, default//servicemesh
|
||||||
|
invoking preapply hooks for releases in group 5/5: default//logging, default//front-proxy
|
||||||
processing 2 groups of releases in this order:
|
processing 2 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default//frontend-v1
|
1 default//frontend-v1
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,13 @@ Affected releases are:
|
||||||
bar (stable/mychart2) UPDATED
|
bar (stable/mychart2) UPDATED
|
||||||
foo (stable/mychart1) UPDATED
|
foo (stable/mychart1) UPDATED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default/testNamespace/bar
|
||||||
|
2 default/testNamespace/foo
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default/testNamespace/bar
|
||||||
|
invoking preapply hooks for releases in group 2/2: default/testNamespace/foo
|
||||||
processing 2 groups of releases in this order:
|
processing 2 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default/testNamespace/foo
|
1 default/testNamespace/foo
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,13 @@ Affected releases are:
|
||||||
bar (stable/mychart2) UPDATED
|
bar (stable/mychart2) UPDATED
|
||||||
foo (stable/mychart1) UPDATED
|
foo (stable/mychart1) UPDATED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default//bar
|
||||||
|
2 default//foo
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default//bar
|
||||||
|
invoking preapply hooks for releases in group 2/2: default//foo
|
||||||
processing 2 groups of releases in this order:
|
processing 2 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default//foo
|
1 default//foo
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,13 @@ Affected releases are:
|
||||||
bar (stable/mychart2) UPDATED
|
bar (stable/mychart2) UPDATED
|
||||||
foo (stable/mychart1) UPDATED
|
foo (stable/mychart1) UPDATED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default/testNamespace/foo
|
||||||
|
2 default/testNamespace/bar
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default/testNamespace/foo
|
||||||
|
invoking preapply hooks for releases in group 2/2: default/testNamespace/bar
|
||||||
processing 2 groups of releases in this order:
|
processing 2 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default/testNamespace/bar
|
1 default/testNamespace/bar
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,13 @@ Affected releases are:
|
||||||
bar (stable/mychart2) UPDATED
|
bar (stable/mychart2) UPDATED
|
||||||
foo (stable/mychart1) UPDATED
|
foo (stable/mychart1) UPDATED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default//foo
|
||||||
|
2 default//bar
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default//foo
|
||||||
|
invoking preapply hooks for releases in group 2/2: default//bar
|
||||||
processing 2 groups of releases in this order:
|
processing 2 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default//bar
|
1 default//bar
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,13 @@ Affected releases are:
|
||||||
bar (stable/mychart2) UPDATED
|
bar (stable/mychart2) UPDATED
|
||||||
foo (stable/mychart1) UPDATED
|
foo (stable/mychart1) UPDATED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default/ns1/foo
|
||||||
|
2 default/ns2/bar
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default/ns1/foo
|
||||||
|
invoking preapply hooks for releases in group 2/2: default/ns2/bar
|
||||||
processing 2 groups of releases in this order:
|
processing 2 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default/ns2/bar
|
1 default/ns2/bar
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,13 @@ Affected releases are:
|
||||||
bar (stable/mychart2) UPDATED
|
bar (stable/mychart2) UPDATED
|
||||||
foo (stable/mychart1) UPDATED
|
foo (stable/mychart1) UPDATED
|
||||||
|
|
||||||
|
invoking preapply hooks for 2 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default/ns2/bar
|
||||||
|
2 default/ns1/foo
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/2: default/ns2/bar
|
||||||
|
invoking preapply hooks for releases in group 2/2: default/ns1/foo
|
||||||
processing 2 groups of releases in this order:
|
processing 2 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default/ns1/foo
|
1 default/ns1/foo
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,11 @@ merged environment: &{default map[] map[]}
|
||||||
Affected releases are:
|
Affected releases are:
|
||||||
foo (incubator/raw) UPDATED
|
foo (incubator/raw) UPDATED
|
||||||
|
|
||||||
|
invoking preapply hooks for 1 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default/default/foo
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/1: default/default/foo
|
||||||
processing 1 groups of releases in this order:
|
processing 1 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default/default/foo
|
1 default/default/foo
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,11 @@ merged environment: &{default map[] map[]}
|
||||||
Affected releases are:
|
Affected releases are:
|
||||||
foo (incubator/raw) UPDATED
|
foo (incubator/raw) UPDATED
|
||||||
|
|
||||||
|
invoking preapply hooks for 1 groups of releases in this order:
|
||||||
|
GROUP RELEASES
|
||||||
|
1 default/default/foo
|
||||||
|
|
||||||
|
invoking preapply hooks for releases in group 1/1: default/default/foo
|
||||||
processing 1 groups of releases in this order:
|
processing 1 groups of releases in this order:
|
||||||
GROUP RELEASES
|
GROUP RELEASES
|
||||||
1 default/default/foo
|
1 default/default/foo
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ hook[prepare] logs |
|
||||||
hook[preapply] logs | foo
|
hook[preapply] logs | foo
|
||||||
hook[preapply] logs |
|
hook[preapply] logs |
|
||||||
|
|
||||||
|
hook[preapply] logs | bar
|
||||||
|
hook[preapply] logs |
|
||||||
|
|
||||||
hook[presync] logs | foo
|
hook[presync] logs | foo
|
||||||
hook[presync] logs |
|
hook[presync] logs |
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,15 @@
|
||||||
hook[prepare] logs | foo
|
hook[prepare] logs | foo
|
||||||
hook[prepare] logs |
|
hook[prepare] logs |
|
||||||
|
|
||||||
|
hook[preapply] logs | foo
|
||||||
|
hook[preapply] logs |
|
||||||
|
|
||||||
hook[preapply] logs | bar
|
hook[preapply] logs | bar
|
||||||
hook[preapply] logs |
|
hook[preapply] logs |
|
||||||
|
|
||||||
hook[presync] logs | bar
|
hook[presync] logs | bar
|
||||||
hook[presync] logs |
|
hook[presync] logs |
|
||||||
|
|
||||||
hook[preapply] logs | foo
|
|
||||||
hook[preapply] logs |
|
|
||||||
|
|
||||||
hook[presync] logs | foo
|
hook[presync] logs | foo
|
||||||
hook[presync] logs |
|
hook[presync] logs |
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ func (st *HelmState) iterateOnReleases(helm helmexec.Interface, concurrency int,
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlanOptions struct {
|
type PlanOptions struct {
|
||||||
|
Purpose string
|
||||||
Reverse bool
|
Reverse bool
|
||||||
IncludeNeeds bool
|
IncludeNeeds bool
|
||||||
IncludeTransitiveNeeds bool
|
IncludeTransitiveNeeds bool
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue