Skip to content

Commit

Permalink
MOD:add a new config in manager.Mew to set on stopped leading function
Browse files Browse the repository at this point in the history
  • Loading branch information
光南 committed Jun 25, 2024
1 parent 162a113 commit 4a3c3f3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"k8s.io/client-go/tools/leaderelection/resourcelock"
"k8s.io/client-go/tools/record"
"k8s.io/utils/ptr"

metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

"sigs.k8s.io/controller-runtime/pkg/cache"
Expand Down Expand Up @@ -201,6 +202,10 @@ type Options struct {
// LeaseDuration time first.
LeaderElectionReleaseOnCancel bool

// OnStoppedLeading is callled when the leader election lease is lost.
// It can be overridden for tests.
OnStoppedLeading func()

// LeaderElectionResourceLockInterface allows to provide a custom resourcelock.Interface that was created outside
// of the controller-runtime. If this value is set the options LeaderElectionID, LeaderElectionNamespace,
// LeaderElectionResourceLock, LeaseDuration, RenewDeadline and RetryPeriod will be ignored. This can be useful if you
Expand Down Expand Up @@ -441,6 +446,7 @@ func New(config *rest.Config, options Options) (Manager, error) {
internalProceduresStop: make(chan struct{}),
leaderElectionStopped: make(chan struct{}),
leaderElectionReleaseOnCancel: options.LeaderElectionReleaseOnCancel,
onStoppedLeading: options.OnStoppedLeading,
}, nil
}

Expand Down

0 comments on commit 4a3c3f3

Please sign in to comment.