Merge pull request #3097 from adamreese/fix/2437-upgrade-release

fix(tiller): upgrade last deployed release
pull/3110/head
Adam Reese 7 years ago committed by GitHub
commit d6da76f3cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,6 +18,7 @@ package storage // import "k8s.io/helm/pkg/storage"
import ( import (
"fmt" "fmt"
"strings"
rspb "k8s.io/helm/pkg/proto/hapi/release" rspb "k8s.io/helm/pkg/proto/hapi/release"
relutil "k8s.io/helm/pkg/releaseutil" relutil "k8s.io/helm/pkg/releaseutil"
@ -127,14 +128,13 @@ func (s *Storage) Deployed(name string) (*rspb.Release, error) {
"OWNER": "TILLER", "OWNER": "TILLER",
"STATUS": "DEPLOYED", "STATUS": "DEPLOYED",
}) })
switch { if err == nil {
case err != nil:
return nil, err
case len(ls) == 0:
return nil, fmt.Errorf("%q has no deployed releases", name)
default:
return ls[0], nil return ls[0], nil
} }
if strings.Contains(err.Error(), "not found") {
return nil, fmt.Errorf("%q has no deployed releases", name)
}
return nil, err
} }
// History returns the revision history for the release with the provided name, or // History returns the revision history for the release with the provided name, or

@ -69,8 +69,8 @@ func (s *ReleaseServer) prepareUpdate(req *services.UpdateReleaseRequest) (*rele
return nil, nil, errMissingChart return nil, nil, errMissingChart
} }
// finds the non-deleted release with the given name // finds the deployed release with the given name
currentRelease, err := s.env.Releases.Last(req.Name) currentRelease, err := s.env.Releases.Deployed(req.Name)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -80,9 +80,15 @@ func (s *ReleaseServer) prepareUpdate(req *services.UpdateReleaseRequest) (*rele
return nil, nil, err return nil, nil, err
} }
// finds the non-deleted release with the given name
lastRelease, err := s.env.Releases.Last(req.Name)
if err != nil {
return nil, nil, err
}
// Increment revision count. This is passed to templates, and also stored on // Increment revision count. This is passed to templates, and also stored on
// the release object. // the release object.
revision := currentRelease.Version + 1 revision := lastRelease.Version + 1
ts := timeconv.Now() ts := timeconv.Now()
options := chartutil.ReleaseOptions{ options := chartutil.ReleaseOptions{
@ -151,7 +157,6 @@ func (s *ReleaseServer) performUpdate(originalRelease, updatedRelease *release.R
if err := s.ReleaseModule.Update(originalRelease, updatedRelease, req, s.env); err != nil { if err := s.ReleaseModule.Update(originalRelease, updatedRelease, req, s.env); err != nil {
msg := fmt.Sprintf("Upgrade %q failed: %s", updatedRelease.Name, err) msg := fmt.Sprintf("Upgrade %q failed: %s", updatedRelease.Name, err)
s.Log("warning: %s", msg) s.Log("warning: %s", msg)
originalRelease.Info.Status.Code = release.Status_SUPERSEDED
updatedRelease.Info.Status.Code = release.Status_FAILED updatedRelease.Info.Status.Code = release.Status_FAILED
updatedRelease.Info.Description = msg updatedRelease.Info.Description = msg
s.recordRelease(originalRelease, true) s.recordRelease(originalRelease, true)

@ -234,8 +234,8 @@ func TestUpdateReleaseFailure(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("Expected to be able to get previous release") t.Errorf("Expected to be able to get previous release")
} }
if oldStatus := oldRelease.Info.Status.Code; oldStatus != release.Status_SUPERSEDED { if oldStatus := oldRelease.Info.Status.Code; oldStatus != release.Status_DEPLOYED {
t.Errorf("Expected SUPERSEDED status on previous Release version. Got %v", oldStatus) t.Errorf("Expected Deployed status on previous Release version. Got %v", oldStatus)
} }
} }

Loading…
Cancel
Save