Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Removes delete action from ihelm-operator manual release sync
Browse files Browse the repository at this point in the history
The original assumption was that user's cluster only contains
Chart releases defined by FluxHelmReleases stored in git repo.
As a result the provided implementation deleted any release
not having a FHR counterpart. This resulted in unwanted deletions
such as helm-operator deleting itself when deployed as a Chart etc
  • Loading branch information
Tamara Kaufler committed Apr 23, 2018
1 parent 6f427cb commit 3765416
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 32 deletions.
1 change: 0 additions & 1 deletion integrations/helm/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var (
type Action string

const (
DeleteAction Action = "DELETE"
InstallAction Action = "CREATE"
UpgradeAction Action = "UPDATE"
)
Expand Down
44 changes: 13 additions & 31 deletions integrations/helm/releasesync/releasesync.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,40 +154,28 @@ func (rs *ReleaseChangeSync) addExistingReleasesToSync(
chRels = relsToSync[ns]
for relName := range nsRelsM {
if customResources[ns] == nil {
chr := chartRelease{
releaseName: relName,
action: chartrelease.DeleteAction,
desiredState: ifv1.FluxHelmRelease{},
}
chRels = append(chRels, chr)
continue
}
// We are ignoring Charts that are not under flux/helm-operator control
fhr, ok := customResources[ns][relName]
if !ok {
continue
}
rel, err := rs.release.GetDeployedRelease(relName)
if err != nil {
return err
}
doUpgrade, err := rs.shouldUpgrade(rel, fhr)
if err != nil {
return err
}
if doUpgrade {
chr := chartRelease{
releaseName: relName,
action: chartrelease.DeleteAction,
action: chartrelease.UpgradeAction,
desiredState: fhr,
}
chRels = append(chRels, chr)

} else {
rel, err := rs.release.GetDeployedRelease(relName)
if err != nil {
return err
}
doUpgrade, err := rs.shouldUpgrade(rel, fhr)
if err != nil {
return err
}
if doUpgrade {
chr := chartRelease{
releaseName: relName,
action: chartrelease.UpgradeAction,
desiredState: fhr,
}
chRels = append(chRels, chr)
}
}
}
if len(chRels) > 0 {
Expand Down Expand Up @@ -282,12 +270,6 @@ func (rs *ReleaseChangeSync) sync(ctx context.Context, releases map[string][]cha

relName := chr.releaseName
switch chr.action {
case chartrelease.DeleteAction:
rs.logger.Log("info", fmt.Sprintf("Deleting manually installed Chart release %s (namespace %s)", relName, ns))
err := rs.release.Delete(relName)
if err != nil {
return err
}
case chartrelease.UpgradeAction:
rs.logger.Log("info", fmt.Sprintf("Resyncing manually upgraded Chart release %s (namespace %s)", relName, ns))
_, err := rs.release.Install(checkout, relName, chr.desiredState, chartrelease.UpgradeAction, opts)
Expand Down

0 comments on commit 3765416

Please sign in to comment.