-
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
Added the option to use --scale for setting MinScale and MaxScale to the same value #914
Conversation
/retest |
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.
At least address the e2e test change and the coverage if possible. Thanks.
docs/cmd/kn_service_update.md
Outdated
@@ -71,6 +71,7 @@ kn service update NAME | |||
--requests-cpu string DEPRECATED: please use --request instead. The requested CPU (e.g., 250m). | |||
--requests-memory string DEPRECATED: please use --request instead. The requested memory (e.g., 64Mi). | |||
--revision-name string The revision name to set. Must start with the service name and a dash as a prefix. Empty revision name will result in the server generating a name for the revision. Accepts golang templates, allowing {{.Service}} for the service name, {{.Generation}} for the generation, and {{.Random [n]}} for n random consonants. (default "{{.Service}}-{{.Random 5}}-{{.Generation}}") | |||
--scale int Minimal and Maximal number of replicas. |
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.
Wonder if “Minimum” and “maximum” are better words here?
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 I look at the result of Google hits for "minimum number" and "minimal number"). Also please use lower case, something like
"Minimum and maximum number of replicas"
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 had "Set min and max scale as the same value" but something recommended those changes when I submitted the first PR? I'll make this update.
@@ -434,6 +438,17 @@ func (p *ConfigurationEditFlags) Apply( | |||
} | |||
} | |||
|
|||
if cmd.Flags().Changed("scale") { |
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 can comment lines 443-445 and/or lines 447-449 and all tests still pass.
This tells me you don’t have tests for servinglib.UpdateMaxScale(...)
and servinglib.UpdateMinScale(...)
failings. Might be easy to cover with a test with negative or 0 scale (perhaps).
@@ -72,6 +72,11 @@ func TestServiceOptions(t *testing.T) { | |||
validateServiceMinScale(r, "svc2", "1") | |||
validateServiceMaxScale(r, "svc2", "3") | |||
|
|||
t.Log("create and validate service with scale options ") | |||
serviceCreateWithOptions(r, "svc2a", "--scale", "5") |
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 wonder if you want to try to change scale value for both direction up and down... Thanks.
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.
@mpetason : single value input works fine, do you plan to add range support or in a separate PR?
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 good, thanks !
However, I don't think it fixes #822 as it only covers the case when you want to set max == min, but #822 also discusses to allow to specify the full range with only --scale
(so that we can deprecate --min-scale
and --max-scale
later).
Happy to merge this now (as the PR implements a subset of the full solution), but then we should open another issue for tracking the extended syntax.
@@ -185,6 +186,9 @@ func (p *ConfigurationEditFlags) addSharedFlags(command *cobra.Command) { | |||
command.Flags().IntVar(&p.MaxScale, "max-scale", 0, "Maximal number of replicas.") | |||
p.markFlagMakesRevision("max-scale") | |||
|
|||
command.Flags().IntVar(&p.Scale, "scale", 0, "Minimal and Maximal number of replicas.") |
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.
command.Flags().IntVar(&p.Scale, "scale", 0, "Minimal and Maximal number of replicas.") | |
command.Flags().IntVar(&p.Scale, "scale", 0, "Minimum and maximum number of replicas.") |
action, created, _, err := fakeServiceCreate([]string{ | ||
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", | ||
"--scale", "5", | ||
"--concurrency-target", "10", "--concurrency-limit", "100", |
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.
Why are these options important here ? I would just focus on --scale
to make this test more focussed and easier to maintain (e.g. when something around concurrency-target would change in the future)
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.
As mentioned by @maximilien you should also add a test for the error case, i.e. when --scale
is negative.
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.
And also a test for what happens when --scale
and --min-scale
& --max-scale
are all provided (the more specific options should take precedence or an error should be thrown if both set of options are used)
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 will make these updates. This was just copying the test for min/max scale above it.
|
||
action, updated, _, err := fakeServiceUpdate(original, []string{ | ||
"service", "update", "foo", | ||
"--scale", "5", "--concurrency-target", "10", "--concurrency-limit", "100", "--concurrency-utilization", "50", "--no-wait"}) |
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 as above, please only test for --scale
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.
Please update the test and wording of the CLI option.
@@ -434,6 +438,17 @@ func (p *ConfigurationEditFlags) Apply( | |||
} | |||
} | |||
|
|||
if cmd.Flags().Changed("scale") { | |||
err = servinglib.UpdateMaxScale(template, p.Scale) |
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.
What is if --max-scale
is also given on the command line ? Which one takes precedence ? Or should an error be thrown ?
IMO we should return an error if both --scale
and either --min-scale
or --max-scale
is provided.
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 need to add this functionality and also tests for it.
@rhuss this doesn't "fix" the other issue, but I'm not sure how to remove the "fixes" unless I can just edit the comment. I will update this to range in another PR, just wanted to get the functionality in and learn how the client works with this PR. |
Still work in progress. I need to address the @maximilien issue + testing. |
The following is the coverage report on the affected files.
|
I think I have addressed all of the comments/change requests. Ready for another review. |
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.
Overall looks good to me. Holding to give others a chance to review of unhold
/hold
/lgtm
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 !
/lgtm
/unhold
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mpetason, navidshaikh, rhuss 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 |
Description
This allows a user to set --scale which will update MinScale and MaxScale to the same value.
Changes
Reference
#822