-
Notifications
You must be signed in to change notification settings - Fork 263
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
Calculate traffic split when N-1 revisions are specified #1483
Conversation
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.
@vyasgun: 0 warnings.
In response to this:
Description
Changes
- Determine traffic split when N-1 revisions are specified
- In case
@latest
is specified, cannot determine the split unless it sums to 100Reference
Fixes #
Instructions 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/test-infra repository.
Codecov Report
@@ Coverage Diff @@
## main #1483 +/- ##
==========================================
+ Coverage 79.05% 79.30% +0.25%
==========================================
Files 162 162
Lines 8454 8495 +41
==========================================
+ Hits 6683 6737 +54
+ Misses 1085 1076 -9
+ Partials 686 682 -4
Continue to review full report at Codecov.
|
/retest |
@vyasgun the test should be OK now, minus |
thanks, @dsimansk! |
pkg/kn/traffic/compute.go
Outdated
return nil | ||
} | ||
} | ||
return errorTrafficDistribution() |
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 this error be tested as well pls?
pkg/kn/traffic/compute.go
Outdated
} | ||
if sum < 100 && revPercents == revisionCount-1 { | ||
if latestNameFound { | ||
return errorTrafficDistribution() |
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.
Maybe the error could accept a reason param? Just an idea to better explain the failure.
In addition to the above comments E2E tests with the change would be great. And there should be an example added to showcase the usage. E.g. https://github.com/knative/client/blob/main/docs/cmd/kn_service_update.md#examples |
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 contribution and for adding lots of tests. However, no integration tests. Perhaps adding some could reduce your unit tests and also make it easier to verify this feature? Might worth a try.
/ok-to-test
pkg/kn/traffic/compute.go
Outdated
@@ -260,18 +271,42 @@ func verifyInput(trafficFlags *flags.Traffic) error { | |||
sum += percentInt | |||
} | |||
|
|||
revPercents := len(trafficFlags.RevisionsPercentages) |
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.
Maybe leave a comment here since not obvious that the length of the array is the revPercents
// verifies if user has repeated @latest field in --tag or --traffic flags | ||
// verifyInput checks: | ||
// - if user has repeated @latest field in --tag or --traffic flags | ||
// - if provided traffic portion are integers | ||
func verifyInput(trafficFlags *flags.Traffic) error { | ||
func verifyInput(trafficFlags *flags.Traffic, revisions []servingv1.Revision) error { |
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 would split this function into smaller private functions. That might make it easier to parse and comprehend. For instance there’s logical helper functions that could be extracted around each of the for
loops… as an example
[]string{"@latest"}, | ||
[]string{"latest"}, | ||
[]int64{100}, | ||
name: "assign 'latest' tag to @latest revision", |
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.
Add some comment to explain the “matrix” of tests you are doing with the big structure below. This would explain why you have x numbers of tests and what the differences between the tests
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.
Thank you for the review. This test matrix was already present. The change is to include the field names which weren't there before (modified because of the new field existingRevisions
being added to the struct)
append(newServiceTraffic([]servingv1.TrafficTarget{}), newTarget("", "", 100, true)), | ||
[]string{"--tag", "@latest="}, | ||
"expecting the value format in value1=value2, given @latest=", | ||
name: "repeatedly tagging to @latest revision not allowed", |
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.
Same comment as above to add some summary comment to explain the different tests in the array…
pkg/kn/commands/service/update.go
Outdated
kn service update gitopstest --env KEY1=VALUE1 --target=/user/knfiles/test.json | ||
|
||
|
||
# Split 50% traffic to stable, 40% traffic to staging and the |
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'd move it above the "offline" mode example to make it appear as a follow-up to the above examples.
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.
Moved it, thanks
/retest |
Thanks, looks good to me now. :) /lgtm |
Co-authored-by: Navid Shaikh <[email protected]>
Co-authored-by: Navid Shaikh <[email protected]>
1e04682
to
30801ee
Compare
The following is the coverage report on the affected files.
|
Since all the review comments are addressed, lets get it in. :) Thanks! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dsimansk, vyasgun The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
/retest |
Description
Changes
@latest
is specified, cannot determine the split unless it sums to 100Reference
Fixes #