From 197e466b9a72be8999436ca756deab16452f752a Mon Sep 17 00:00:00 2001 From: Michelle Noorali Date: Thu, 25 Aug 2016 09:06:14 -0600 Subject: [PATCH] ref(*): return resource update errors Resolves #1058 --- cmd/helm/upgrade.go | 2 +- cmd/tiller/release_server.go | 2 +- pkg/kube/client.go | 16 +++++++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 3b7de8ec8..10251dadd 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -125,7 +125,7 @@ func (u *upgradeCmd) run() error { _, err = u.client.UpdateRelease(u.release, chartPath, helm.UpdateValueOverrides(rawVals), helm.UpgradeDryRun(u.dryRun), helm.UpgradeDisableHooks(u.disableHooks)) if err != nil { - return prettyError(err) + return fmt.Errorf("UPGRADE FAILED: %v", prettyError(err)) } success := u.release + " has been upgraded. Happy Helming!\n" diff --git a/cmd/tiller/release_server.go b/cmd/tiller/release_server.go index 5c103e90d..cd3de35f6 100644 --- a/cmd/tiller/release_server.go +++ b/cmd/tiller/release_server.go @@ -224,7 +224,7 @@ func (s *releaseServer) performUpdate(originalRelease, updatedRelease *release.R original := bytes.NewBufferString(originalRelease.Manifest) modified := bytes.NewBufferString(updatedRelease.Manifest) if err := kubeCli.Update(updatedRelease.Namespace, original, modified); err != nil { - return nil, fmt.Errorf("Update of %s failed: %s", updatedRelease.Name, err) + return nil, err } // post-upgrade hooks diff --git a/pkg/kube/client.go b/pkg/kube/client.go index 6e5e74e30..529d2b4c4 100644 --- a/pkg/kube/client.go +++ b/pkg/kube/client.go @@ -22,6 +22,7 @@ import ( "io" "log" "reflect" + "strings" "time" "k8s.io/kubernetes/pkg/api" @@ -157,8 +158,9 @@ func (c *Client) Update(namespace string, currentReader, modifiedReader io.Reade } modifiedInfos := []*resource.Info{} + updateErrors := []string{} - modified.Visit(func(info *resource.Info, err error) error { + err = modified.Visit(func(info *resource.Info, err error) error { modifiedInfos = append(modifiedInfos, info) if err != nil { return err @@ -188,15 +190,23 @@ func (c *Client) Update(namespace string, currentReader, modifiedReader io.Reade if err := updateResource(info, currentObj); err != nil { log.Printf("error updating the resource %s:\n\t %v", resourceName, err) - return err + updateErrors = append(updateErrors, err.Error()) } - return err + return nil }) deleteUnwantedResources(currentInfos, modifiedInfos) + if err != nil { + return err + } else if len(updateErrors) != 0 { + return fmt.Errorf(strings.Join(updateErrors, " && ")) + + } + return nil + } // Delete deletes kubernetes resources from an io.reader