Use Create method if no resources need to be adopted

Signed-off-by: Jacob LeGrone <git@jacob.work>
pull/7649/head
Jacob LeGrone 6 years ago
parent 271cb2268b
commit d829343c15
No known key found for this signature in database
GPG Key ID: 5FD0852F235368C1

@ -243,7 +243,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release.
// Mark this release as in-progress // Mark this release as in-progress
rel.SetStatus(release.StatusPendingInstall, "Initial install underway") rel.SetStatus(release.StatusPendingInstall, "Initial install underway")
var adoptedResources kube.ResourceList var toBeAdopted kube.ResourceList
resources, err := i.cfg.KubeClient.Build(bytes.NewBufferString(rel.Manifest), !i.DisableOpenAPIValidation) resources, err := i.cfg.KubeClient.Build(bytes.NewBufferString(rel.Manifest), !i.DisableOpenAPIValidation)
if err != nil { if err != nil {
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")
@ -261,11 +261,10 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release.
// 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 !i.ClientOnly && !isUpgrade { if !i.ClientOnly && !isUpgrade {
toBeUpdated, err := existingResourceConflict(resources, rel.Name, rel.Namespace) toBeAdopted, err = existingResourceConflict(resources, rel.Name, rel.Namespace)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "rendered manifests contain a resource that already exists. Unable to continue with install") return nil, errors.Wrap(err, "rendered manifests contain a resource that already exists. Unable to continue with install")
} }
adoptedResources = toBeUpdated
} }
// Bail out here if it is a dry run // Bail out here if it is a dry run
@ -300,8 +299,14 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release.
// At this point, we can do the install. Note that before we were detecting whether to // At this point, we can do the install. Note that before we were detecting whether to
// do an update, but it's not clear whether we WANT to do an update if the re-use is set // do an update, but it's not clear whether we WANT to do an update if the re-use is set
// to true, since that is basically an upgrade operation. // to true, since that is basically an upgrade operation.
if _, err := i.cfg.KubeClient.Update(adoptedResources, resources, false); err != nil { if len(toBeAdopted) == 0 {
return i.failRelease(rel, err) if _, err := i.cfg.KubeClient.Create(resources); err != nil {
return i.failRelease(rel, err)
}
} else {
if _, err := i.cfg.KubeClient.Update(toBeAdopted, resources, false); err != nil {
return i.failRelease(rel, err)
}
} }
if i.Wait { if i.Wait {

Loading…
Cancel
Save