Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/apis/workflow/v1alpha1/workflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,12 @@ type WorkflowSpec struct {
// ArtifactGC describes the strategy to use when deleting artifacts from completed or deleted workflows (applies to all output Artifacts
// unless Artifact.ArtifactGC is specified, which overrides this)
ArtifactGC *WorkflowLevelArtifactGC `json:"artifactGC,omitempty" protobuf:"bytes,43,opt,name=artifactGC"`

// DisableRetry prevents manual retry of this workflow once it has completed.
DisableRetry bool `json:"disableRetry,omitempty" protobuf:"varint,44,opt,name=disableRetry"`

// DisableResubmit prevents resubmission of this workflow once it has completed.
DisableResubmit bool `json:"disableResubmit,omitempty" protobuf:"varint,45,opt,name=disableResubmit"`
}

type LabelValueFrom struct {
Expand Down
8 changes: 8 additions & 0 deletions server/workflow/workflow_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,10 @@ func (s *workflowServer) RetryWorkflow(ctx context.Context, req *workflowpkg.Wor
return nil, sutils.ToStatusError(err, codes.InvalidArgument)
}

if wf.Spec.DisableRetry {
return nil, status.Errorf(codes.FailedPrecondition, "retry is disabled for workflow %s", wf.Name)
}

err = s.hydrator.Hydrate(ctx, wf)
if err != nil {
return nil, sutils.ToStatusError(err, codes.Internal)
Expand Down Expand Up @@ -543,6 +547,10 @@ func (s *workflowServer) ResubmitWorkflow(ctx context.Context, req *workflowpkg.
return nil, sutils.ToStatusError(err, codes.InvalidArgument)
}

if wf.Spec.DisableResubmit {
return nil, status.Errorf(codes.FailedPrecondition, "resubmit is disabled for workflow %s", wf.Name)
}

newWF, err := util.FormulateResubmitWorkflow(ctx, wf, req.Memoized, req.Parameters)
if err != nil {
return nil, sutils.ToStatusError(err, codes.Internal)
Expand Down
9 changes: 9 additions & 0 deletions server/workflowarchive/archived_workflow_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ func (w *archivedWorkflowServer) ResubmitArchivedWorkflow(ctx context.Context, r
return nil, sutils.ToStatusError(err, codes.Internal)
}

if wf.Spec.DisableResubmit {
return nil, status.Errorf(codes.FailedPrecondition, "resubmit is disabled for workflow %s", wf.Name)
}

newWF, err := util.FormulateResubmitWorkflow(ctx, wf, req.Memoized, req.Parameters)
if err != nil {
return nil, sutils.ToStatusError(err, codes.Internal)
Expand Down Expand Up @@ -245,6 +249,11 @@ func (w *archivedWorkflowServer) RetryArchivedWorkflow(ctx context.Context, req
if err != nil {
return nil, sutils.ToStatusError(err, codes.Internal)
}

if wf.Spec.DisableRetry {
return nil, status.Errorf(codes.FailedPrecondition, "retry is disabled for workflow %s", wf.Name)
}

oriUID := wf.UID

_, err = wfClient.ArgoprojV1alpha1().Workflows(req.Namespace).Get(ctx, wf.Name, metav1.GetOptions{})
Expand Down
10 changes: 10 additions & 0 deletions ui/src/shared/models/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,16 @@ export interface WorkflowSpec {
* workflowTemplateRef is the reference to the workflow template resource to execute.
*/
workflowTemplateRef?: WorkflowTemplateRef;

/**
* DisableRetry prevents manual retry of this workflow once it has completed.
*/
disableRetry?: boolean;

/**
* DisableResubmit prevents resubmission of this workflow once it has completed.
*/
disableResubmit?: boolean;
}

export interface WorkflowTemplateRef {
Expand Down
5 changes: 4 additions & 1 deletion ui/src/shared/workflow-operations-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export const WorkflowOperationsMap: WorkflowOperations = {
title: 'RETRY',
iconClassName: 'fa fa-undo',
disabled: (wf: Workflow) => {
if (wf?.spec?.disableRetry) {
return true;
}
const workflowPhase: NodePhase = wf && wf.status ? wf.status.phase : undefined;
return workflowPhase === undefined || !(workflowPhase === 'Failed' || workflowPhase === 'Error');
},
Expand All @@ -34,7 +37,7 @@ export const WorkflowOperationsMap: WorkflowOperations = {
RESUBMIT: {
title: 'RESUBMIT',
iconClassName: 'fa fa-plus-circle',
disabled: () => false,
disabled: (wf: Workflow) => wf?.spec?.disableResubmit === true,
action: (wf: Workflow) => services.workflows.resubmit(wf.metadata.name, wf.metadata.namespace, null)
},
SUSPEND: {
Expand Down
Loading