Skip to content

feat: allow last retry variables in expressions. Fixes #10364#14450

Merged
Joibel merged 21 commits intoargoproj:mainfrom
pipekit:resurrect-allow-last-retry
May 21, 2025
Merged

feat: allow last retry variables in expressions. Fixes #10364#14450
Joibel merged 21 commits intoargoproj:mainfrom
pipekit:resurrect-allow-last-retry

Conversation

@isubasinghe
Copy link
Member

@isubasinghe isubasinghe commented May 6, 2025

Fixes #10364

Motivation

This PR resurrects the older PR by @eduardodbr to support last retry variable in expressions.

Modifications

This adds a generic function to replace expressions. My change differs somewhat to @eduardodbr's. I didn't agree with his implementation so I changed it. The actual injection is pretty much exactly how retries get injected.

Verification

Verified with the test.

Documentation

Modified the docs to add documentation on the lastRetry variable.

eduardodbr and others added 4 commits May 6, 2025 12:02
Signed-off-by: eduardodbr <eduardodbr@hotmail.com>
Signed-off-by: eduardodbr <eduardodbr@hotmail.com>
Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: isubasinghe <isitha@pipekit.io>
@isubasinghe isubasinghe changed the title feat: resurrect allow last retry feat: allow last retry variables in expressions. Fixes #10364 May 6, 2025
Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: isubasinghe <isitha@pipekit.io>
@isubasinghe isubasinghe marked this pull request as ready for review May 7, 2025 04:39
Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: isubasinghe <isitha@pipekit.io>
@isubasinghe isubasinghe requested a review from Joibel May 8, 2025 08:07
return fmt.Fprintf(w, "{{%s%s}}", kindExpression, expression)
}

if (hasVariableInExpression(unmarshalledExpression, "lastRetry.exitCode") && !hasVarInEnv(env, "lastRetry.exitCode") ||
Copy link
Member

Choose a reason for hiding this comment

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

Oh, this hack is horrid. But it mirrors what's happening with retries, so I guess we go with it for now.

Can we make this less evil code wise - perhaps list of all the variables we're going to do this for and iterate? Including retry?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure I think we can do this for lastRetry but I do not want to do this for retries. I think they need to be distinct.
I could maybe be refactored to share some common logic though.

Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: isubasinghe <isitha@pipekit.io>
@eduardodbr
Copy link
Member

Thanks for resurrecting it!

Looks good to me.

Did you have the time to check @juliev0 suggestion? #12722 (comment)

Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: isubasinghe <isitha@pipekit.io>
@isubasinghe isubasinghe requested a review from Joibel May 21, 2025 05:00
@Joibel Joibel merged commit 81130fb into argoproj:main May 21, 2025
34 checks passed
@Joibel Joibel deleted the resurrect-allow-last-retry branch May 21, 2025 10:10
@argo-cd-cherry-pick-bot
Copy link

❌ Cherry-pick failed for 3.6. Please check the workflow logs for details.

argo-cd-cherry-pick-bot bot pushed a commit that referenced this pull request Nov 13, 2025
Signed-off-by: eduardodbr <eduardodbr@hotmail.com>
Signed-off-by: isubasinghe <isitha@pipekit.io>
Co-authored-by: eduardodbr <eduardodbr@hotmail.com>
Joibel pushed a commit that referenced this pull request Nov 13, 2025
Co-authored-by: eduardodbr <eduardodbr@hotmail.com>
(cherry picked from commit 81130fb)

Signed-off-by: eduardodbr <eduardodbr@hotmail.com>
Signed-off-by: isubasinghe <isitha@pipekit.io>
Signed-off-by: Alan Clucas <alan@clucas.org>
@Joibel
Copy link
Member

Joibel commented Nov 13, 2025

Oops, this is a feature so shouldn't be back ported. I was trying to sort out the dependencies for backporting #15033 to release-3.6

Joibel added a commit that referenced this pull request Nov 13, 2025
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.

Allow use of lastRetry in podSpecPatch resources request

3 participants