-
Notifications
You must be signed in to change notification settings - Fork 542
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
mimir-operations: Ensure integer auto-scaling thresholds #3512
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
c278206
to
37b2170
Compare
37b2170
to
94cdacd
Compare
94cdacd
to
6a3deb7
Compare
) | ||
); | ||
|
||
std.split(std.toString(siToBytesDecimal(str)), '.')[0] |
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.
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.
If we are using std.toString(std.parseInt(trigger.threshold))
above, do we need this here?
siToBytes could still return a number (preferably an integer, but decimals shouldn't matter if it's easier to ignore it for now). It's KEDA itself that expects a number in a string so we could do the string conversion just at that point.
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.
If we are using std.toString(std.parseInt(trigger.threshold)) above, do we need this here?
@jhesketh std.parseInt
will fail if e.g. it's a string representing a decimal nmber, so it is necessary.
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.
Can't we guarantee that siToBytesDecimal()
always return a number, then here we just use std.ceil(siToBytesDecimal(str))
?
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.
@pracucci aside from the technique for converting to a number, do you prefer rounding up (ceil
) to rounding down, since I'm currently doing the latter?
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 converted siToBytesDecimal
to return a number, awaiting @pracucci's reply regarding floor
vs ceil
. I figured rounding down would be OK personally, but not sure what others think.
6a3deb7
to
128f7cb
Compare
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.
Happy to do this as it should work, but also wondering if we can neaten the type handling up a bit. The type expectation from KEDA is silly :-s
) | ||
); | ||
|
||
std.split(std.toString(siToBytesDecimal(str)), '.')[0] |
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.
If we are using std.toString(std.parseInt(trigger.threshold))
above, do we need this here?
siToBytes could still return a number (preferably an integer, but decimals shouldn't matter if it's easier to ignore it for now). It's KEDA itself that expects a number in a string so we could do the string conversion just at that point.
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.
Can you state in a comment what the conversion is - looks like truncate-towards-zero.
Also I would clarify that siToBytes
is now returning a string. Perhaps name it siToBytesString
.
Thanks @bboreham, will do. |
128f7cb
to
c366640
Compare
In Jsonnet logic to generate KEDA auto-scaling thresholds, ensure that thresholds are integers since KEDA requires this. Signed-off-by: Arve Knudsen <[email protected]>
c366640
to
08a8209
Compare
@@ -137,21 +139,27 @@ | |||
}, | |||
}, | |||
|
|||
local siToBytes(str) = ( | |||
local siToBytesString(str) = ( |
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.
From a design perspective, I think this should be a generic utility returning a number and then if the call needs a string it will cast it to string (which is what were were doing before).
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.
@pracucci actually before it could return either a number or a string.
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.
@pracucci I converted it now into returning an integer.
Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
* mimir-operations: Ensure integer auto-scaling thresholds In Jsonnet logic to generate KEDA auto-scaling thresholds, ensure that thresholds are integers since KEDA requires this. Signed-off-by: Arve Knudsen <[email protected]>
What this PR does
Ensure that auto-scaling thresholds in mimir-operations are integers.
Which issue(s) this PR fixes or relates to
We've sometimes made the mistake of setting non-integer KEDA thresholds due to this logic not enforcing the expectation of them being integers.
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]