fix: use %g instead of %f for autoscaling annotation values#3904
fix: use %g instead of %f for autoscaling annotation values#3904Elvand-Lie wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Elvand-Lie The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
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 53.93% 51.73% -2.20%
==========================================
Files 200 200
Lines 23681 23681
==========================================
- Hits 12772 12252 -520
- Misses 9674 10282 +608
+ Partials 1235 1147 -88
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:
|
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
bc022b5 to
740583b
Compare
Description
setServiceOptionsinpkg/knative/deployer.gousesfmt.Sprintf("%f", ...)to format autoscalingTargetandUtilizationannotation values. Go's%fverb produces 6 trailing decimal places by default (e.g.,"100.000000"), which is not the expected format for Knative autoscaling annotations.Changed
%fto%gwhich strips trailing zeros (100.0becomes"100",70.5becomes"70.5").Changes
pkg/knative/deployer.go, lines 592 and 598:%freplaced with%gpkg/knative/deployer_test.go: addedTestSetServiceOptions_ScaleAnnotationFormatregression testVerification
go vet ./pkg/knative: cleango test ./pkg/knative/ -count=1: all 20 tests passgo test ./pkg/knative/ -run TestSetServiceOptions_ScaleAnnotationFormat -count=1: passFixes #3901