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

Commit

Permalink
#562. chart is upgraded to out-of-sync. sync before upgrading
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-handda committed Dec 3, 2020
1 parent 90f4946 commit 4bf2c6f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/helm-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func main() {
// _before_ starting it or else the cache sync seems to hang at
// random
opr := operator.New(log.With(logger, "component", "operator"),
*logReleaseDiffs, kubeClient, hrInformer, queue, rel)
*logReleaseDiffs, kubeClient, hrInformer, queue, rel, gitChartSync)
go ifInformerFactory.Start(shutdown)

// wait for the caches to be synced before starting _any_ workers
Expand Down
10 changes: 9 additions & 1 deletion pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package operator

import (
"fmt"
"github.com/fluxcd/helm-operator/pkg/api"
"os"
"path"
"sync"
Expand Down Expand Up @@ -44,6 +45,7 @@ type Controller struct {
hrSynced cache.InformerSynced

release *release.Release
apiServer api.Server

// workqueue is a rate limited work queue. This is used to queue work to be
// processed instead of performing it as soon as a change happens. This
Expand All @@ -64,7 +66,8 @@ func New(
kubeclientset kubernetes.Interface,
hrInformer hrv1.HelmReleaseInformer,
releaseWorkqueue workqueue.RateLimitingInterface,
release *release.Release) *Controller {
release *release.Release,
apiServer api.Server) *Controller {

// Add helm-operator types to the default Kubernetes Scheme so Events can be
// logged for helm-operator types.
Expand All @@ -81,6 +84,7 @@ func New(
releaseWorkqueue: releaseWorkqueue,
recorder: recorder,
release: release,
apiServer: apiServer,
}

controller.logger.Log("info", "setting up event handlers")
Expand Down Expand Up @@ -275,6 +279,10 @@ func (c *Controller) enqueueUpdateJob(old, new interface{}) {
return
}

if csDiff := cmp.Diff(oldHr.Spec.ChartSource,newHr.Spec.ChartSource); csDiff != "" {
c.apiServer.SyncMirrors()
}

c.enqueueJob(new)
}

Expand Down

0 comments on commit 4bf2c6f

Please sign in to comment.