-
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
[WIP] Added range options to --scale #986
Conversation
Work in Progress. Plan on adding a helper function + more tests: Test 0..5 |
/ok-to-test Ready for some reviews @mpetason? |
Not ready for a review yet. I need to cleanup the range section and create a helper function. Right now it's just in an "it works" status and I wanted to show some work. |
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.
Some initial feedback. Also, make sure to add a e2e test.
docs/cmd/kn_service_create.md
Outdated
@@ -86,7 +86,7 @@ kn service create NAME --image IMAGE | |||
--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 Minimum and maximum number of replicas. | |||
--scale string Minimum and maximum number of replicas. Example: --scale 5 or --scale 1..5 or --scale 1.. or --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.
What does it mean to do —scale ..5 (up to five?). Maybe lets be clear with text...
@@ -82,7 +83,7 @@ func (p *ConfigurationEditFlags) addSharedFlags(command *cobra.Command) { | |||
command.Flags().MarkHidden("max-scale") | |||
p.markFlagMakesRevision("max-scale") | |||
|
|||
command.Flags().IntVar(&p.Scale, "scale", 0, "Minimum and maximum number of replicas.") | |||
command.Flags().StringVar(&p.Scale, "scale", "", "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.
Is “” a valid value? Perhaps use default?
if err != nil { | ||
return err | ||
if !strings.Contains(p.Scale, "..") { | ||
scaleInt, _ := strconv.Atoi(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.
Why are you ignoring the Atoi(...)
error? Just catch and check it
} | ||
} else if len(p.Scale) == 4 { | ||
scaleParts := strings.Split(p.Scale, "..") | ||
scaleMin, _ := strconv.Atoi(scaleParts[0]) |
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 here... don’t ignore errors
OK, sorry. I'll do another pass when ready. Just tag me and remove the WIP label. Cheers 🍻 |
fyi, the fix for the failing CI is included as part of #902 |
/retest |
Wonder if this is a flake /test pull-knative-client-build-tests |
@mpetason you would need to recreate the docs via |
@rhuss will do. I should have an update for this today. |
Still WIP, need to update tests and fix how I'm checking for errors. |
This pull request introduces 1 alert when merging f9e53d5 into c801e82 - view on LGTM.com new alerts:
|
@maximilien @rhuss I think I'm ready for a review now. I need to update the docs (reverted back with the last build), but would like some pointers on changes I can make to the code/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 contributions. I think this PR looks good generally. I just left a few comments.
@@ -82,7 +84,7 @@ func (p *ConfigurationEditFlags) addSharedFlags(command *cobra.Command) { | |||
command.Flags().MarkHidden("max-scale") | |||
p.markFlagMakesRevision("max-scale") | |||
|
|||
command.Flags().IntVar(&p.Scale, "scale", 0, "Minimum and maximum number of replicas.") | |||
command.Flags().StringVar(&p.Scale, "scale", "1", "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 suggest to add a sample at the end of the explanation, e.g.
Minimum and maximum number of replicas. (e.g., 1..5).
in order to help end users understand the format clearly.
@@ -480,3 +486,32 @@ func (p *ConfigurationEditFlags) AnyMutation(cmd *cobra.Command) bool { | |||
} | |||
return false | |||
} | |||
|
|||
func (p *ConfigurationEditFlags) ScaleConversion(scale string) (scaleMin int, scaleMax int, err 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.
Do you want the method ScaleConversion
to be visible outside package? If the method is not used by any other packages, I suggest to change the method name to start with a lower case letter, e.g. scaleConversion
/restest |
I didn't rebase this correctly and have no clue how to fix it. I guess I need to close/delete this PR and try again? |
The following is the coverage report on the affected files.
|
@mpetason: PR needs rebase. 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. |
1 similar comment
@mpetason: PR needs rebase. 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. |
Can't figure out how to fix the issue where there are so many files added. Tried a rebase but it doesn't look like that helped. Going to close this out for good and open a new PR with the same work. |
Fixed issues related to reviews and cleaned up some of the logic Removed error checking - will add back after more updates Ran build to update docs/created a helper script Updated helper function/cleaned it up and resolved failing tests Added checks for non ".." values and added more tests Updated wording and scaleconversion Added range options to --scale Fixed issues related to reviews and cleaned up some of the logic Removed error checking - will add back after more updates Ran build to update docs/created a helper script Updated helper function/cleaned it up and resolved failing tests Added checks for non ".." values and added more tests Updated wording and scaleconversion Added range options to --scale Fixed issues related to reviews and cleaned up some of the logic Ran build to update docs/created a helper script Updated helper function/cleaned it up and resolved failing tests Updated wording and scaleconversion Added range options to --scale Fixed issues related to reviews and cleaned up some of the logic Removed error checking - will add back after more updates Ran build to update docs/created a helper script Updated helper function/cleaned it up and resolved failing tests Added checks for non ".." values and added more tests Updated wording and scaleconversion Added comment about the helper function
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mpetason The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@mpetason: The following tests failed, say
Full PR test history. Your PR dashboard. 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. I understand the commands that are listed here. |
Figured out how to clean this up after rebase. I'm probably going to close this out and re-open since I'm still running into conflicts with the command information files. |
Description
Adds range options to --scale.
Changes
Reference
Fixes #822