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

[WIP] Added range options to --scale #986

Closed
wants to merge 2 commits into from
Closed

[WIP] Added range options to --scale #986

wants to merge 2 commits into from

Conversation

mpetason
Copy link
Contributor

Description

Adds range options to --scale.

Changes

  • Adds three more options to --scale (1..5, 1.., ..5)

Reference

Fixes #822

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Aug 20, 2020
@mpetason
Copy link
Contributor Author

mpetason commented Aug 20, 2020

Work in Progress. Plan on adding a helper function + more tests:

Test 0..5
Test 0..
Test ..0
Test 1,,5 (using incorrect separation)

@mpetason mpetason changed the title Added range options to --scale [WIP] Added range options to --scale Aug 20, 2020
@maximilien
Copy link
Contributor

/ok-to-test

Ready for some reviews @mpetason?

@knative-prow-robot knative-prow-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Aug 20, 2020
@mpetason
Copy link
Contributor Author

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.

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.

Some initial feedback. Also, make sure to add a e2e test.

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

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

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

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

@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 21, 2020
@maximilien
Copy link
Contributor

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.

OK, sorry. I'll do another pass when ready. Just tag me and remove the WIP label. Cheers 🍻

@rhuss
Copy link
Contributor

rhuss commented Aug 25, 2020

fyi, the fix for the failing CI is included as part of #902

@rhuss
Copy link
Contributor

rhuss commented Aug 25, 2020

/retest

@maximilien
Copy link
Contributor

Wonder if this is a flake

/test pull-knative-client-build-tests

@rhuss
Copy link
Contributor

rhuss commented Sep 1, 2020

@mpetason you would need to recreate the docs via build.sh and commit the generated/updated markdown files

@mpetason
Copy link
Contributor Author

mpetason commented Sep 1, 2020

@rhuss will do. I should have an update for this today.

@mpetason
Copy link
Contributor Author

mpetason commented Sep 1, 2020

Still WIP, need to update tests and fix how I'm checking for errors.

@lgtm-com
Copy link

lgtm-com bot commented Sep 2, 2020

This pull request introduces 1 alert when merging f9e53d5 into c801e82 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

@mpetason
Copy link
Contributor Author

mpetason commented Sep 2, 2020

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

Copy link
Member

@daisy-ycguo daisy-ycguo left a 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.")
Copy link
Member

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

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

@mpetason
Copy link
Contributor Author

/restest

@knative-prow-robot knative-prow-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ 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 Sep 16, 2020
@mpetason
Copy link
Contributor Author

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?

@mpetason mpetason closed this Sep 21, 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 83.2% 83.4% 0.2

@mpetason mpetason reopened this Oct 1, 2020
@knative-prow-robot knative-prow-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 1, 2020
@knative-prow-robot
Copy link
Contributor

@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
@knative-prow-robot
Copy link
Contributor

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

@mpetason
Copy link
Contributor Author

mpetason commented Oct 1, 2020

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.

@mpetason mpetason closed this Oct 1, 2020
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
@mpetason mpetason reopened this Oct 7, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mpetason
To complete the pull request process, please assign sixolet after the PR has been reviewed.
You can assign the PR to them by writing /assign @sixolet in a comment when ready.

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

@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 7, 2020
@knative-prow-robot
Copy link
Contributor

@mpetason: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-knative-client-integration-tests-latest-release 0bc3b80 link /test pull-knative-client-integration-tests-latest-release
pull-knative-client-unit-tests 0bc3b80 link /test pull-knative-client-unit-tests
pull-knative-client-build-tests 0bc3b80 link /test pull-knative-client-build-tests
pull-knative-client-integration-tests 0bc3b80 link /test pull-knative-client-integration-tests
pull-knative-client-go-coverage 0bc3b80 link /test pull-knative-client-go-coverage

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.

@mpetason
Copy link
Contributor Author

mpetason commented Oct 7, 2020

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.

@mpetason mpetason closed this Oct 15, 2020
@mpetason mpetason deleted the issue-822-pt3 branch October 22, 2020 15:31
@mpetason mpetason restored the issue-822-pt3 branch October 22, 2020 15:31
@mpetason mpetason deleted the issue-822-pt3 branch October 22, 2020 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indicates the PR's author has signed the CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

support --scale
7 participants