Skip to content

Commit

Permalink
Merge pull request volcano-sh#2927 from rfyiamcool/fix/leaderelection…
Browse files Browse the repository at this point in the history
…_signal_ctx

fix: set leaderelection's ctx that can sense signal in controller
  • Loading branch information
volcano-sh-bot authored Aug 8, 2023
2 parents d57f9f3 + 2477fd3 commit 04a3b1b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/controller-manager/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"volcano.sh/volcano/cmd/controller-manager/app/options"
"volcano.sh/volcano/pkg/controllers/framework"
"volcano.sh/volcano/pkg/kube"
"volcano.sh/volcano/pkg/signals"
)

const (
Expand All @@ -62,8 +63,10 @@ func Run(opt *options.ServerOption) error {

run := startControllers(config, opt)

ctx := signals.SetupSignalContext()

if !opt.EnableLeaderElection {
run(context.TODO())
run(ctx)
return fmt.Errorf("finished without leader elect")
}

Expand Down Expand Up @@ -97,7 +100,7 @@ func Run(opt *options.ServerOption) error {
return fmt.Errorf("couldn't create resource lock: %v", err)
}

leaderelection.RunOrDie(context.TODO(), leaderelection.LeaderElectionConfig{
leaderelection.RunOrDie(ctx, leaderelection.LeaderElectionConfig{
Lock: rl,
LeaseDuration: leaseDuration,
RenewDeadline: renewDeadline,
Expand Down

0 comments on commit 04a3b1b

Please sign in to comment.