-
Notifications
You must be signed in to change notification settings - Fork 6.5k
fix: Disable ESO refresh/push custom actions when they would do nothing #22305
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: Disable ESO refresh/push custom actions when they would do nothing #22305
Conversation
❌ Preview Environment deleted from BunnyshellAvailable commands (reply to this comment):
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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]*$"..
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
endI'm sure it has great performance, but it can also handle stuff like 0h0m0s0ms0µs0ns which is technically a correct time.ParseDuration input 😁
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
a9582ac to
f56d508
Compare
f56d508 to
03aa176
Compare
Signed-off-by: crabique <[email protected]>
03aa176 to
2c38361
Compare
…ng (argoproj#22305) Signed-off-by: crabique <[email protected]> Signed-off-by: Lyheng <[email protected]>
…ng (argoproj#22305) Signed-off-by: crabique <[email protected]>
…ng (argoproj#22305) Signed-off-by: crabique <[email protected]>
…ng (argoproj#22305) Signed-off-by: crabique <[email protected]> Signed-off-by: dsuhinin <[email protected]>
…ng (argoproj#22305) Signed-off-by: crabique <[email protected]> Signed-off-by: dsuhinin <[email protected]>
|
Hey, while the issue statement is valid, it is possible to set |
When
spec.refreshIntervalis0sfor eitherExternalSecretorPushSecret, 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: