mirror of https://github.com/k3s-io/k3s
Fix issue with k3s-etcd informers not starting
Start shared informer caches when k3s-etcd controller wins leader election. Previously, these were only started when the main k3s apiserver controller won an election. If the leaders ended up going to different nodes, some informers wouldn't be started
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 3d14092f76
)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
pull/10288/head
parent
6f4fd6d9c3
commit
2b63eb4a27
|
@ -91,7 +91,9 @@ func (c *Cluster) start(ctx context.Context) error {
|
|||
return c.managedDB.Start(ctx, c.clientAccessInfo)
|
||||
}
|
||||
|
||||
// registerDBHandlers registers routes for database info with the http request handler
|
||||
// registerDBHandlers registers managed-datastore-specific callbacks, and installs additional HTTP route handlers.
|
||||
// Note that for etcd, controllers only run on nodes with a local apiserver, in order to provide stable external
|
||||
// management of etcd cluster membership without being disrupted when a member is removed from the cluster.
|
||||
func (c *Cluster) registerDBHandlers(handler http.Handler) (http.Handler, error) {
|
||||
if c.managedDB == nil {
|
||||
return handler, nil
|
||||
|
|
|
@ -34,6 +34,7 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
certutil "github.com/rancher/dynamiclistener/cert"
|
||||
controllerv1 "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
|
||||
"github.com/rancher/wrangler/pkg/start"
|
||||
"github.com/robfig/cron/v3"
|
||||
"github.com/sirupsen/logrus"
|
||||
"go.etcd.io/etcd/api/v3/etcdserverpb"
|
||||
|
@ -619,6 +620,12 @@ func (e *ETCD) Register(handler http.Handler) (http.Handler, error) {
|
|||
registerEndpointsHandlers(ctx, e)
|
||||
registerMemberHandlers(ctx, e)
|
||||
registerSnapshotHandlers(ctx, e)
|
||||
|
||||
// Re-run informer factory startup after core and leader-elected controllers have started.
|
||||
// Additional caches may need to start for the newly added OnChange/OnRemove callbacks.
|
||||
if err := start.All(ctx, 5, e.config.Runtime.K3s, e.config.Runtime.Core); err != nil {
|
||||
panic(errors.Wrap(err, "failed to start wrangler controllers"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,8 +167,8 @@ func apiserverControllers(ctx context.Context, sc *Context, config *Config) {
|
|||
}
|
||||
}
|
||||
|
||||
// Re-run context startup after core and leader-elected controllers have started. Additional
|
||||
// informer caches may need to start for the newly added OnChange callbacks.
|
||||
// Re-run informer factory startup after core and leader-elected controllers have started.
|
||||
// Additional caches may need to start for the newly added OnChange/OnRemove callbacks.
|
||||
if err := sc.Start(ctx); err != nil {
|
||||
panic(errors.Wrap(err, "failed to start wranger controllers"))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue