diff --git a/cmd/main.go b/cmd/main.go index cff1696a..c71edefd 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -111,6 +111,7 @@ func main() { flag.IntVar(&webhookPort, "webhook-port", 9443, "admission webhook listen address") flag.IntVar(&controllerArgs.ConcurrentReconciles, "concurrent-reconciles", 4, "concurrent-reconciles is the concurrent reconcile number of the controller. The default value is 4") flag.BoolVar(&controllerArgs.IgnoreWorkflowWithoutControllerRequirement, "ignore-workflow-without-controller-requirement", false, "If true, workflow controller will not process the workflowrun without 'workflowrun.oam.dev/controller-version-require' annotation") + flag.DurationVar(&controllerArgs.ReconcileTimeout, "reconcile-timeout", controllers.DefaultReconcileTimeout, "The timeout for workflowrun reconcile loop. Increase this value if your workflowrun has a large number of steps. Default is 3m.") flag.Float64Var(&qps, "kube-api-qps", 50, "the qps for reconcile clients. Low qps may lead to low throughput. High qps may give stress to api-server. Raise this value if concurrent-reconciles is set to be high.") flag.IntVar(&burst, "kube-api-burst", 100, "the burst for reconcile clients. Recommend setting it qps*2.") flag.StringVar(&userAgent, "user-agent", "vela-workflow", "the user agent of the client.") diff --git a/controllers/backup_controller.go b/controllers/backup_controller.go index abaaff8e..6f87a653 100644 --- a/controllers/backup_controller.go +++ b/controllers/backup_controller.go @@ -68,7 +68,11 @@ const ( // +kubebuilder:rbac:groups=core.oam.dev,resources=workflowruns/status,verbs=get;update;patch // +kubebuilder:rbac:groups=core.oam.dev,resources=workflowruns/finalizers,verbs=update func (r *BackupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - ctx, cancel := context.WithTimeout(ctx, ReconcileTimeout) + reconcileTimeout := r.Args.ReconcileTimeout + if reconcileTimeout <= 0 { + reconcileTimeout = DefaultReconcileTimeout + } + ctx, cancel := context.WithTimeout(ctx, reconcileTimeout) defer cancel() ctx = types.SetNamespaceInCtx(ctx, req.Namespace) diff --git a/controllers/workflowrun_controller.go b/controllers/workflowrun_controller.go index a53a5fd4..a3a74c61 100644 --- a/controllers/workflowrun_controller.go +++ b/controllers/workflowrun_controller.go @@ -58,6 +58,8 @@ type Args struct { ConcurrentReconciles int // IgnoreWorkflowWithoutControllerRequirement indicates that workflow controller will not process the workflowrun without 'workflowrun.oam.dev/controller-version-require' annotation. IgnoreWorkflowWithoutControllerRequirement bool + // ReconcileTimeout is the timeout for the reconcile loop. Default is 3 minutes. + ReconcileTimeout time.Duration } // WorkflowRunReconciler reconciles a WorkflowRun object @@ -74,9 +76,9 @@ type workflowRunPatcher struct { run *v1alpha1.WorkflowRun } -var ( - // ReconcileTimeout timeout for controller to reconcile - ReconcileTimeout = time.Minute * 3 +const ( + // DefaultReconcileTimeout is the default timeout for controller to reconcile + DefaultReconcileTimeout = time.Minute * 3 ) // Reconcile reconciles the WorkflowRun object @@ -84,7 +86,11 @@ var ( // +kubebuilder:rbac:groups=core.oam.dev,resources=workflowruns/status,verbs=get;update;patch // +kubebuilder:rbac:groups=core.oam.dev,resources=workflowruns/finalizers,verbs=update func (r *WorkflowRunReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { - ctx, cancel := context.WithTimeout(ctx, ReconcileTimeout) + reconcileTimeout := r.Args.ReconcileTimeout + if reconcileTimeout <= 0 { + reconcileTimeout = DefaultReconcileTimeout + } + ctx, cancel := context.WithTimeout(ctx, reconcileTimeout) defer cancel() ctx = types.SetNamespaceInCtx(ctx, req.Namespace)