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

add autoscaling list command #17

Closed
wants to merge 6 commits into from

Conversation

chaozbj
Copy link
Contributor

@chaozbj chaozbj commented Nov 12, 2020

The issue is: #15
here is an example of output:

12:00 ➜ ~/Workspace/code/github.com/kn-plugin-admin/cmd [chao-15 ✘] ./cmd autoscaling list
NAME                         VALUE
enable-scale-to-zero         false
max-scale-down-rate          3
panic-threshold-percentage   100

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Nov 12, 2020
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 12, 2020
Copy link

@zhanggbj zhanggbj left a comment

Choose a reason for hiding this comment

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

@chaozbj it's good to add at least one e2e test case for autoscaling list in test/e2e/kn_admin_test.go, thanks!

Copy link

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

Couple comments. Also need e2e tests. These are the best :)

Otherwise LGTM

currentCm := &corev1.ConfigMap{}
currentCm, err := p.ClientSet.CoreV1().ConfigMaps(knativeServing).Get(configAutoscaler, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get ConfigMaps: %+v", err)

Choose a reason for hiding this comment

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

I wonder if putting the error message here will be useful to user?

func TestAutoscalingListEmpty(t *testing.T) {
t.Run("no flags", func(t *testing.T) {
cm := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{

Choose a reason for hiding this comment

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

Maybe when it’s empty the result should be “No autoscaling info available” or similar instead of a list with headers...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @maximilien, I will improve the output for empty configs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maximilien and @zhanggbj Thanks, for e2e test case, yes, I missed it, I will add, but I saw @zhanggbj added the test function for autoscaling func (et *e2eTest) knAdminAutoscaling(t *testing.T, r *test.KnRunResultCollector) in her RP #16 , I think I should wait the PR to deliver first and then modify the same function to add tests for list command or I can add it later.

Copy link

@zhanggbj zhanggbj Nov 20, 2020

Choose a reason for hiding this comment

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

@chaozbj make sense, so let's wait #16 merge first and then you can rebase and add e2e in this PR then.

@knative-prow-robot knative-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Nov 18, 2020
@zhanggbj
Copy link

/hold
wait for #16 to merge first.

@zhanggbj
Copy link

/unhold
#16 is merged, please help to rebase and finish this PR, thanks!

@knative-prow-robot knative-prow-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 27, 2020
@chaozbj
Copy link
Contributor Author

chaozbj commented Nov 30, 2020

@zhanggbj @maximilien Changes as below:

  1. Following knative/client v0.17 to update go.mod because I want to use autoscaler.Config.ScaleToZeroPodRetentionPeriod field which is introduced from knative/serving v0.15.

    I didn't follow the knative/client v0.18 or v0.19 to update go.mod since I got compiling error when I use k8s.io/apimachinery >= v0.18, there is an interface changed from v0.18(maybe from earlier version):

    ../pkg/command/utils/utils.go:27:72: not enough arguments in call to client.CoreV1().ConfigMaps(desiredCm.ObjectMeta.Namespace).Get
    have (string, "k8s.io/apimachinery/pkg/apis/meta/v1".GetOptions)
    want (context.Context, string, "k8s.io/apimachinery/pkg/apis/meta/v1".GetOptions)

    We need to change our codes if we want to adopt it, but I don't want to address them in this PR, so I choosed the older version to use.

  2. Always list all values for autoscaler configs, if the config is changed by user, the user's value will be printed, otherwise the default value will be printed. I called autoscalerconfig.NewConfigFromMap(map[string]string) defined in knative/serving to build configs with default value, that is why I need to update go.mod.

  3. Updated unit test codes for new changes.

  4. Added e2e test case for autoscaling list command.

  5. A minor change for release.sh, using -mod=readonly to replace-mod=vendor because we don't use vendor now.

Please help me to review, thanks!

cmd/release.sh Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
@zhanggbj
Copy link

@chaozbj Thanks Chao for the efforts! In general, the changes look good to me,

For 1) Let's finish the dependency bump firstly in PR #21, we need it to build release 0.1.0, this will also resolve the issue you mentioned.

For 5) I think ./hack/xx is more proper for some scripts and tools like release.sh

@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 3, 2020
@chaozbj
Copy link
Contributor Author

chaozbj commented Dec 3, 2020

@zhanggbj I rebased it from PR #25 and also deleted release.sh script because I found that hack/build.sh can do the same thing. Please help me review, thanks!

@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chaozbj, maximilien, zhanggbj

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:
  • OWNERS [maximilien,zhanggbj]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zhanggbj
Copy link

zhanggbj commented Dec 3, 2020

/lgtm
Look nice and merging! Thanks @chaozbj!

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 3, 2020
@zhanggbj
Copy link

zhanggbj commented Dec 3, 2020

Prow tests are failing due to test-infra setting in progress which is covered by #24

/usr/local/bin/kubekins-runner.sh: line 104: ./test/presubmit-tests.sh: No such file or directory

Copy link

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

Tests still failing
/retest

@navidshaikh
Copy link
Contributor

/test all

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 4, 2020
@zhanggbj
Copy link

zhanggbj commented Dec 4, 2020

/retest

@zhanggbj
Copy link

zhanggbj commented Dec 4, 2020

/lgtm cancel

@chaozbj would you please help to rebase first. Just merged Navid's PR for test infra.

@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Dec 4, 2020
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 4, 2020
@chaozbj
Copy link
Contributor Author

chaozbj commented Dec 4, 2020

/retest

1 similar comment
@chaozbj
Copy link
Contributor Author

chaozbj commented Dec 4, 2020

/retest

@navidshaikh
Copy link
Contributor

navidshaikh commented Dec 4, 2020

@chaozbj : there is a verify codegen step now part of the build tests,


ERROR: /home/prow/go/src/knative.dev/kn-plugin-admin is out of date. Please run ./hack/build.sh -c and commit.
--

please run ./hack/build.sh and commit the changes

@knative-prow-robot
Copy link

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

Test name Commit Details Rerun command
pull-knative-sandbox-kn-plugin-admin-build-tests 4e4a2b4 link /test pull-knative-sandbox-kn-plugin-admin-build-tests
pull-knative-sandbox-kn-plugin-admin-integration-tests 4e4a2b4 link /test pull-knative-sandbox-kn-plugin-admin-integration-tests

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.

@chaozbj
Copy link
Contributor Author

chaozbj commented Dec 4, 2020

close it and will create a new PR for autoscaling list command

@chaozbj chaozbj closed this Dec 4, 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. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants