Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
pull/6542/head
Taylor Thomas 5 years ago
parent 36f3a4b326
commit 6ccb2897d9

@ -225,20 +225,22 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release.
return nil, errors.Wrap(err, "unable to build kubernetes objects from release manifest") return nil, errors.Wrap(err, "unable to build kubernetes objects from release manifest")
} }
// Bail out here if it is a dry run
if i.DryRun {
rel.Info.Description = "Dry run complete"
return rel, nil
}
// Install requires an extra validation step of checking that resources // Install requires an extra validation step of checking that resources
// don't already exist before we actually create resources. If we continue // don't already exist before we actually create resources. If we continue
// forward and create the release object with resources that already exist, // forward and create the release object with resources that already exist,
// we'll end up in a state where we will delete those resources upon // we'll end up in a state where we will delete those resources upon
// deleting the release because the manifest will be pointing at that // deleting the release because the manifest will be pointing at that
// resource // resource
if err := existingResourceConflict(resources); err != nil { if !i.ClientOnly {
return nil, errors.Wrap(err, "rendered manifests contain a resource that already exists. Unable to continue with install") if err := existingResourceConflict(resources); err != nil {
return nil, errors.Wrap(err, "rendered manifests contain a resource that already exists. Unable to continue with install")
}
}
// Bail out here if it is a dry run
if i.DryRun {
rel.Info.Description = "Dry run complete"
return rel, nil
} }
// If Replace is true, we need to supercede the last release. // If Replace is true, we need to supercede the last release.

@ -199,12 +199,6 @@ func (u *Upgrade) performUpgrade(originalRelease, upgradedRelease *release.Relea
return upgradedRelease, errors.Wrap(err, "unable to build kubernetes objects from new release manifest") return upgradedRelease, errors.Wrap(err, "unable to build kubernetes objects from new release manifest")
} }
if u.DryRun {
u.cfg.Log("dry run for %s", upgradedRelease.Name)
upgradedRelease.Info.Description = "Dry run complete"
return upgradedRelease, nil
}
// Do a basic diff using gvk + name to figure out what new resources are being created so we can validate they don't already exist // Do a basic diff using gvk + name to figure out what new resources are being created so we can validate they don't already exist
existingResources := make(map[string]bool) existingResources := make(map[string]bool)
for _, r := range current { for _, r := range current {
@ -222,6 +216,12 @@ func (u *Upgrade) performUpgrade(originalRelease, upgradedRelease *release.Relea
return nil, errors.Wrap(err, "rendered manifests contain a new resource that already exists. Unable to continue with update") return nil, errors.Wrap(err, "rendered manifests contain a new resource that already exists. Unable to continue with update")
} }
if u.DryRun {
u.cfg.Log("dry run for %s", upgradedRelease.Name)
upgradedRelease.Info.Description = "Dry run complete"
return upgradedRelease, nil
}
u.cfg.Log("creating upgraded release for %s", upgradedRelease.Name) u.cfg.Log("creating upgraded release for %s", upgradedRelease.Name)
if err := u.cfg.Releases.Create(upgradedRelease); err != nil { if err := u.cfg.Releases.Create(upgradedRelease); err != nil {
return nil, err return nil, err

@ -191,9 +191,13 @@ func (c *Client) Update(original, target ResourceList, force bool) (*Result, err
for _, info := range original.Difference(target) { for _, info := range original.Difference(target) {
c.Log("Deleting %q in %s...", info.Name, info.Namespace) c.Log("Deleting %q in %s...", info.Name, info.Namespace)
res.Deleted = append(res.Deleted, info) res.Deleted = append(res.Deleted, info)
if err := deleteResource(info); err != nil && !apierrors.IsNotFound(err) { if err := deleteResource(info); err != nil {
c.Log("Failed to delete %q, err: %s", info.Name, err) if apierrors.IsNotFound(err) {
return res, errors.Wrapf(err, "Failed to delete %q", info.Name) c.Log("Attempted to delete %q, but the resource was missing", info.Name)
} else {
c.Log("Failed to delete %q, err: %s", info.Name, err)
return res, errors.Wrapf(err, "Failed to delete %q", info.Name)
}
} }
} }
return res, nil return res, nil

Loading…
Cancel
Save