Skip to content

Commit

Permalink
feat: Append previous workflow name as label to resubmitted workflow (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
terrytangyuan committed Jun 20, 2020
1 parent 2dae724 commit 55e1370
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions workflow/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ const (
LabelKeyWorkflow = workflow.WorkflowFullName + "/workflow"
// LabelKeyPhase is a label applied to workflows to indicate the current phase of the workflow (for filtering purposes)
LabelKeyPhase = workflow.WorkflowFullName + "/phase"
// LabelKeyPreviousWorkflowName is a label applied to resubmitted workflows
LabelKeyPreviousWorkflowName = workflow.WorkflowFullName + "/resubmitted-from-workflow"
// LabelKeyCronWorkflow is a label applied to Workflows that are started by a CronWorkflow
LabelKeyCronWorkflow = workflow.WorkflowFullName + "/cron-workflow"
// LabelKeyWorkflowTemplate is a label applied to Workflows that are submitted from Workflowtemplate
Expand Down
9 changes: 6 additions & 3 deletions workflow/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,18 @@ func FormulateResubmitWorkflow(wf *wfv1.Workflow, memoized bool) (*wfv1.Workflow

// carry over user labels and annotations from previous workflow.
// skip any argoproj.io labels except for the controller instanceID label.
if newWF.ObjectMeta.Labels == nil {
newWF.ObjectMeta.Labels = make(map[string]string)
}
for key, val := range wf.ObjectMeta.Labels {
if strings.HasPrefix(key, workflow.WorkflowFullName+"/") && key != common.LabelKeyControllerInstanceID {
continue
}
if newWF.ObjectMeta.Labels == nil {
newWF.ObjectMeta.Labels = make(map[string]string)
}
newWF.ObjectMeta.Labels[key] = val
}
// Append an additional label so it's easy for user to see the
// name of the original workflow that has been resubmitted.
newWF.ObjectMeta.Labels[common.LabelKeyPreviousWorkflowName] = wf.ObjectMeta.Name
for key, val := range wf.ObjectMeta.Annotations {
if newWF.ObjectMeta.Annotations == nil {
newWF.ObjectMeta.Annotations = make(map[string]string)
Expand Down

0 comments on commit 55e1370

Please sign in to comment.