From 769c1d54152041b29ea2cc5ac81c6cdfde2ca625 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 7 Mar 2019 11:24:18 -0700 Subject: [PATCH 1/2] Fix manifest polling --- pkg/deploy/controller.go | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/pkg/deploy/controller.go b/pkg/deploy/controller.go index 8279b9b84e..f9f3161701 100644 --- a/pkg/deploy/controller.go +++ b/pkg/deploy/controller.go @@ -52,21 +52,15 @@ func WatchFiles(ctx context.Context, skips []string, bases ...string) error { addons.Enqueue("", startKey) addons.Interface().AddHandler(ctx, "addon-start", func(key string, _ *v1.Addon) (runtime.Object, error) { if key == startKey { - if err := w.listFiles(true); err != nil { - return nil, err - } - w.started = true - return nil, nil + go w.start(ctx) } return nil, nil }) - w.start(ctx) return nil } type watcher struct { - started bool addonCache v1.AddonClientCache addons v1.AddonClient bases []string @@ -77,14 +71,17 @@ type watcher struct { } func (w *watcher) start(ctx context.Context) { + force := true for { + if err := w.listFiles(force); err == nil { + force = false + } else { + logrus.Errorf("failed to process config: %v", err) + } select { case <-ctx.Done(): return case <-time.After(15 * time.Second): - if err := w.listFiles(false); err != nil { - logrus.Errorf("failed to process config: %v", err) - } } } } @@ -101,10 +98,6 @@ func (w *watcher) listFiles(force bool) error { } func (w *watcher) listFilesIn(base string, force bool) error { - if !w.started { - return nil - } - files, err := ioutil.ReadDir(base) if os.IsNotExist(err) { return nil From a64998322824cd6dc00795ee893a4b3913658354 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 7 Mar 2019 11:26:46 -0700 Subject: [PATCH 2/2] Any change to helm chart values or values.yaml should upgrade --- pkg/helm/controller.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/helm/controller.go b/pkg/helm/controller.go index ca86f1e5a8..e396d8be97 100644 --- a/pkg/helm/controller.go +++ b/pkg/helm/controller.go @@ -2,6 +2,8 @@ package helm import ( "context" + "crypto/sha256" + "encoding/hex" "fmt" "sort" @@ -22,7 +24,7 @@ import ( const ( namespace = "kube-system" - image = "rancher/klipper-helm:v0.1.2" + image = "rancher/klipper-helm:v0.1.3" label = "helm.k3s.cattle.io/chart" ) @@ -124,6 +126,7 @@ func (h *handler) onRemove(chart *k3s.HelmChart) (runtime.Object, error) { func job(chart *k3s.HelmChart) (*batch.Job, *core.ConfigMap) { oneThousand := int32(1000) + valuesHash := sha256.Sum256([]byte(chart.Spec.ValuesContent)) action := "install" if chart.DeletionTimestamp != nil { @@ -170,6 +173,10 @@ func job(chart *k3s.HelmChart) (*batch.Job, *core.ConfigMap) { Name: "REPO", Value: chart.Spec.Repo, }, + { + Name: "VALUES_HASH", + Value: hex.EncodeToString(valuesHash[:]), + }, }, }, },