Signed-off-by: Lentil1016 <lentil1016@gmail.com>
pull/3744/head
Lentil1016 8 years ago
parent 48e7039970
commit ea29162fad

@ -346,7 +346,7 @@ func (s *ReleaseServer) execHook(hs []*release.Hook, name, namespace, hook strin
executingHooks = sortByHookWeight(executingHooks) executingHooks = sortByHookWeight(executingHooks)
for _, h := range executingHooks { for index, h := range executingHooks {
b := bytes.NewBufferString(h.Manifest) b := bytes.NewBufferString(h.Manifest)
if err := kubeCli.Create(namespace, b, timeout, false); err != nil { if err := kubeCli.Create(namespace, b, timeout, false); err != nil {
@ -360,6 +360,19 @@ func (s *ReleaseServer) execHook(hs []*release.Hook, name, namespace, hook strin
s.Log("warning: Release %s %s %s could not complete: %s", name, hook, h.Path, err) s.Log("warning: Release %s %s %s could not complete: %s", name, hook, h.Path, err)
// If a hook is failed, checkout the annotation of the hook to determine whether the hook should be deleted // If a hook is failed, checkout the annotation of the hook to determine whether the hook should be deleted
// under failed condition. If so, then clear the corresponding resource object in the hook // under failed condition. If so, then clear the corresponding resource object in the hook
// Delete previous succeeded hooks with hook-delete-policy hook-succeeded
for _, hp := range executingHooks[:index] {
if hookShouldBeDeleted(hp, hooks.HookSucceeded) {
b.Reset()
b.WriteString(hp.Manifest)
s.Log("deleting %s hook %s for release %s due to %q policy", hook, hp.Name, name, hooks.HookSucceeded)
if errHookDelete := kubeCli.Delete(namespace, b); errHookDelete != nil {
s.Log("warning: Release %s %s %S could not be deleted: %s", name, hook, hp.Path, errHookDelete)
return errHookDelete
}
}
hp.LastRun = timeconv.Now()
}
if hookShouldBeDeleted(h, hooks.HookFailed) { if hookShouldBeDeleted(h, hooks.HookFailed) {
b.Reset() b.Reset()
b.WriteString(h.Manifest) b.WriteString(h.Manifest)

Loading…
Cancel
Save