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(controller): Use deterministic name for cron workflow children #4638

Merged
merged 11 commits into from Dec 9, 2020

Conversation

simster7
Copy link
Member

@simster7 simster7 commented Dec 3, 2020

Signed-off-by: Simon Behar simbeh7@gmail.com

Checklist:

Signed-off-by: Simon Behar <simbeh7@gmail.com>
Signed-off-by: Simon Behar <simbeh7@gmail.com>
workflow/cron/operator.go Outdated Show resolved Hide resolved
}

func getChildWorkflowName(cronWorkflowName string, scheduledRuntime time.Time) string {
return fmt.Sprintf("%s-%d", cronWorkflowName, scheduledRuntime.Unix())
Copy link
Contributor

Choose a reason for hiding this comment

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

truncate time to 1 minute?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this function should accept scheduledRuntime as given and not modify it

Copy link
Contributor

Choose a reason for hiding this comment

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

do you truncate there?

Signed-off-by: Simon Behar <simbeh7@gmail.com>
Signed-off-by: Simon Behar <simbeh7@gmail.com>
Signed-off-by: Simon Behar <simbeh7@gmail.com>
Signed-off-by: Simon Behar <simbeh7@gmail.com>
workflow/cron/controller.go Outdated Show resolved Hide resolved
This reverts commit ef8e3e3.

Signed-off-by: Simon Behar <simbeh7@gmail.com>
Signed-off-by: Simon Behar <simbeh7@gmail.com>
@@ -8,22 +8,21 @@ import (
)

func ConvertCronWorkflowToWorkflow(cronWf *wfv1.CronWorkflow) *wfv1.Workflow {
wf := toWorkflow(cronWf.TypeMeta, cronWf.ObjectMeta, cronWf.Spec.WorkflowSpec)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this covered by existing tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it is. I added an extra test as well

workflow/common/convert.go Show resolved Hide resolved
workflow/cron/cron_facade.go Show resolved Hide resolved
workflow/cron/operator.go Outdated Show resolved Hide resolved
workflow/cron/operator.go Outdated Show resolved Hide resolved
if errors.IsAlreadyExists(err) {
// The scheduled workflow already exists, likely indicating that there is a corrupted LastScheduledTime field.
// If the intended scheduledRuntime is later than the present value in LastScheduledTime, then replace it
if scheduledRuntime.After(woc.cronWf.Status.LastScheduledTime.Time) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If it is a conflict error, then our time should be the same surely? This code does not get run?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, I think after the overwriting stale LastScheduledRun issue is fixed in #4659 this check will be moot. Not sure I would remove it though as it can only fix a corrupted state if it encounters one. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to write tests and then bug fix and maintain all new code - so add less code if it achieves the same outcome

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, will remove this then

workflow/cron/operator.go Outdated Show resolved Hide resolved
workflow/cron/operator.go Outdated Show resolved Hide resolved
Signed-off-by: Simon Behar <simbeh7@gmail.com>
@simster7 simster7 requested a review from alexec December 9, 2020 14:00
@simster7
Copy link
Member Author

simster7 commented Dec 9, 2020

@alexec Addressed comments

@alexec alexec changed the title feat: Use deterministic name for cron workflow children feat(controller): Use deterministic name for cron workflow children Dec 9, 2020
Signed-off-by: Simon Behar <simbeh7@gmail.com>
@simster7 simster7 merged commit d9d5f5f into argoproj:master Dec 9, 2020
@simster7
Copy link
Member Author

Back-ported to v2.12.0-rc5

simster7 added a commit that referenced this pull request Dec 10, 2020
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.

None yet

2 participants