diff --git a/cmd/tiller/release_server.go b/cmd/tiller/release_server.go index 4f00791f5..21a531238 100644 --- a/cmd/tiller/release_server.go +++ b/cmd/tiller/release_server.go @@ -803,6 +803,15 @@ func (s *releaseServer) execHook(hs []*release.Hook, name, namespace, hook strin return nil } +func (s *releaseServer) purgeReleases(rels ...*release.Release) error { + for _, rel := range rels { + if _, err := s.env.Releases.Delete(rel.Name, rel.Version); err != nil { + return err + } + } + return nil +} + func (s *releaseServer) UninstallRelease(c ctx.Context, req *services.UninstallReleaseRequest) (*services.UninstallReleaseResponse, error) { if !checkClientVersion(c) { return nil, errIncompatibleVersion @@ -829,7 +838,7 @@ func (s *releaseServer) UninstallRelease(c ctx.Context, req *services.UninstallR // already marked deleted? if rel.Info.Status.Code == release.Status_DELETED { if req.Purge { - if _, err := s.env.Releases.Delete(rel.Name, rel.Version); err != nil { + if err := s.purgeReleases(rels...); err != nil { log.Printf("uninstall: Failed to purge the release: %s", err) return nil, err } @@ -882,7 +891,7 @@ func (s *releaseServer) UninstallRelease(c ctx.Context, req *services.UninstallR log.Printf("uninstall: Failed to store updated release: %s", err) } } else { - if _, err := s.env.Releases.Delete(rel.Name, rel.Version); err != nil { + if err := s.purgeReleases(rels...); err != nil { log.Printf("uninstall: Failed to purge the release: %s", err) } } diff --git a/cmd/tiller/release_server_test.go b/cmd/tiller/release_server_test.go index e3073c189..98cfe6ea9 100644 --- a/cmd/tiller/release_server_test.go +++ b/cmd/tiller/release_server_test.go @@ -902,7 +902,11 @@ func TestUninstallRelease(t *testing.T) { func TestUninstallPurgeRelease(t *testing.T) { c := helm.NewContext() rs := rsFixture() - rs.env.Releases.Create(releaseStub()) + rel := releaseStub() + rs.env.Releases.Create(rel) + upgradedRel := upgradeReleaseVersion(rel) + rs.env.Releases.Update(rel) + rs.env.Releases.Create(upgradedRel) req := &services.UninstallReleaseRequest{ Name: "angry-panda", @@ -922,13 +926,16 @@ func TestUninstallPurgeRelease(t *testing.T) { t.Errorf("Expected status code to be DELETED, got %d", res.Release.Info.Status.Code) } - if res.Release.Hooks[0].LastRun.Seconds == 0 { - t.Error("Expected LastRun to be greater than zero.") - } - if res.Release.Info.Deleted.Seconds <= 0 { t.Errorf("Expected valid UNIX date, got %d", res.Release.Info.Deleted.Seconds) } + rels, err := rs.GetHistory(helm.NewContext(), &services.GetHistoryRequest{Name: "angry-panda"}) + if err != nil { + t.Fatal(err) + } + if len(rels.Releases) != 0 { + t.Errorf("Expected no releases in storage, got %d", len(rels.Releases)) + } } func TestUninstallPurgeDeleteRelease(t *testing.T) {