Skip to content

Conversation

@crabique
Copy link
Contributor

@crabique crabique commented Mar 11, 2025

When spec.refreshInterval is 0s for either ExternalSecret or PushSecret, adding the annotation to it will not trigger a forced refresh/push, so the custom action are misleading as it would seem like something happens, but nothing actually does.

Related ESO issue: external-secrets/external-secrets#4447

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

@crabique crabique requested a review from a team as a code owner March 11, 2025 21:39
@bunnyshell
Copy link

bunnyshell bot commented Mar 11, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@codecov
Copy link

codecov bot commented Mar 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@2afcb6f). Learn more about missing BASE report.
⚠️ Report is 735 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master   #22305   +/-   ##
=========================================
  Coverage          ?   55.88%           
=========================================
  Files             ?      343           
  Lines             ?    57327           
  Branches          ?        0           
=========================================
  Hits              ?    32039           
  Misses            ?    22646           
  Partials          ?     2642           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@crenshaw-dev crenshaw-dev left a comment

Choose a reason for hiding this comment

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

Basic idea lgtm, just have one request to cover more possible values.

actions["refresh"] = {["disabled"] = false}

local refresh_disabled = false
if obj.spec.refreshInterval == "0s" then
Copy link
Member

Choose a reason for hiding this comment

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

Looks like refreshInterval is based on go's time.ParseDuration, so we'd also need to handle 0, 0ns, 0us, 0µs, 0ms, 0m, and 0h to cover all cases.

Copy link
Contributor Author

@crabique crabique Mar 13, 2025

Choose a reason for hiding this comment

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

Yeah I was checking that too, it seems that in modern versions of Go it always serializes to 0s, at least according to kubernetes/kubernetes#40783

For any 0-ish duration it's printed as 0s: https://go.dev/play/p/mKxx1R5ruHN

Copy link
Member

Choose a reason for hiding this comment

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

It looks like the Lua script receives whatever is in the YAML, not the sting-serialized version.

Screen.Recording.2025-03-14.at.10.20.57.AM.mov

Copy link
Contributor Author

@crabique crabique Mar 14, 2025

Choose a reason for hiding this comment

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

@crenshaw-dev do you think something like string.find(obj.spec.refreshInterval, "^0[^0-9]*$") would be acceptable? Could also be a more explicit "^0[nuµsmh]*$"..

Copy link
Member

Choose a reason for hiding this comment

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

I like the explicit regex, assuming we have access to a regex lib in Lua

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The * is to handle the composite suffixes (ns, us, µs, ms), and to match a suffix-less 0, as I understand it can be put in YAML as well.

Regarding the pattern matching library, this should be the standard lib: didn't require any imports to work with vanilla interpreter.

Copy link
Member

Choose a reason for hiding this comment

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

Ah fair... maybe this:

^0(0*(ns|us|µs|ms|s|m|h))?$

That would handle 0, 0s, 000h but would reject the invalid 00. Probably not a perfect match with what time.ParseDuration supports, but close enough.

Copy link
Contributor Author

@crabique crabique Mar 15, 2025

Choose a reason for hiding this comment

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

Unfortunately, it didn't work because this isn't really a regex engine and it doesn't support groupings of characters.

The only thing that worked reliably so far is the ugly "^0*[nuµsmh]*$", but even splitting it to "^0[nuµm]?[smh]?$" stops matching 0µs for some ASCII reasons I assume.

Maybe a pivot to something more complex, but readable instead?

disable_refresh = false
local time_units = {"ns", "us", "µs", "s", "m", "h"}
local digits = obj.spec.refreshInterval
for _, time_unit in ipairs(time_units) do
    digits, _ = digits:gsub(time_unit, "")
    if tonumber(digits) == 0 then
        disable_refresh = true
        break
    end
end

I'm sure it has great performance, but it can also handle stuff like 0h0m0s0ms0µs0ns which is technically a correct time.ParseDuration input 😁

Copy link
Member

Choose a reason for hiding this comment

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

I'm cool with complex! Especially nice that it handles more possibilities.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the help! PR updated, PTAL

@crabique crabique force-pushed the fix/eso-resource-actions branch from a9582ac to f56d508 Compare March 18, 2025 14:39
@crabique crabique requested a review from crenshaw-dev March 18, 2025 14:40
@crabique crabique force-pushed the fix/eso-resource-actions branch from f56d508 to 03aa176 Compare March 18, 2025 14:52
@crabique crabique force-pushed the fix/eso-resource-actions branch from 03aa176 to 2c38361 Compare March 18, 2025 16:26
@crenshaw-dev crenshaw-dev merged commit 4905876 into argoproj:master May 21, 2025
27 checks passed
@crabique crabique deleted the fix/eso-resource-actions branch May 21, 2025 20:05
LyhengTep pushed a commit to LyhengTep/argo-cd that referenced this pull request May 24, 2025
tylerrosnett pushed a commit to StateFarmIns/argo-cd that referenced this pull request May 27, 2025
chansuke pushed a commit to chansuke/argo-cd that referenced this pull request Jun 4, 2025
dsuhinin pushed a commit to dsuhinin/argo-cd that referenced this pull request Jun 16, 2025
dsuhinin pushed a commit to dsuhinin/argo-cd that referenced this pull request Jun 16, 2025
@KyriosGN0
Copy link
Contributor

Hey, while the issue statement is valid, it is possible to set RefreshPolicy: OnChange on ExternalSecret (and i think PushSecret as well) and then this option becomes valid, would you be open a to PR to change that behavior? or do i need to open an issue to discuss this? @crenshaw-dev

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.

3 participants