Skip to content
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

Merged
merged 8 commits into from
Jul 11, 2020

Conversation

mpetason
Copy link
Contributor

@mpetason mpetason commented Jul 2, 2020

Description

This allows a user to set --scale which will update MinScale and MaxScale to the same value.

Changes

  • add --scale as a CLI option

Reference

#822

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 2, 2020
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 2, 2020
@mpetason
Copy link
Contributor Author

mpetason commented Jul 2, 2020

/retest

Copy link
Contributor

@maximilien maximilien left a 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.

@@ -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.
Copy link
Contributor

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?

Copy link
Contributor

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"

Copy link
Contributor Author

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") {
Copy link
Contributor

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")
Copy link
Contributor

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.

Copy link
Collaborator

@navidshaikh navidshaikh left a 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?

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 7, 2020
Copy link
Contributor

@rhuss rhuss left a 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.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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",
Copy link
Contributor

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)

Copy link
Contributor

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.

Copy link
Contributor

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)

Copy link
Contributor Author

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"})
Copy link
Contributor

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

Copy link
Contributor

@rhuss rhuss left a 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)
Copy link
Contributor

@rhuss rhuss Jul 7, 2020

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.

Copy link
Contributor Author

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.

@mpetason
Copy link
Contributor Author

mpetason commented Jul 7, 2020

@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.

@mpetason
Copy link
Contributor Author

mpetason commented Jul 7, 2020

Still work in progress. I need to address the @maximilien issue + testing.

@knative-prow-robot knative-prow-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 8, 2020
@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 8, 2020
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 9, 2020
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/kn/commands/service/configuration_edit_flags.go 84.6% 85.0% 0.4

@mpetason
Copy link
Contributor Author

I think I have addressed all of the comments/change requests. Ready for another review.

Copy link
Contributor

@maximilien maximilien left a 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

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 10, 2020
@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 10, 2020
Copy link
Contributor

@rhuss rhuss left a 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

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 11, 2020
@knative-prow-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot merged commit e1c48e6 into knative:master Jul 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants