Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CLI): support backfill for cron workflow. Part of #2706 #13999

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

shuangkun
Copy link
Member

@shuangkun shuangkun commented Dec 15, 2024

Base #4212

Airflow is easy to backfill. Simplify the use of backfill on Argo.

Support:

Provide CLI like argo corn backfill <cronworkflow name> --name <backfill name> --start <startdate> --end <enddate>

Part of #2706

Motivation

Modifications

Verification

U-4YKHFNR6-2229 cron-backfill % ./argo cron backfill daily-job --start "Wed, 21 Oct 2024 15:28:00 GMT" --end "Wed, 28 Oct 2024 15:28:00 GMT" --argname data --parallel true
Created 28816 Backfill task for Cronworkflow daily-job
==================================================
Backfill Period :
Start Time : Wed, 21 Oct 2024 15:28:00 GMT
  End Time : Wed, 28 Oct 2024 15:28:00 GMT
Total Backfill Schedule: 7
==================================================
Backfill Workflows:
   NAMESPACE	 WORKFLOW:
1. argo 	 backfill-wf-jhmpr
tianshuangkun@U-4YKHFNR6-2229 cron-backfill % ./argo get backfill-wf-jhmpr
Name:                backfill-wf-jhmpr
Namespace:           argo
ServiceAccount:      unset (will run with the default ServiceAccount)
Status:              Running
Conditions:
 PodRunning          True
Created:             Tue Dec 17 14:44:02 +0800 (10 seconds ago)
Started:             Tue Dec 17 14:44:02 +0800 (10 seconds ago)
Duration:            10 seconds
Progress:            0/7

STEP                                                     TEMPLATE         PODNAME                                       DURATION  MESSAGE
 ● backfill-wf-jhmpr                                     main
 └─┬─● create-workflow(0:2024-10-22 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-3441413642  10s
   ├─● create-workflow(1:2024-10-23 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-2444440844  10s
   ├─● create-workflow(2:2024-10-24 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-2857101642  10s
   ├─● create-workflow(3:2024-10-25 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-2922680488  10s
   ├─● create-workflow(4:2024-10-26 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-4231395098  10s
   ├─● create-workflow(5:2024-10-27 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-2220838812  10s
   └─● create-workflow(6:2024-10-28 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-1221315226  10s
U-4YKHFNR6-2229 cron-backfill % argo list
NAME                             STATUS      AGE   DURATION   PRIORITY   MESSAGE
daily-job-backfill-28816-njt45   Running     11s   11s        0
daily-job-backfill-28816-shk9g   Running     11s   11s        0
daily-job-backfill-28816-vk79g   Running     11s   11s        0
backfill-wf-jhmpr                Running     13s   13s        0
daily-job-backfill-28816-k5wcm   Succeeded   11s   7s         0
daily-job-backfill-28816-q949s   Succeeded   11s   7s         0
daily-job-backfill-28816-xssbb   Succeeded   11s   7s         0
daily-job-backfill-28816-csfld   Succeeded   11s   6s         0
U-4YKHFNR6-2229 cron-backfill % argo list
NAME                             STATUS      AGE   DURATION   PRIORITY   MESSAGE
backfill-wf-jhmpr                Succeeded   34s   30s        0
daily-job-backfill-28816-vk79g   Succeeded   32s   22s        0
daily-job-backfill-28816-shk9g   Succeeded   32s   17s        0
daily-job-backfill-28816-njt45   Succeeded   32s   13s        0
U-4YKHFNR6-2229 cron-backfill % ./argo get backfill-wf-jhmpr
Name:                backfill-wf-jhmpr
Namespace:           argo
ServiceAccount:      unset (will run with the default ServiceAccount)
Status:              Succeeded
Conditions:
 PodRunning          False
 Completed           True
Created:             Tue Dec 17 14:44:02 +0800 (37 seconds ago)
Started:             Tue Dec 17 14:44:02 +0800 (37 seconds ago)
Finished:            Tue Dec 17 14:44:32 +0800 (7 seconds ago)
Duration:            30 seconds
Progress:            7/7
ResourcesDuration:   9s*(1 cpu),1m7s*(100Mi memory)

STEP                                                     TEMPLATE         PODNAME                                       DURATION  MESSAGE
 ✔ backfill-wf-jhmpr                                     main
 └─┬─✔ create-workflow(0:2024-10-22 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-3441413642  23s
   ├─✔ create-workflow(1:2024-10-23 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-2444440844  13s
   ├─✔ create-workflow(2:2024-10-24 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-2857101642  28s
   ├─✔ create-workflow(3:2024-10-25 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-2922680488  18s
   ├─✔ create-workflow(4:2024-10-26 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-4231395098  13s
   ├─✔ create-workflow(5:2024-10-27 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-2220838812  13s
   └─✔ create-workflow(6:2024-10-28 02:00:00 +0000 GMT)  create-workflow  backfill-wf-jhmpr-create-workflow-1221315226  13s

Co-authored-by: Saravanan Balasubramanian <[email protected]>
Co-authored-by: shuangkun <[email protected]>
Signed-off-by: shuangkun <[email protected]>
@shuangkun shuangkun marked this pull request as draft December 15, 2024 12:19
@shuangkun shuangkun marked this pull request as ready for review December 17, 2024 06:33
@shuangkun shuangkun changed the title feat(CLI): support backfill for cron workflow. feat(CLI): support backfill for cron workflow. Part of #2706 Dec 17, 2024
Copy link
Member

@tczhao tczhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should have a way to label this as something like a alpha feature,
so that we don't need to maintain backward compatibility incase there's a significant change later on

Namespace: Namespace,
LabelRequirements: parse,
})
s.CheckError(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we check backfill workflow actually exist, incase this returns empty list

--format string Date format for Schedule time value (default "Mon, 02 Jan 2006 15:04:05 MST")
-h, --help help for backfill
--name string Backfill name
--parallel Enabled all backfile workflows run parallel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
--parallel Enabled all backfile workflows run parallel
--parallel Enabled all backfill workflows run parallel

return nil
}

var backfillWf = `{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var backfillWf = `{
const backfillWf = `{

var scheList []string
wf := common.ConvertCronWorkflowToWorkflow(cronWF)
paramArg := `{{inputs.parameters.backfillscheduletime}}`
wf.GenerateName = cronWF.Name + "-backfill-" + strings.ToLower(cliOps.name) + "-"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may want to truncate this in case this gets too long

### Options

```
--argname string Schedule time argument name for workflow (default "cronScheduleTime")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if we really need this, it's only for parent workflow, right?

`

func CreateMonitorWf(ctx context.Context, wf, namespace, cronWFName string, scheTime []string, wfClient workflow.WorkflowServiceClient, cliOps backfillOpts) error {
const maxWfCount = 1000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to expose this as an argument?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants