Merge pull request #1353 from michelleN/ref-rollback

bug(tiller): correct release statuses on rollback
pull/1359/head
Michelle Noorali 8 years ago committed by GitHub
commit 13e5c2f380

@ -407,18 +407,18 @@ func (s *releaseServer) RollbackRelease(c ctx.Context, req *services.RollbackRel
return nil, err return nil, err
} }
rel, err := s.performRollback(currentRelease, targetRelease, req) res, err := s.performRollback(currentRelease, targetRelease, req)
if err != nil { if err != nil {
return nil, err return res, err
} }
if !req.DryRun { if !req.DryRun {
if err := s.env.Releases.Create(targetRelease); err != nil { if err := s.env.Releases.Create(targetRelease); err != nil {
return nil, err return res, err
} }
} }
return rel, nil return res, nil
} }
func (s *releaseServer) performRollback(currentRelease, targetRelease *release.Release, req *services.RollbackReleaseRequest) (*services.RollbackReleaseResponse, error) { func (s *releaseServer) performRollback(currentRelease, targetRelease *release.Release, req *services.RollbackReleaseRequest) (*services.RollbackReleaseResponse, error) {
@ -437,7 +437,12 @@ func (s *releaseServer) performRollback(currentRelease, targetRelease *release.R
} }
if err := s.performKubeUpdate(currentRelease, targetRelease); err != nil { if err := s.performKubeUpdate(currentRelease, targetRelease); err != nil {
return nil, err log.Printf("warning: Release Rollback %q failed: %s", targetRelease.Name, err)
currentRelease.Info.Status.Code = release.Status_SUPERSEDED
targetRelease.Info.Status.Code = release.Status_FAILED
s.recordRelease(currentRelease, true)
s.recordRelease(targetRelease, false)
return res, err
} }
// post-rollback hooks // post-rollback hooks
@ -448,9 +453,7 @@ func (s *releaseServer) performRollback(currentRelease, targetRelease *release.R
} }
currentRelease.Info.Status.Code = release.Status_SUPERSEDED currentRelease.Info.Status.Code = release.Status_SUPERSEDED
if err := s.env.Releases.Update(currentRelease); err != nil { s.recordRelease(currentRelease, true)
return nil, fmt.Errorf("Update of %s failed: %s", currentRelease.Name, err)
}
targetRelease.Info.Status.Code = release.Status_DEPLOYED targetRelease.Info.Status.Code = release.Status_DEPLOYED

@ -623,6 +623,39 @@ func TestUpdateReleaseFailure(t *testing.T) {
} }
} }
func TestRollbackReleaseFailure(t *testing.T) {
c := helm.NewContext()
rs := rsFixture()
rel := releaseStub()
rs.env.Releases.Create(rel)
upgradedRel := upgradeReleaseVersion(rel)
rs.env.Releases.Update(rel)
rs.env.Releases.Create(upgradedRel)
req := &services.RollbackReleaseRequest{
Name: rel.Name,
DisableHooks: true,
}
rs.env.KubeClient = newUpdateFailingKubeClient()
res, err := rs.RollbackRelease(c, req)
if err == nil {
t.Error("Expected failed rollback")
}
if targetStatus := res.Release.Info.Status.Code; targetStatus != release.Status_FAILED {
t.Errorf("Expected FAILED release. Got %v", targetStatus)
}
oldRelease, err := rs.env.Releases.Get(rel.Name, rel.Version)
if err != nil {
t.Errorf("Expected to be able to get previous release")
}
if oldStatus := oldRelease.Info.Status.Code; oldStatus != release.Status_SUPERSEDED {
t.Errorf("Expected SUPERSEDED status on previous Release version. Got %v", oldStatus)
}
}
func TestUpdateReleaseNoHooks(t *testing.T) { func TestUpdateReleaseNoHooks(t *testing.T) {
c := helm.NewContext() c := helm.NewContext()
rs := rsFixture() rs := rsFixture()

Loading…
Cancel
Save