Trigger a Helm upgrade only when FHR values changed
- fix unwanted upgrades on K8s 1.11
@@ -324,9 +324,7 @@ func (c *Controller) enqueueUpateJob(old, new interface{}) {
return
}
- oldResVer := oldFhr.ResourceVersion
- newResVer := newFhr.ResourceVersion
- if newResVer != oldResVer {
+ if needsUpdate(oldFhr, newFhr) {
c.logger.Log("info", "UPGRADING release")
c.logger.Log("info", "Custom Resource driven release upgrade")
c.enqueueJob(new)
@@ -343,3 +341,31 @@ func (c *Controller) deleteRelease(fhr ifv1.FluxHelmRelease) {
}
return
}
+
+// needsUpdate compares two FluxHelmRelease and determines if any changes occurred
+func needsUpdate(old, new ifv1.FluxHelmRelease) bool {
+
+ oldValues, err := old.Spec.Values.YAML()
+ if err != nil {
+ return false
+ }
+
+ newValues, err := new.Spec.Values.YAML()
+ if err != nil {
+ return false
+ }
+
+ if oldValues != newValues {
+ return true
+ }
+
+ if old.Spec.ReleaseName != new.Spec.ReleaseName {
+ return true
+ }
+
+ if old.Spec.ChartGitPath != new.Spec.ChartGitPath {
+ return true
+ }
+
+ return false
+}
