mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-23 22:46:53 +00:00
resolve comments
Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
This commit is contained in:
@@ -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` |
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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` |
|
||||
|
||||
@@ -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 }}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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},
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user