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: add status.lastRunAt field to WorkflowTemplates. Fixes #1915 #13310

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

qingfeng777
Copy link
Contributor

@qingfeng777 qingfeng777 commented Jul 5, 2024

Fixes #1915

Motivation

It would be useful to know when the last time a WorkflowTemplate was run

Modifications

  • add WorkflowTemplateStatus.LastRunAt filed to workflow template filed
  • enable workflowTemplate support record last run time

img_v3_02ch_489267f4-e9f9-4204-967a-ed83b98d1c2g

Verification

run locally, submit workflow from template and check

@qingfeng777 qingfeng777 marked this pull request as draft July 6, 2024 15:18
@qingfeng777 qingfeng777 marked this pull request as ready for review July 6, 2024 15:19
@qingfeng777 qingfeng777 force-pushed the main branch 2 times, most recently from 1475af0 to 552cefd Compare July 6, 2024 15:50
@Joibel
Copy link
Member

Joibel commented Jul 8, 2024

The implementation of the feature doesn't do what I expected.

Currently, it is only recording uses of WorkflowTemplates when invoked through the user interface or CLI, and will not record uses in many other circumstances:

  • Uses from CronWorkflows
  • Uses when a workflow is injected via the kubernetes API, or other system which uses this mechanism such as argo-events
  • Uses of a template when it is not used through workflowTemplateRef.

I am happy, if we document it as so, that this only records workflowTemplateRef uses of a WorkflowTemplate. It must record all uses via workflowTemplateRef though. Take a look at fetchWorkflowSpec.

I was also expecting this new value to be visible in the user interface, although I might be persuaded that that should be in a separate PR if you have a good reason.

Copy link
Member

@Joibel Joibel left a comment

Choose a reason for hiding this comment

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

This should be performed by the controller to catch all uses, not by the server.

@qingfeng777
Copy link
Contributor Author

qingfeng777 commented Jul 8, 2024

Thank you for being so helpful. You were absolutely right. I will make a separate PR to add the Status field and then see how to perform this task with the controller to catch all uses.

@qingfeng777 qingfeng777 changed the title feat: workflow template support record last run time. Fixes #1915 feat: workflow template add status.lastrunat field. Fixes #1915 Jul 8, 2024
@agilgur5 agilgur5 changed the title feat: workflow template add status.lastrunat field. Fixes #1915 feat: add status.lastRunAt field to WorkflowTemplates. Fixes #1915 Jul 8, 2024
@agilgur5 agilgur5 added area/spec Changes to the workflow specification. area/workflow-templates labels Jul 8, 2024
@qingfeng777 qingfeng777 requested a review from Joibel July 9, 2024 00:42
Copy link
Member

@Joibel Joibel left a comment

Choose a reason for hiding this comment

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

By itself, adding the field but not setting it isn't useful, and is possibly misleading as someone might reasonably expect it to get set.

Could you add the code to set this value from the controller to this same PR please.

@qingfeng777
Copy link
Contributor Author

qingfeng777 commented Jul 9, 2024

Thank you for your advice, I will add the code to set this value from the controller to the same PR later.

@qingfeng777 qingfeng777 force-pushed the main branch 3 times, most recently from 3d5a319 to 80c1b0d Compare July 15, 2024 02:13
@qingfeng777
Copy link
Contributor Author

qingfeng777 commented Jul 15, 2024

Hi,

In my first attempt, I updated the Getter in context.go to an Operator (supporting both get and update operations), using the clientSet as a parameter. However, the requeue and get workflow did not function as expected.

In my second attempt, I used NewContextFromClientSet instead of NewContext, to hold both the informer getter and clientSet. Unfortunately, I was unable to retrieve clientSet in some callers of the ValidateWorkflow function.

Ultimately, I implemented the feature like this. I am unsure if there is a better approach. Could you please review it again?

The main updates to support recording LastRunAt are in the second commit.

Thank you.

@qingfeng777 qingfeng777 requested a review from Joibel July 15, 2024 07:02
@qingfeng777 qingfeng777 marked this pull request as draft July 19, 2024 01:29
@qingfeng777 qingfeng777 marked this pull request as ready for review July 19, 2024 01:29
@Joibel Joibel self-assigned this Jul 19, 2024
Copy link
Member

@Joibel Joibel left a comment

Choose a reason for hiding this comment

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

This is a hard problem to solve correctly. The main objection here is how hard this is on the kubernetes API, and how it will slow down execution.

workflow/templateresolution/context.go Outdated Show resolved Hide resolved
workflow/templateresolution/context.go Outdated Show resolved Hide resolved
workflow/templateresolution/context.go Outdated Show resolved Hide resolved
workflow/templateresolution/context.go Show resolved Hide resolved
@qingfeng777 qingfeng777 marked this pull request as draft July 23, 2024 15:16
@qingfeng777 qingfeng777 force-pushed the main branch 2 times, most recently from 5bc7bdc to aa010cf Compare July 29, 2024 17:42
@qingfeng777 qingfeng777 requested a review from Joibel July 30, 2024 00:50
@qingfeng777 qingfeng777 marked this pull request as ready for review July 30, 2024 00:50
@Joibel
Copy link
Member

Joibel commented Jul 30, 2024

I am away for 2 weeks, I will take a look when I can.

@qingfeng777
Copy link
Contributor Author

qingfeng777 commented Jul 30, 2024

Happy holidays!

@qingfeng777
Copy link
Contributor Author

Hi,@Joibel, could you take a look at this PR? thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/spec Changes to the workflow specification. area/workflow-templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Record last time when a WorkflowTemplate was used in a status field
3 participants