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

fix!: consolidate cronworkflow variables #13702

Merged
merged 4 commits into from
Oct 17, 2024
Merged

fix!: consolidate cronworkflow variables #13702

merged 4 commits into from
Oct 17, 2024

Conversation

Joibel
Copy link
Member

@Joibel Joibel commented Oct 4, 2024

Context

Issues #13474 and #12305 both introduced expressions into CronWorkflows as new features for 3.6.
There are some inconsistencies between the two, per #13474 (comment) and #12305 (comment)

This PR was discussed at the October 1st 2024 Contributor meeting.

Motivation

The expressions for when include the prefix cronworkflow.. Those for stopStrategy.condition do not.

Unify both of these under cronworkflow. and allow both sets of variables to be used in both expressions. This simplifies the documentation and is less surprising. It also allows some use cases where you could check for previous run failures and take decisions based on that and time of day - so perhaps run every hour in the schedule but then use when to only actually take action if the previous run this day failed.

stopStrategy's condition is mostly not a field name used in workflows, so in agreement with @agilgur5 I've renamed it to expression.

Modifications

Renamed stopStrategy.condition to stopStrategy.expression

Created a single function to generate all the variables for both expressions and use that instead of the two disparate mechanisms.

Modified some code comments to be godoc compliant.

Verification

Existing tests still pass with appropriate amendments to the test cases

Note

This is a breaking change vs 3.6-rc1 and rc2 for users of stopStrategy only. This is not considered properly breaking as those are release candidates and not full releases.

Signed-off-by: Alan Clucas [email protected]

@Joibel Joibel assigned Joibel and unassigned Joibel Oct 4, 2024
@Joibel
Copy link
Member Author

Joibel commented Oct 4, 2024

Summoning

  • @eduardodbr, the effect of this change is mostly on your implementation, so I'd appreciate feedback
  • @isubasinghe, this doesn't much affect when, but I'd also appreciate feedback
  • @agilgur5, as you're the one who pointed this out and I'd like to know if it matches your expectations

@Joibel Joibel force-pushed the cron-variable-tidies branch from 84afcd9 to d4e3e02 Compare October 4, 2024 07:15
Copy link

@agilgur5 agilgur5 left a comment

Choose a reason for hiding this comment

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

Could you remove the @tag of me in the commit message? I'm getting notified for every single commit right now and uh would prefer not to, including when commits are backported or forked 😅

@agilgur5 agilgur5 added this to the v3.6.0 milestone Oct 4, 2024
@Joibel Joibel force-pushed the cron-variable-tidies branch from d4e3e02 to 08d15c2 Compare October 4, 2024 14:30
@Joibel
Copy link
Member Author

Joibel commented Oct 4, 2024

Could you remove the @tag of me in the commit message? I'm getting notified for every single commit right now and uh would prefer not to, including when commits are backported or forked 😅

Oh, ha ha! That's not fun.
Done.

docs/fields.md Outdated Show resolved Hide resolved
@agilgur5 agilgur5 added area/cron-workflows area/templating Templating with `{{...}}` labels Oct 5, 2024
Copy link
Member

@isubasinghe isubasinghe left a comment

Choose a reason for hiding this comment

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

I do apologize but I think this:
hack/api/swagger/swaggify.sh
is getting in your way.

@Joibel Joibel dismissed agilgur5’s stale review October 7, 2024 08:34

Removed @ from commit message as requested

@Joibel
Copy link
Member Author

Joibel commented Oct 7, 2024

I do apologize but I think this: hack/api/swagger/swaggify.sh is getting in your way.

This is annoying. I'm not going to attempt to address this hack at the moment, so I've reworded it. Probably the correct fix is to understand the json and only replace in the two (I think) places in the structure which actually want it to happen, or at least not in title and description fields.

Copy link

@agilgur5 agilgur5 left a comment

Choose a reason for hiding this comment

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

There are some misses here and a semantic error in the docs. Do keep in mind the surrounding context when making docs changes, as they do reference and build upon each other.
The version annotations are also intentionally at the beginning.
See in-line comments below

docs/cron-workflows.md Show resolved Hide resolved
docs/cron-workflows.md Outdated Show resolved Hide resolved
docs/cron-workflows.md Show resolved Hide resolved
docs/cron-workflows.md Outdated Show resolved Hide resolved
@@ -69,11 +69,12 @@ type CronWorkflowSpec struct {
When string `json:"when,omitempty" protobuf:"bytes,12,opt,name=when"`
}

// v3.6 and after: StopStrategy defines if the CronWorkflow should stop scheduling based on a condition
// StopStrategy defines if the CronWorkflow should stop scheduling based on an expression. v3.6 and after
Copy link

@agilgur5 agilgur5 Oct 7, 2024

Choose a reason for hiding this comment

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

