mirror of https://github.com/k3s-io/k3s
Fix looping on startup while installing addons
parent
5e1ce4aa42
commit
91002f1fee
|
@ -31,7 +31,8 @@ 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) {
|
||||||
w.started = true
|
if key == startKey {
|
||||||
return nil, w.listFiles(true)
|
if err := w.listFiles(true); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
w.started = 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…
Reference in New Issue