Repository navigation
fix: format autoscaling annotation values without trailing zeros - #3904
Elvand-Lie wants to merge 2 commits into
Conversation
|
Hi @Elvand-Lie. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Verification Evidence1.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3904 +/- ##
==========================================
+ Coverage 54.00% 54.04% +0.04%
==========================================
Files 200 200
Lines 23687 23687
==========================================
+ Hits 12792 12802 +10
+ Misses 9660 9653 -7
+ Partials 1235 1232 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bc022b5 to
740583b
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes formatting of Knative autoscaling annotation values produced by setServiceOptions so that integer-like floats don’t get emitted with trailing .000000, matching Knative’s expected annotation string format.
Changes:
- Switch autoscaling
TargetandUtilizationannotation formatting from"%f"to"%g"to remove trailing zeros. - Add a regression test ensuring
100.0and70.0render as"100"and"70"in the resulting annotations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
pkg/knative/deployer.go |
Updates autoscaling annotation value formatting to avoid unwanted trailing decimals. |
pkg/knative/deployer_test.go |
Adds a regression test to assert the corrected annotation string formatting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
740583b to
2c8df8d
Compare
setServiceOptions used fmt.Sprintf(%%f, ...) to format autoscaling Target and Utilization annotations, producing values like 100.000000 instead of 100. Knative autoscaler expects clean numeric strings. Changed to %%g which strips trailing zeros (100.0 -> 100, 70.5 -> 70.5). Also adds regression test TestSetServiceOptions_ScaleAnnotationFormat. Fixes knative#3901
%f leaves trailing zeros ("100.000000"); %g switches to exponent form
at >= 1e6 ("1e+06"). FormatFloat with 'f' and prec -1 yields the clean
decimal Knative expects ("100", "70.5", "1000000").
Signed-off-by: Luke Kingland <luke@lukekingland.com>
2c8df8d to
03e24d3
Compare
|
Thanks @Elvand-Lie. We rebased this and added one commit on top: /ok-to-test |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Elvand-Lie, lkingland The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
setServiceOptionsinpkg/knative/deployer.goformatted the autoscalingTargetandUtilizationannotations withfmt.Sprintf("%f", ...), which writes six decimal places ("100.000000").Both values are now formatted with
strconv.FormatFloat(v, 'f', -1, 64): plain decimal, no trailing zeros, and no exponent form (100,70.5,1000000).%gwould have switched to1e+06at one million.Existing services get one new revision on their next deploy, since the annotation text changes.
Changes
pkg/knative/deployer.go: format Target and Utilization withstrconv.FormatFloatpkg/knative/deployer_test.go:TestSetServiceOptions_ScaleAnnotationFormatcovers integer, fractional and 1e6 valuespkg/knative/deployer_scale_test.go: expected values updatedFixes #3901
Release Note