fix(pkg/kube/client.go): cannot upgrade release after upgrade release failed in a certain case

In a certain case, if charts updates with add a new k8s resource, and upgrade release failed. The
failed reason is upgrade other res ources failed excepet the n ew k8s resource. In this case,
results cannot upgrade success anymore, it would throw an error like that " no %s with the name %q
found"(release not found)

Signed-off-by: skydai <corndai1997@gmail.com>
pull/9074/head
skydai 5 years ago
parent 2be0d141a6
commit 4089fe0d03

@ -211,8 +211,21 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err
originalInfo := original.Get(info) originalInfo := original.Get(info)
if originalInfo == nil { if originalInfo == nil {
kind := info.Mapping.GroupVersionKind.Kind c.Log("Warning: %s/%s is found in k8s, but not found in previous release info", info.Namespace, info.Name)
return errors.Errorf("no %s with the name %q found", kind, info.Name) c.Log("Deleting %q in %s...", info.Name, info.Namespace)
if err := deleteResource(info); err != nil {
c.Log("Failed to delete %q, err: %s", info.Name, err)
return errors.Wrap(err, "Failed to delete resource")
}
res.Deleted = append(res.Deleted, info)
if err := createResource(info); err != nil {
return errors.Wrap(err, "failed to create resource")
}
// Append the created resource to the results
res.Created = append(res.Created, info)
return nil
} }
if err := updateResource(c, info, originalInfo.Object, force); err != nil { if err := updateResource(c, info, originalInfo.Object, force); err != nil {

Loading…
Cancel
Save