Browse Source

Fix looping on startup while installing addons

pull/22/head
Darren Shepherd 6 years ago
parent
commit
91002f1fee
  1. 16
      pkg/deploy/controller.go

16
pkg/deploy/controller.go

@ -32,6 +32,7 @@ import (
const ( const (
ns = "kube-system" ns = "kube-system"
startKey = "_start_"
) )
func WatchFiles(ctx context.Context, skips []string, bases ...string) error { func WatchFiles(ctx context.Context, skips []string, bases ...string) error {
@ -48,10 +49,16 @@ func WatchFiles(ctx context.Context, skips []string, bases ...string) error {
clients: map[schema.GroupVersionKind]*objectclient.ObjectClient{}, clients: map[schema.GroupVersionKind]*objectclient.ObjectClient{},
} }
addons.Enqueue("", "_start_") addons.Enqueue("", startKey)
addons.Interface().AddHandler(ctx, "addon-start", func(key string, _ *v1.Addon) (runtime.Object, error) { 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 w.started = true
return nil, w.listFiles(true) return nil, nil
}
return nil, nil
}) })
w.start(ctx) w.start(ctx)
@ -144,6 +151,7 @@ func (w *watcher) deploy(path string, compareChecksum bool) error {
checksum := checksum(content) checksum := checksum(content)
if compareChecksum && checksum == addon.Spec.Checksum { if compareChecksum && checksum == addon.Spec.Checksum {
logrus.Debugf("Skipping existing deployment of %s, check=%v, checksum %s=%s", path, compareChecksum, checksum, addon.Spec.Checksum)
return nil return nil
} }
@ -153,6 +161,10 @@ func (w *watcher) deploy(path string, compareChecksum bool) error {
} }
clients, err := w.apply(addon, objectSet) clients, err := w.apply(addon, objectSet)
if err != nil {
return err
}
if w.clients == nil { if w.clients == nil {
w.clients = map[schema.GroupVersionKind]*objectclient.ObjectClient{} w.clients = map[schema.GroupVersionKind]*objectclient.ObjectClient{}
} }

Loading…
Cancel
Save