Skip to content

Commit

Permalink
fix(tiller): show failed YAML
Browse files Browse the repository at this point in the history
When an install fails and --dry-run is set, return the broken YAML for
the user to debug.

Closes #1499
  • Loading branch information
technosophos committed Nov 14, 2016
1 parent e4bbe33 commit 6eabe28
Showing 1 changed file with 38 additions and 3 deletions.
41 changes: 38 additions & 3 deletions pkg/tiller/release_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,14 @@ func (s *ReleaseServer) InstallRelease(c ctx.Context, req *services.InstallRelea
rel, err := s.prepareRelease(req)
if err != nil {
log.Printf("Failed install prepare step: %s", err)
return nil, err
res := &services.InstallReleaseResponse{Release: rel}

// On dry run, append the manifest contents to a failed release. This is
// a stop-gap until we can revisit an error backchannel post-2.0.
if req.DryRun && strings.HasPrefix(err.Error(), "YAML parse error") {
err = fmt.Errorf("%s\n%s", err, rel.Manifest)
}
return res, err
}

res, err := s.performRelease(rel, req)
Expand Down Expand Up @@ -625,7 +632,24 @@ func (s *ReleaseServer) prepareRelease(req *services.InstallReleaseRequest) (*re

hooks, manifestDoc, notesTxt, err := s.renderResources(req.Chart, valuesToRender)
if err != nil {
return nil, err
// Return a release with partial data so that client can show debugging
// information.
rel := &release.Release{
Name: name,
Namespace: req.Namespace,
Chart: req.Chart,
Config: req.Values,
Info: &release.Info{
FirstDeployed: ts,
LastDeployed: ts,
Status: &release.Status{Code: release.Status_UNKNOWN},
},
Version: 0,
}
if manifestDoc != nil {
rel.Manifest = manifestDoc.String()
}
return rel, err
}

// Store a release.
Expand Down Expand Up @@ -708,7 +732,18 @@ func (s *ReleaseServer) renderResources(ch *chart.Chart, values chartutil.Values
if err != nil {
// By catching parse errors here, we can prevent bogus releases from going
// to Kubernetes.
return nil, nil, "", err
//
// We return the files as a big blob of data to help the user debug parser
// errors.
b := bytes.NewBuffer(nil)
for name, content := range files {
if len(strings.TrimSpace(content)) == 0 {
continue
}
b.WriteString("\n---\n# Source: " + name + "\n")
b.WriteString(content)
}
return nil, b, "", err
}

// Aggregate all valid manifests into one big doc.
Expand Down

0 comments on commit 6eabe28

Please sign in to comment.