Commit 13e5c2f3 authored by Michelle Noorali's avatar Michelle Noorali Committed by GitHub

Merge pull request #1353 from michelleN/ref-rollback

bug(tiller): correct release statuses on rollback
parents bf405541 1ad84745
......@@ -407,18 +407,18 @@ func (s *releaseServer) RollbackRelease(c ctx.Context, req *services.RollbackRel
return nil, err
}
rel, err := s.performRollback(currentRelease, targetRelease, req)
res, err := s.performRollback(currentRelease, targetRelease, req)
if err != nil {
return nil, err
return res, err
}
if !req.DryRun {
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) {
......@@ -437,7 +437,12 @@ func (s *releaseServer) performRollback(currentRelease, targetRelease *release.R
}
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
......@@ -448,9 +453,7 @@ func (s *releaseServer) performRollback(currentRelease, targetRelease *release.R
}
currentRelease.Info.Status.Code = release.Status_SUPERSEDED
if err := s.env.Releases.Update(currentRelease); err != nil {
return nil, fmt.Errorf("Update of %s failed: %s", currentRelease.Name, err)
}
s.recordRelease(currentRelease, true)
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) {
c := helm.NewContext()
rs := rsFixture()
......
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