Don't run leader elections on controllers when no leader election

This commit is contained in:
Darren Shepherd 2019-08-26 21:56:01 -07:00
parent f0382329a5
commit 8f597ba168

View File

@ -110,14 +110,24 @@ func startWrangler(ctx context.Context, config *Config) (string, error) {
return "", err return "", err
} }
go leader.RunOrDie(ctx, "", "k3s", sc.K8s, func(ctx context.Context) { start := func(ctx context.Context) {
if err := masterControllers(ctx, sc, config); err != nil { if err := masterControllers(ctx, sc, config); err != nil {
panic(err) panic(err)
} }
if err := sc.Start(ctx); err != nil { if err := sc.Start(ctx); err != nil {
panic(err) panic(err)
} }
}) }
if controlConfig.NoLeaderElect {
go func() {
start(ctx)
<-ctx.Done()
logrus.Fatal("controllers exited")
}()
} else {
go leader.RunOrDie(ctx, "", "k3s", sc.K8s, start)
}
return certs, nil return certs, nil
} }