Upgrade csi-lib-utils to 0.8.1

This commit is contained in:
Jiawei Wang
2020-10-01 17:31:31 -07:00
parent 9b5b601d9b
commit fa12fa91db
21 changed files with 582 additions and 239 deletions

View File

@@ -60,6 +60,8 @@ type leaderElection struct {
renewDeadline time.Duration
retryPeriod time.Duration
ctx context.Context
clientset kubernetes.Interface
}
@@ -127,6 +129,11 @@ func (l *leaderElection) WithRetryPeriod(retryPeriod time.Duration) {
l.retryPeriod = retryPeriod
}
// WithContext Add context
func (l *leaderElection) WithContext(ctx context.Context) {
l.ctx = ctx
}
func (l *leaderElection) Run() error {
if l.identity == "" {
id, err := defaultLeaderElectionIdentity()
@@ -174,7 +181,11 @@ func (l *leaderElection) Run() error {
},
}
leaderelection.RunOrDie(context.TODO(), leaderConfig)
ctx := l.ctx
if ctx == nil {
ctx = context.Background()
}
leaderelection.RunOrDie(ctx, leaderConfig)
return nil // should never reach here
}