From a7ecfc085cebd67366aeda62952015789d83198b Mon Sep 17 00:00:00 2001 From: Yuan Tang Date: Fri, 26 Feb 2021 15:30:50 -0500 Subject: [PATCH] feat(controller): Allow to modify time related configurations in leader election (#5234) Signed-off-by: terrytangyuan --- docs/environment-variables.md | 3 +++ workflow/controller/controller.go | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/environment-variables.md b/docs/environment-variables.md index 70b12655fc2e..9ff818c0da19 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -15,6 +15,9 @@ Note that these environment variables may be removed at any time. | `DEFAULT_REQUEUE_TIME` | `time.Duration` | The requeue time for the rate limiter of the workflow queue. | | `GZIP_IMPLEMENTATION` | `string` | The implementation of compression/decompression. Currently only "PGZip" and "GZip" are supported. Defaults to "PGZip". | | `LEADER_ELECTION_IDENTITY` | `string` | The ID used for workflow controllers to elect a leader. | +| `LEADER_ELECTION_LEASE_DURATION` | `time.Duration` | The duration that non-leader candidates will wait to force acquire leadership. | +| `LEADER_ELECTION_RENEW_DEADLINE` | `time.Duration` | The duration that the acting master will retry refreshing leadership before giving up. | +| `LEADER_ELECTION_RETRY_PERIOD` | `time.Duration` | The duration that the leader election clients should wait between tries of actions. | | `MAX_OPERATION_TIME` | `time.Duration` | The maximum time a workflow operation is allowed to run for before requeuing the workflow onto the work queue. | | `OFFLOAD_NODE_STATUS_TTL` | `time.Duration` | The TTL to delete the offloaded node status. Currently only used for testing. | | `RECENTLY_STARTED_POD_DURATION` | `time.Duration` | The duration of a pod before the pod is considered to be recently started. | diff --git a/workflow/controller/controller.go b/workflow/controller/controller.go index 63f872495940..971ccc3ce3ab 100644 --- a/workflow/controller/controller.go +++ b/workflow/controller/controller.go @@ -229,9 +229,9 @@ func (wfc *WorkflowController) Run(ctx context.Context, wfWorkers, workflowTTLWo LockConfig: resourcelock.ResourceLockConfig{Identity: nodeID, EventRecorder: wfc.eventRecorderManager.Get(wfc.namespace)}, }, ReleaseOnCancel: true, - LeaseDuration: 15 * time.Second, - RenewDeadline: 10 * time.Second, - RetryPeriod: 5 * time.Second, + LeaseDuration: env.LookupEnvDurationOr("LEADER_ELECTION_LEASE_DURATION", 15*time.Second), + RenewDeadline: env.LookupEnvDurationOr("LEADER_ELECTION_RENEW_DEADLINE", 10*time.Second), + RetryPeriod: env.LookupEnvDurationOr("LEADER_ELECTION_RETRY_PERIOD", 5*time.Second), Callbacks: leaderelection.LeaderCallbacks{ OnStartedLeading: func(ctx context.Context) { logCtx.Info("started leading")