Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

[kn-admin]Add support to enable or disable scale-to-zero #26

Merged
merged 1 commit into from
Jun 4, 2020

Conversation

zhanggbj
Copy link

@zhanggbj zhanggbj commented May 4, 2020

User Story: As a Knative administrator, I want to enable and disable scale to zero for Knative platform.

It might be desirable for Knative admins to enable or disable scale-to-zero for a specific Knative installation frequently, which is also discussed in #18. The kn-admin plugin will enable/disable this feature via the CLI instead of modifying ConfigMap. We can use this PR for further discussion on it. Thanks!

Note: please merge PR #25 first and then I'll rebase this one on it.

PR:

  • Init autoscaling subcommand
  • support scale-to-zero config

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label May 4, 2020
@knative-prow-robot knative-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 4, 2020
@zhanggbj zhanggbj changed the title Add support to enable or disable scale-to-zero [kn-admin]Add support to enable or disable scale-to-zero May 5, 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 for me, but in order to provide a smooth UX we should stick to the convention to use --no-autoscale-to-zero and --scale-to-zero for the true/false values.

There is some specific handling for this in the client, and I wonder whether we should move our 'special' handling of option into a reusable library (like also how to deal with maps + arrays)

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.

  1. missing unset
  2. missing unit tests
  3. missing integration tests

plugins/admin/core/root.go Outdated Show resolved Hide resolved
plugins/admin/pkg/command/autoscaling/autoscaling.go Outdated Show resolved Hide resolved
plugins/admin/pkg/command/autoscaling/set.go Outdated Show resolved Hide resolved
@zhanggbj
Copy link
Author

Thanks for your code review!

@rhuss Thanks for point it out. I'll refine this PR to follow the same UX with cli to use --scale-to-zero and --no-scale-to-zero.

@maximilien Same with above will refine it^^ for unset. And I'm working on another item to fill up UT and e2e test #14. So for the future PR, will raise them with test files.

@knative-prow-robot knative-prow-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 10, 2020
@zhanggbj zhanggbj force-pushed the scale-to-zero branch 2 times, most recently from e4575da to 88500a5 Compare May 10, 2020 09:44
@zhanggbj
Copy link
Author

All comments addressed, it's ready for review, thanks!

k8s.io/api v0.17.4
k8s.io/apimachinery v0.17.4
k8s.io/client-go v0.17.4
knative.dev/client v0.14.0
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need a dependency on knative.dev/client ?

Copy link
Author

Choose a reason for hiding this comment

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

@rhuss
I noticed there's a method in knative.dev/client to create flags like --scale-to-zero and --no-scale-to-zero, so reused it.

flags.AddBothBoolFlagsUnhidden

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is ok for now but for the long run we should extract the parts that can be reused by plugins within the client into at least a dedicated package. Because the client coders will not be aware that this method is used by anybody outside the client itself, so its very likely that this can be changed by a refactoring or by accident.

@zhanggbj
Copy link
Author

Hi @rhuss @maximilien,

All comments addressed, would you please help to review again, thanks!

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.

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label May 20, 2020
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label May 22, 2020
@zhanggbj
Copy link
Author

will wait for #14 to add more UT and e2e test

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 28, 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 May 31, 2020
- Init autoscaling subcommand
- Support scale-to-zero config
- Update examples in README
Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

Produced via:
gofmt -s -w $(find -path './vendor' -prune -o -path './third_party' -prune -o -type f -name '*.go' -print)


import (
"errors"
"fmt"
Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change
"fmt"
"fmt"


})
}

Copy link
Member

Choose a reason for hiding this comment

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

Format Go code:

Suggested change

@zhanggbj
Copy link
Author

zhanggbj commented Jun 2, 2020

As @rhuss have approved it and I filled up UT just now, @rhuss @maximilien would you please help to take a review, thanks!

@knative-prow-robot
Copy link

@zhanggbj: you cannot LGTM your own PR.

In response to this:

As @rhuss have added lgtm and I filled up UT later, so I'll merge it.
/lgtm

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.

@zhanggbj
Copy link
Author

zhanggbj commented Jun 4, 2020

Hi @rhuss @maximilien ,

Would you please help to take a review, the last update is to fill up UT, thank you!

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 for me now, let's get it merged.

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhuss, 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:

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 f207c1f into knative:master Jun 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants