Commit 87ab6673 authored by Matt Butcher's avatar Matt Butcher

fix(tiller): when delete fails, mark release as deleted

When a deletion fails to remove a manifest file, the release should
still be marked as deleted. This changes the error handling to try to
delete all manifests, and then mark the release as deleted, then return
the errors.

Closes #1305
parent 11078091
...@@ -855,20 +855,20 @@ func (s *releaseServer) UninstallRelease(c ctx.Context, req *services.UninstallR ...@@ -855,20 +855,20 @@ func (s *releaseServer) UninstallRelease(c ctx.Context, req *services.UninstallR
// We could instead just delete everything in no particular order. // We could instead just delete everything in no particular order.
return nil, err return nil, err
} }
// Note: We could re-join these into one file and delete just that one. Or
// we could collect errors (instead of bailing on the first error) and try // Collect the errors, and return them later.
// to delete as much as possible instead of failing at the first error. es := []string{}
for _, file := range files { for _, file := range files {
b := bytes.NewBufferString(file.content) b := bytes.NewBufferString(file.content)
if err := s.env.KubeClient.Delete(rel.Namespace, b); err != nil { if err := s.env.KubeClient.Delete(rel.Namespace, b); err != nil {
log.Printf("uninstall: Failed deletion of %q: %s", req.Name, err) log.Printf("uninstall: Failed deletion of %q: %s", req.Name, err)
return nil, err es = append(es, err.Error())
} }
} }
if !req.DisableHooks { if !req.DisableHooks {
if err := s.execHook(rel.Hooks, rel.Name, rel.Namespace, postDelete); err != nil { if err := s.execHook(rel.Hooks, rel.Name, rel.Namespace, postDelete); err != nil {
return res, err es = append(es, err.Error())
} }
} }
...@@ -882,7 +882,12 @@ func (s *releaseServer) UninstallRelease(c ctx.Context, req *services.UninstallR ...@@ -882,7 +882,12 @@ func (s *releaseServer) UninstallRelease(c ctx.Context, req *services.UninstallR
} }
} }
return res, nil var errs error
if len(es) > 0 {
errs = fmt.Errorf("deletion error count %d: %s", len(es), strings.Join(es, "; "))
}
return res, errs
} }
// byName implements the sort.Interface for []*release.Release. // byName implements the sort.Interface for []*release.Release.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment