diff --git a/charts/vela-core/README.md b/charts/vela-core/README.md index c544a477f..ea8b718b5 100644 --- a/charts/vela-core/README.md +++ b/charts/vela-core/README.md @@ -55,7 +55,7 @@ helm install --create-namespace -n vela-system kubevela kubevela/vela-core --wai | Name | Description | Value | | -------------------------------------- | ------------------------------------------------------ | ------- | -| `workflow.enableSuspendFailedWorkflow` | Enable suspend failed workflow | `false` | +| `workflow.enableSuspendOnFailure` | Enable suspend on workflow failure | `false` | | `workflow.backoff.maxTime.waitState` | The max backoff time of workflow in a wait condition | `60` | | `workflow.backoff.maxTime.failedState` | The max backoff time of workflow in a failed condition | `300` | | `workflow.step.errorRetryTimes` | The max retry times of a failed workflow step | `10` | diff --git a/charts/vela-core/templates/kubevela-controller.yaml b/charts/vela-core/templates/kubevela-controller.yaml index bcd4b0d48..808b68269 100644 --- a/charts/vela-core/templates/kubevela-controller.yaml +++ b/charts/vela-core/templates/kubevela-controller.yaml @@ -172,7 +172,7 @@ spec: - "--max-workflow-wait-backoff-time={{ .Values.workflow.backoff.maxTime.waitState }}" - "--max-workflow-failed-backoff-time={{ .Values.workflow.backoff.maxTime.failedState }}" - "--max-workflow-step-error-retry-times={{ .Values.workflow.step.errorRetryTimes }}" - - "--feature-gates=EnableSuspendFailedWorkflow={{- .Values.workflow.enableSuspendFailedWorkflow | toString -}}" + - "--feature-gates=EnableSuspendOnFailure={{- .Values.workflow.enableSuspendOnFailure | toString -}}" - "--feature-gates=AuthenticateApplication={{- .Values.authentication.enabled | toString -}}" {{ if .Values.authentication.enabled }} {{ if .Values.authentication.withUser }} diff --git a/charts/vela-core/values.yaml b/charts/vela-core/values.yaml index 9b5706c37..7b99cd49f 100644 --- a/charts/vela-core/values.yaml +++ b/charts/vela-core/values.yaml @@ -35,12 +35,12 @@ dependCheckWait: 30s ## @section KubeVela workflow parameters -## @param workflow.enableSuspendFailedWorkflow Enable suspend failed workflow +## @param workflow.enableSuspendOnFailure Enable suspend on workflow failure ## @param workflow.backoff.maxTime.waitState The max backoff time of workflow in a wait condition ## @param workflow.backoff.maxTime.failedState The max backoff time of workflow in a failed condition ## @param workflow.step.errorRetryTimes The max retry times of a failed workflow step workflow: - enableSuspendFailedWorkflow: false + enableSuspendOnFailure: false backoff: maxTime: waitState: 60 diff --git a/charts/vela-minimal/README.md b/charts/vela-minimal/README.md index 6d250ee6f..d8e72d3fb 100644 --- a/charts/vela-minimal/README.md +++ b/charts/vela-minimal/README.md @@ -74,7 +74,7 @@ helm install --create-namespace -n vela-system kubevela kubevela/vela-minimal -- | Name | Description | Value | | -------------------------------------- | ------------------------------------------------------ | ------- | -| `workflow.enableSuspendFailedWorkflow` | Enable suspend failed workflow | `false` | +| `workflow.enableSuspendOnFailure` | Enable suspend on workflow failure | `false` | | `workflow.backoff.maxTime.waitState` | The max backoff time of workflow in a wait condition | `60` | | `workflow.backoff.maxTime.failedState` | The max backoff time of workflow in a failed condition | `300` | | `workflow.step.errorRetryTimes` | The max retry times of a failed workflow step | `10` | diff --git a/charts/vela-minimal/templates/kubevela-controller.yaml b/charts/vela-minimal/templates/kubevela-controller.yaml index 4a59d63da..6b6237682 100644 --- a/charts/vela-minimal/templates/kubevela-controller.yaml +++ b/charts/vela-minimal/templates/kubevela-controller.yaml @@ -142,7 +142,7 @@ spec: - "--max-workflow-wait-backoff-time={{ .Values.workflow.backoff.maxTime.waitState }}" - "--max-workflow-failed-backoff-time={{ .Values.workflow.backoff.maxTime.failedState }}" - "--max-workflow-step-error-retry-times={{ .Values.workflow.step.errorRetryTimes }}" - - "--feature-gates=EnableSuspendFailedWorkflow={{- .Values.workflow.enableSuspendFailedWorkflow | toString -}}" + - "--feature-gates=EnableSuspendOnFailure={{- .Values.workflow.enableSuspendOnFailure | toString -}}" - "--feature-gates=AuthenticateApplication={{- .Values.authentication.enabled | toString -}}" {{ if .Values.authentication.enabled }} {{ if .Values.authentication.withUser }} diff --git a/charts/vela-minimal/values.yaml b/charts/vela-minimal/values.yaml index bca8c7adb..448bf49a3 100644 --- a/charts/vela-minimal/values.yaml +++ b/charts/vela-minimal/values.yaml @@ -38,12 +38,12 @@ dependCheckWait: 30s ## @section KubeVela workflow parameters -## @param workflow.enableSuspendFailedWorkflow Enable suspend failed workflow +## @param workflow.enableSuspendOnFailure Enable suspend on workflow failure ## @param workflow.backoff.maxTime.waitState The max backoff time of workflow in a wait condition ## @param workflow.backoff.maxTime.failedState The max backoff time of workflow in a failed condition ## @param workflow.step.errorRetryTimes The max retry times of a failed workflow step workflow: - enableSuspendFailedWorkflow: false + enableSuspendOnFailure: false backoff: maxTime: waitState: 60 diff --git a/pkg/apiserver/domain/service/workflow.go b/pkg/apiserver/domain/service/workflow.go index 944e7f3ab..7bde20b69 100644 --- a/pkg/apiserver/domain/service/workflow.go +++ b/pkg/apiserver/domain/service/workflow.go @@ -578,7 +578,7 @@ func (w *workflowServiceImpl) TerminateRecord(ctx context.Context, appModel *mod return err } - if err := TerminateWorkflow(w.KubeClient, oamApp); err != nil { + if err := TerminateWorkflow(ctx, w.KubeClient, oamApp); err != nil { return err } if err := w.syncWorkflowStatus(ctx, oamApp, recordName, oamApp.Name); err != nil { @@ -589,7 +589,7 @@ func (w *workflowServiceImpl) TerminateRecord(ctx context.Context, appModel *mod } // TerminateWorkflow terminate workflow -func TerminateWorkflow(kubecli client.Client, app *v1beta1.Application) error { +func TerminateWorkflow(ctx context.Context, kubecli client.Client, app *v1beta1.Application) error { // set the workflow terminated to true app.Status.Workflow.Terminated = true steps := app.Status.Workflow.Steps @@ -618,7 +618,7 @@ func TerminateWorkflow(kubecli client.Client, app *v1beta1.Application) error { } } - if err := kubecli.Status().Patch(context.TODO(), app, client.Merge); err != nil { + if err := kubecli.Status().Patch(ctx, app, client.Merge); err != nil { return err } return nil diff --git a/pkg/controller/core.oam.dev/v1alpha2/application/application_controller.go b/pkg/controller/core.oam.dev/v1alpha2/application/application_controller.go index 0570be52a..08773b92f 100644 --- a/pkg/controller/core.oam.dev/v1alpha2/application/application_controller.go +++ b/pkg/controller/core.oam.dev/v1alpha2/application/application_controller.go @@ -231,7 +231,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu handler.app.Status.Workflow.SuspendState = "" return r.gcResourceTrackers(logCtx, handler, common.ApplicationRunningWorkflow, false, false) } - if !workflow.IsFailedAfterRetry(app) || !feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendFailedWorkflow) { + if !workflow.IsFailedAfterRetry(app) || !feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure) { r.stateKeep(logCtx, handler, app) } return r.gcResourceTrackers(logCtx, handler, common.ApplicationWorkflowSuspending, false, true) diff --git a/pkg/controller/core.oam.dev/v1alpha2/application/application_controller_test.go b/pkg/controller/core.oam.dev/v1alpha2/application/application_controller_test.go index e7a5490db..fe36addfb 100644 --- a/pkg/controller/core.oam.dev/v1alpha2/application/application_controller_test.go +++ b/pkg/controller/core.oam.dev/v1alpha2/application/application_controller_test.go @@ -1868,7 +1868,7 @@ var _ = Describe("Test Application Controller", func() { }) It("application with dag workflow failed after retries", func() { - defer featuregatetesting.SetFeatureGateDuringTest(&testing.T{}, utilfeature.DefaultFeatureGate, features.EnableSuspendFailedWorkflow, true)() + defer featuregatetesting.SetFeatureGateDuringTest(&testing.T{}, utilfeature.DefaultFeatureGate, features.EnableSuspendOnFailure, true)() ns := corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: "dag-failed-after-retries", @@ -1977,7 +1977,7 @@ var _ = Describe("Test Application Controller", func() { }) It("application with step by step workflow failed after retries", func() { - defer featuregatetesting.SetFeatureGateDuringTest(&testing.T{}, utilfeature.DefaultFeatureGate, features.EnableSuspendFailedWorkflow, true)() + defer featuregatetesting.SetFeatureGateDuringTest(&testing.T{}, utilfeature.DefaultFeatureGate, features.EnableSuspendOnFailure, true)() ns := corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: "step-by-step-failed-after-retries", diff --git a/pkg/features/controller_features.go b/pkg/features/controller_features.go index 5460dbda8..6a0620722 100644 --- a/pkg/features/controller_features.go +++ b/pkg/features/controller_features.go @@ -33,8 +33,8 @@ const ( DeprecatedObjectLabelSelector featuregate.Feature = "DeprecatedObjectLabelSelector" // LegacyResourceTrackerGC enable the gc of legacy resource tracker in managed clusters LegacyResourceTrackerGC featuregate.Feature = "LegacyResourceTrackerGC" - // EnableSuspendFailedWorkflow enable suspend failed workflow - EnableSuspendFailedWorkflow featuregate.Feature = "EnableSuspendFailedWorkflow" + // EnableSuspendOnFailure enable suspend on workflow failure + EnableSuspendOnFailure featuregate.Feature = "EnableSuspendOnFailure" // Edge Features @@ -47,7 +47,7 @@ var defaultFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{ LegacyObjectTypeIdentifier: {Default: false, PreRelease: featuregate.Alpha}, DeprecatedObjectLabelSelector: {Default: false, PreRelease: featuregate.Alpha}, LegacyResourceTrackerGC: {Default: true, PreRelease: featuregate.Alpha}, - EnableSuspendFailedWorkflow: {Default: false, PreRelease: featuregate.Alpha}, + EnableSuspendOnFailure: {Default: false, PreRelease: featuregate.Alpha}, AuthenticateApplication: {Default: false, PreRelease: featuregate.Alpha}, } diff --git a/pkg/workflow/tasks/custom/task.go b/pkg/workflow/tasks/custom/task.go index 7c4151914..e6a624676 100644 --- a/pkg/workflow/tasks/custom/task.go +++ b/pkg/workflow/tasks/custom/task.go @@ -157,7 +157,7 @@ func (t *TaskLoader) makeTaskGenerator(templ string) (wfTypes.TaskGenerator, err return CheckPending(ctx, wfStep, stepStatus) } tRunner.skip = func(dependsOnPhase common.WorkflowStepPhase, stepStatus map[string]common.StepStatus) (common.StepStatus, bool) { - if feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendFailedWorkflow) { + if feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure) { return exec.status(), false } skip := SkipTaskRunner(&SkipOptions{ @@ -506,7 +506,7 @@ func CheckPending(ctx wfContext.Context, step v1beta1.WorkflowStep, stepStatus m // IsStepFinish will decide whether step is finish. func IsStepFinish(phase common.WorkflowStepPhase, reason string) bool { - if feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendFailedWorkflow) { + if feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure) { return phase == common.WorkflowStepPhaseSucceeded } if phase == common.WorkflowStepPhaseFailed { diff --git a/pkg/workflow/tasks/discover.go b/pkg/workflow/tasks/discover.go index 38efb6743..978b30bcf 100644 --- a/pkg/workflow/tasks/discover.go +++ b/pkg/workflow/tasks/discover.go @@ -162,7 +162,7 @@ func (tr *suspendTaskRunner) Skip(dependsOnPhase common.WorkflowStepPhase, stepS Type: types.WorkflowStepTypeSuspend, Phase: tr.phase, } - if feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendFailedWorkflow) { + if feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure) { return status, false } skip := custom.SkipTaskRunner(&custom.SkipOptions{ @@ -199,7 +199,7 @@ func (tr *stepGroupTaskRunner) Skip(dependsOnPhase common.WorkflowStepPhase, ste Name: tr.step.Name, Type: types.WorkflowStepTypeStepGroup, } - if feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendFailedWorkflow) { + if feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure) { return status, false } skip := custom.SkipTaskRunner(&custom.SkipOptions{ diff --git a/pkg/workflow/workflow.go b/pkg/workflow/workflow.go index 6482dc7d8..fc3a5826f 100644 --- a/pkg/workflow/workflow.go +++ b/pkg/workflow/workflow.go @@ -540,9 +540,9 @@ func (e *engine) Run(taskRunners []wfTypes.TaskRunner, dag bool) error { func (e *engine) checkWorkflowStatusMessage(wfStatus *common.WorkflowStatus) { switch { - case !e.waiting && e.failedAfterRetries && feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendFailedWorkflow): + case !e.waiting && e.failedAfterRetries && feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure): e.status.Message = MessageSuspendFailedAfterRetries - case e.failedAfterRetries && !feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendFailedWorkflow): + case e.failedAfterRetries && !feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure): e.status.Message = MessageTerminatedFailedAfterRetries case wfStatus.Terminated: e.status.Message = string(common.WorkflowStateTerminated) @@ -695,16 +695,16 @@ func (e *engine) updateStepStatus(status common.StepStatus) { } func (e *engine) checkFailedAfterRetries() { - if !e.waiting && e.failedAfterRetries && feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendFailedWorkflow) { + if !e.waiting && e.failedAfterRetries && feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure) { e.status.Suspend = true } - if e.failedAfterRetries && !feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendFailedWorkflow) { + if e.failedAfterRetries && !feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure) { e.status.Terminated = true } } func (e *engine) needStop() bool { - if feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendFailedWorkflow) { + if feature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure) { e.checkFailedAfterRetries() } // if the workflow is terminated, we still need to execute all the remaining steps diff --git a/pkg/workflow/workflow_test.go b/pkg/workflow/workflow_test.go index 21f40c940..af5a2e50e 100644 --- a/pkg/workflow/workflow_test.go +++ b/pkg/workflow/workflow_test.go @@ -523,7 +523,7 @@ var _ = Describe("Test Workflow", func() { It("Workflow test for failed after retries with suspend", func() { By("Test failed-after-retries in StepByStep mode with suspend") - defer featuregatetesting.SetFeatureGateDuringTest(&testing.T{}, utilfeature.DefaultFeatureGate, features.EnableSuspendFailedWorkflow, true)() + defer featuregatetesting.SetFeatureGateDuringTest(&testing.T{}, utilfeature.DefaultFeatureGate, features.EnableSuspendOnFailure, true)() app, runners := makeTestCase([]oamcore.WorkflowStep{ { Name: "s1", @@ -804,7 +804,7 @@ var _ = Describe("Test Workflow", func() { It("Test failed after retries with sub steps", func() { By("Test failed-after-retries with step group in StepByStep mode") - defer featuregatetesting.SetFeatureGateDuringTest(&testing.T{}, utilfeature.DefaultFeatureGate, features.EnableSuspendFailedWorkflow, true)() + defer featuregatetesting.SetFeatureGateDuringTest(&testing.T{}, utilfeature.DefaultFeatureGate, features.EnableSuspendOnFailure, true)() app, runners := makeTestCase([]oamcore.WorkflowStep{ { Name: "s1", @@ -1399,7 +1399,7 @@ func makeRunner(name, tpy, ifDecl string, dependsOn []string, subTaskRunners []w Name: name, Type: tpy, } - if utilfeature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendFailedWorkflow) { + if utilfeature.DefaultMutableFeatureGate.Enabled(features.EnableSuspendOnFailure) { return status, false } skip := custom.SkipTaskRunner(&custom.SkipOptions{ diff --git a/references/cli/workflow.go b/references/cli/workflow.go index aca0b9021..0bdafaa99 100644 --- a/references/cli/workflow.go +++ b/references/cli/workflow.go @@ -289,7 +289,7 @@ func resumeWorkflow(kubecli client.Client, app *v1beta1.Application) error { // TerminateWorkflow terminate workflow func TerminateWorkflow(kubecli client.Client, app *v1beta1.Application) error { - if err := service.TerminateWorkflow(kubecli, app); err != nil { + if err := service.TerminateWorkflow(context.TODO(), kubecli, app); err != nil { return err }