Commit fefa00fc authored by Matt Butcher's avatar Matt Butcher

fix(tiller): return status for deleted release

This modifies `helm status` to return info about deleted and failed
releases. We do our best to retrieve info for releases that were
partially deployed.
parent bf9dea13
......@@ -83,7 +83,9 @@ func PrintStatus(out io.Writer, res *services.GetReleaseStatusResponse) {
fmt.Fprintf(out, "Details: %s\n", res.Info.Status.Details)
}
fmt.Fprintf(out, "\n")
if len(res.Info.Status.Resources) > 0 {
fmt.Fprintf(out, "Resources:\n%s\n", res.Info.Status.Resources)
}
if len(res.Info.Status.Notes) > 0 {
fmt.Fprintf(out, "Notes:\n%s\n", res.Info.Status.Notes)
}
......
......@@ -190,17 +190,22 @@ func (s *releaseServer) GetReleaseStatus(c ctx.Context, req *services.GetRelease
return nil, errors.New("release chart is missing")
}
sc := rel.Info.Status.Code
statusResp := &services.GetReleaseStatusResponse{Info: rel.Info, Namespace: rel.Namespace}
// Ok, we got the status of the release as we had jotted down, now we need to match the
// manifest we stashed away with reality from the cluster.
kubeCli := s.env.KubeClient
resp, err := kubeCli.Get(rel.Namespace, bytes.NewBufferString(rel.Manifest))
if err != nil {
if sc == release.Status_DELETED || sc == release.Status_FAILED {
// Skip errors if this is already deleted or failed.
return statusResp, nil
} else if err != nil {
log.Printf("warning: Get for %s failed: %v", rel.Name, err)
return nil, err
}
rel.Info.Status.Resources = resp
return &services.GetReleaseStatusResponse{Info: rel.Info, Namespace: rel.Namespace}, nil
return statusResp, nil
}
func (s *releaseServer) GetReleaseContent(c ctx.Context, req *services.GetReleaseContentRequest) (*services.GetReleaseContentResponse, error) {
......
......@@ -711,6 +711,25 @@ func TestGetReleaseStatus(t *testing.T) {
}
}
func TestGetReleaseStatusDeleted(t *testing.T) {
c := context.Background()
rs := rsFixture()
rel := releaseStub()
rel.Info.Status.Code = release.Status_DELETED
if err := rs.env.Releases.Create(rel); err != nil {
t.Fatalf("Could not store mock release: %s", err)
}
res, err := rs.GetReleaseStatus(c, &services.GetReleaseStatusRequest{Name: rel.Name})
if err != nil {
t.Errorf("Error getting release content: %s", err)
}
if res.Info.Status.Code != release.Status_DELETED {
t.Errorf("Expected %d, got %d", release.Status_DELETED, res.Info.Status.Code)
}
}
func TestListReleases(t *testing.T) {
rs := rsFixture()
num := 7
......
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