The version annotation being consistently the first thing is intentional so that it is the first thing you see. This change makes this inconsistent with every other version annotation in the codebase, like lines 64-68 above, as well as harder to notice (and we already have trouble with users not noticing versions and so should not increase that).

I believe you made this change for GoDoc purposes, which does raise a conundrum since that apparently requires it to start the same way? If it's just a convention, the consistency and visibility should supersede that.

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 did that to make it GoDoc compliant.

Copy link

@agilgur5 agilgur5 Oct 22, 2024

Choose a reason for hiding this comment

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

That does not address my comment (I mentioned that myself in my comment) and, as I wrote above, is inconsistent with the entirety of rest of the code and docs (where this exact comment is user-facing) on version annotation placement

pkg/apis/workflow/v1alpha1/cron_workflow_types.go Outdated Show resolved Hide resolved
Issues #13474 and #12305 both introduced expressions into
CronWorkflows as new features for 3.6.

Motivation

The expressions for `when` include the prefix `cronworkflow.`. Those
for `stopStrategy.condition` do not.

Unify both of these under `cronworkflow.` and allow both sets of
variables to be used in both expressions. This simplifies the
documentation and is less surprising.

stopExpression's `condition` is mostly not a field name used, so in
agreement with agilgur5 I've renamed it to `expression`.

Modifications

Renamed `stopStrategy.condition` to `stopStrategy.expression`

Created a single function to generate all the variables for both
expressions and use that instead of the two disparate mechanisms.

Modified some code comments to be godoc compliant.

Verification

Existing tests still pass with appropriate amendments to the test cases

Note

This is a breaking change vs 3.6-rc1 and rc2 for users of stopStrategy
only.

Signed-off-by: Alan Clucas <[email protected]>
@Joibel Joibel force-pushed the cron-variable-tidies branch from f93cd60 to 5878b21 Compare October 11, 2024 13:21
Signed-off-by: Alan Clucas <[email protected]>
@Joibel Joibel force-pushed the cron-variable-tidies branch from 5878b21 to 1c20373 Compare October 11, 2024 13:23
Copy link
Member

@isubasinghe isubasinghe left a comment

Choose a reason for hiding this comment

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

LGTM

@Joibel Joibel requested a review from agilgur5 October 15, 2024 08:09
@Joibel Joibel dismissed agilgur5’s stale review October 17, 2024 09:47

Requested changes have been addressed

@Joibel Joibel enabled auto-merge (squash) October 17, 2024 09:47
@Joibel Joibel merged commit a88cddc into main Oct 17, 2024
28 checks passed
@Joibel Joibel deleted the cron-variable-tidies branch October 17, 2024 10:18
Copy link

@agilgur5 agilgur5 left a comment

Choose a reason for hiding this comment

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

Joibel dismissed agilgur5’s stale review 5 days ago:
Requested changes have been addressed

One of them was not addressed and the other was only partially addressed

@@ -51,7 +51,7 @@ You can use `CronWorkflow.spec.workflowMetadata` to add `labels` and `annotation
| `startingDeadlineSeconds` | `0` | Seconds after [the last scheduled time](#crash-recovery) during which a missed `Workflow` will still be run. |
| `successfulJobsHistoryLimit` | `3` | Number of successful `Workflows` to persist |
| `failedJobsHistoryLimit` | `1` | Number of failed `Workflows` to persist |
| `stopStrategy` | `nil` | v3.6 and after: defines if the CronWorkflow should stop scheduling based on a condition |
| `stopStrategy.expression` | `nil` | v3.6 and after: defines if the CronWorkflow should stop scheduling based on an expression, which if present must evaluate to false for the workflow to be created |
Copy link

@agilgur5 agilgur5 Oct 22, 2024

Choose a reason for hiding this comment

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

Suggested change
| `stopStrategy.expression` | `nil` | v3.6 and after: defines if the CronWorkflow should stop scheduling based on an expression, which if present must evaluate to false for the workflow to be created |
| `stopStrategy.expression` | `nil` | v3.6 and after: defines if the CronWorkflow [should stop scheduling](#automatically-stopping-a-cronworkflow) based on an expression |

@@ -69,11 +69,12 @@ type CronWorkflowSpec struct {
When string `json:"when,omitempty" protobuf:"bytes,12,opt,name=when"`
}

// v3.6 and after: StopStrategy defines if the CronWorkflow should stop scheduling based on a condition
// StopStrategy defines if the CronWorkflow should stop scheduling based on an expression. v3.6 and after
Copy link

@agilgur5 agilgur5 Oct 22, 2024

Choose a reason for hiding this comment

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

That does not address my comment (I mentioned that myself in my comment) and, as I wrote above, is inconsistent with the entirety of rest of the code and docs (where this exact comment is user-facing) on version annotation placement

docs/cron-workflows.md Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants