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

Rename --concurrency-target and --concurrency-utilization #1490

Merged
merged 2 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
| Deprecate `--autoscale-window` in favor of `--scale-window`
| https://github.com/knative/client/pull/1454[#1454]

| ✨
| Deprecate `--concurrency-target` and `--concurrency-utilization` in favor of `--scale-target` and `--scale-utilization`, respectively
| https://github.com/knative/client/pull/1454[#1454]
|===

## v0.26.0 (2021-09-22)
Expand Down
6 changes: 4 additions & 2 deletions docs/cmd/kn_service_apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ kn service apply s0 --filename my-svc.yml
--cluster-local Specify that the service be private. (--no-cluster-local will make the service publicly available)
--cmd stringArray Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd sh --cmd /app/start.sh or --cmd /app/start --arg myArg to pass additional arguments.
--concurrency-limit int Hard Limit of concurrent requests to be processed by a single replica.
--concurrency-target int Recommendation for when to scale up based on the concurrent number of incoming request. Defaults to --concurrency-limit when given.
--concurrency-utilization int Percentage of concurrent requests utilization before scaling up. (default 70)
--concurrency-target int Deprecated, use --scale-target instead.
--concurrency-utilization int Deprecated, use --scale-utilization instead. (default 70)
-e, --env stringArray Environment variable to set. NAME=value; you may provide this flag any number of times to set multiple environment variables. To unset, specify the environment variable name followed by a "-" (e.g., NAME-).
--env-file string Path to a file containing environment variables (e.g. --env-file=/home/knative/service1/env).
--env-from stringArray Add environment variables from a ConfigMap (prefix cm: or config-map:) or a Secret (prefix secret:). Example: --env-from cm:myconfigmap or --env-from secret:mysecret. You can use this flag multiple times. To unset a ConfigMap/Secret reference, append "-" to the name, e.g. --env-from cm:myconfigmap-.
Expand Down Expand Up @@ -66,6 +66,8 @@ kn service apply s0 --filename my-svc.yml
--scale-init int Initial number of replicas with which a service starts. Can be 0 or a positive integer.
--scale-max int Maximum number of replicas.
--scale-min int Minimum number of replicas.
--scale-target int Recommendation for when to scale up based on the concurrent number of incoming request. Defaults to --concurrency-limit when given.
--scale-utilization int Percentage of concurrent requests utilization before scaling up. (default 70)
--scale-window string Duration to look back for making auto-scaling decisions. The service is scaled to zero if no request was received in during that time. (eg: 10s)
--service-account string Service account name to set. An empty argument ("") clears the service account. The referenced service account must exist in the service's namespace.
--user int The user ID to run the container (e.g., 1001).
Expand Down
6 changes: 4 additions & 2 deletions docs/cmd/kn_service_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ kn service create NAME --image IMAGE
--cluster-local Specify that the service be private. (--no-cluster-local will make the service publicly available)
--cmd stringArray Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd sh --cmd /app/start.sh or --cmd /app/start --arg myArg to pass additional arguments.
--concurrency-limit int Hard Limit of concurrent requests to be processed by a single replica.
--concurrency-target int Recommendation for when to scale up based on the concurrent number of incoming request. Defaults to --concurrency-limit when given.
--concurrency-utilization int Percentage of concurrent requests utilization before scaling up. (default 70)
--concurrency-target int Deprecated, use --scale-target instead.
--concurrency-utilization int Deprecated, use --scale-utilization instead. (default 70)
-e, --env stringArray Environment variable to set. NAME=value; you may provide this flag any number of times to set multiple environment variables. To unset, specify the environment variable name followed by a "-" (e.g., NAME-).
--env-file string Path to a file containing environment variables (e.g. --env-file=/home/knative/service1/env).
--env-from stringArray Add environment variables from a ConfigMap (prefix cm: or config-map:) or a Secret (prefix secret:). Example: --env-from cm:myconfigmap or --env-from secret:mysecret. You can use this flag multiple times. To unset a ConfigMap/Secret reference, append "-" to the name, e.g. --env-from cm:myconfigmap-.
Expand Down Expand Up @@ -91,6 +91,8 @@ kn service create NAME --image IMAGE
--scale-init int Initial number of replicas with which a service starts. Can be 0 or a positive integer.
--scale-max int Maximum number of replicas.
--scale-min int Minimum number of replicas.
--scale-target int Recommendation for when to scale up based on the concurrent number of incoming request. Defaults to --concurrency-limit when given.
--scale-utilization int Percentage of concurrent requests utilization before scaling up. (default 70)
--scale-window string Duration to look back for making auto-scaling decisions. The service is scaled to zero if no request was received in during that time. (eg: 10s)
--service-account string Service account name to set. An empty argument ("") clears the service account. The referenced service account must exist in the service's namespace.
--target string Work on local directory instead of a remote cluster (experimental)
Expand Down
6 changes: 4 additions & 2 deletions docs/cmd/kn_service_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ kn service update NAME
--cluster-local Specify that the service be private. (--no-cluster-local will make the service publicly available)
--cmd stringArray Specify command to be used as entrypoint instead of default one. Example: --cmd /app/start or --cmd sh --cmd /app/start.sh or --cmd /app/start --arg myArg to pass additional arguments.
--concurrency-limit int Hard Limit of concurrent requests to be processed by a single replica.
--concurrency-target int Recommendation for when to scale up based on the concurrent number of incoming request. Defaults to --concurrency-limit when given.
--concurrency-utilization int Percentage of concurrent requests utilization before scaling up. (default 70)
--concurrency-target int Deprecated, use --scale-target instead.
--concurrency-utilization int Deprecated, use --scale-utilization instead. (default 70)
-e, --env stringArray Environment variable to set. NAME=value; you may provide this flag any number of times to set multiple environment variables. To unset, specify the environment variable name followed by a "-" (e.g., NAME-).
--env-file string Path to a file containing environment variables (e.g. --env-file=/home/knative/service1/env).
--env-from stringArray Add environment variables from a ConfigMap (prefix cm: or config-map:) or a Secret (prefix secret:). Example: --env-from cm:myconfigmap or --env-from secret:mysecret. You can use this flag multiple times. To unset a ConfigMap/Secret reference, append "-" to the name, e.g. --env-from cm:myconfigmap-.
Expand All @@ -74,6 +74,8 @@ kn service update NAME
--scale-init int Initial number of replicas with which a service starts. Can be 0 or a positive integer.
--scale-max int Maximum number of replicas.
--scale-min int Minimum number of replicas.
--scale-target int Recommendation for when to scale up based on the concurrent number of incoming request. Defaults to --concurrency-limit when given.
--scale-utilization int Percentage of concurrent requests utilization before scaling up. (default 70)
--scale-window string Duration to look back for making auto-scaling decisions. The service is scaled to zero if no request was received in during that time. (eg: 10s)
--service-account string Service account name to set. An empty argument ("") clears the service account. The referenced service account must exist in the service's namespace.
--tag strings Set tag (format: --tag revisionRef=tagName) where revisionRef can be a revision or '@latest' string representing latest ready revision. This flag can be specified multiple times.
Expand Down
2 changes: 1 addition & 1 deletion docs/operations/autoscaling.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ flags to configure the autoscaling behavior.
| Flag | Description |
| :------------------------- | :-------------------------------------------------------------------------------------------------------------------------- |
| `--concurrency-limit int` | Hard limit of concurrent requests to be processed by a single replica. |
| `--concurrency-target int` | Recommendation for when to scale up based on the concurrent number of incoming requests. Defaults to `--concurrency-limit`. |
| `--scale-target int` | Recommendation for when to scale up based on the concurrent number of incoming requests. Defaults to `--concurrency-limit`. |
| `--scale-max int` | Maximum number of replicas. |
| `--scale-min int` | Minimum number of replicas. |
58 changes: 34 additions & 24 deletions pkg/kn/commands/service/configuration_edit_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ type ConfigurationEditFlags struct {
PodSpecFlags knflags.PodSpecFlags

// Direct field manipulation
Scale string
MinScale int
MaxScale int
ConcurrencyTarget int
ConcurrencyLimit int
ConcurrencyUtilization int
ScaleWindow string
Labels []string
LabelsService []string
LabelsRevision []string
RevisionName string
Annotations []string
AnnotationsService []string
AnnotationsRevision []string
ClusterLocal bool
ScaleInit int
Scale string
MinScale int
MaxScale int
ScaleTarget int
ConcurrencyLimit int
ScaleUtilization int
ScaleWindow string
Labels []string
LabelsService []string
LabelsRevision []string
RevisionName string
Annotations []string
AnnotationsService []string
AnnotationsRevision []string
ClusterLocal bool
ScaleInit int

// Preferences about how to do the action.
LockToDigest bool
Expand Down Expand Up @@ -110,19 +110,29 @@ func (p *ConfigurationEditFlags) addSharedFlags(command *cobra.Command) {
knflags.AddBothBoolFlagsUnhidden(command.Flags(), &p.ClusterLocal, "cluster-local", "", false,
"Specify that the service be private. (--no-cluster-local will make the service publicly available)")

command.Flags().IntVar(&p.ConcurrencyTarget, "concurrency-target", 0,
// DEPRECATED since 1.0
command.Flags().IntVar(&p.ScaleTarget, "concurrency-target", 0,
"Deprecated, use --scale-target instead.")
p.markFlagMakesRevision("concurrency-target")

command.Flags().IntVar(&p.ScaleTarget, "scale-target", 0,
"Recommendation for when to scale up based on the concurrent number of incoming request. "+
"Defaults to --concurrency-limit when given.")
p.markFlagMakesRevision("concurrency-target")
p.markFlagMakesRevision("scale-target")

command.Flags().IntVar(&p.ConcurrencyLimit, "concurrency-limit", 0,
"Hard Limit of concurrent requests to be processed by a single replica.")
p.markFlagMakesRevision("concurrency-limit")

command.Flags().IntVar(&p.ConcurrencyUtilization, "concurrency-utilization", 70,
"Percentage of concurrent requests utilization before scaling up.")
// DEPRECATED since 1.0
command.Flags().IntVar(&p.ScaleUtilization, "concurrency-utilization", 70,
"Deprecated, use --scale-utilization instead.")
p.markFlagMakesRevision("concurrency-utilization")

command.Flags().IntVar(&p.ScaleUtilization, "scale-utilization", 70,
"Percentage of concurrent requests utilization before scaling up.")
p.markFlagMakesRevision("scale-utilization")

command.Flags().StringArrayVarP(&p.Labels, "label", "l", []string{},
"Labels to set for both Service and Revision. name=value; you may provide this flag "+
"any number of times to set multiple labels. "+
Expand Down Expand Up @@ -325,8 +335,8 @@ func (p *ConfigurationEditFlags) Apply(
}
}

if cmd.Flags().Changed("concurrency-target") {
err = servinglib.UpdateConcurrencyTarget(template, p.ConcurrencyTarget)
if cmd.Flags().Changed("scale-target") || cmd.Flags().Changed("concurrency-target") {
err = servinglib.UpdateScaleTarget(template, p.ScaleTarget)
if err != nil {
return err
}
Expand All @@ -339,8 +349,8 @@ func (p *ConfigurationEditFlags) Apply(
}
}

if cmd.Flags().Changed("concurrency-utilization") {
err = servinglib.UpdateConcurrencyUtilization(template, p.ConcurrencyUtilization)
if cmd.Flags().Changed("scale-utilization") || cmd.Flags().Changed("concurrency-utilization") {
err = servinglib.UpdateScaleUtilization(template, p.ScaleUtilization)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kn/commands/service/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ func TestServiceCreateMaxMinScale(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz",
"--scale-min", "1", "--scale-max", "5",
"--concurrency-target", "10", "--concurrency-limit", "100",
"--concurrency-utilization", "50",
"--scale-target", "10", "--concurrency-limit", "100",
"--scale-utilization", "50",
"--scale-window", "10s",
"--no-wait"}, false)

Expand Down
2 changes: 1 addition & 1 deletion pkg/kn/commands/service/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ func TestServiceUpdateMaxMinScale(t *testing.T) {

action, updated, _, err := fakeServiceUpdate(original, []string{
"service", "update", "foo",
"--scale-min", "1", "--scale-max", "5", "--concurrency-target", "10", "--concurrency-limit", "100", "--concurrency-utilization", "50", "--no-wait"})
"--scale-min", "1", "--scale-max", "5", "--scale-target", "10", "--concurrency-limit", "100", "--scale-utilization", "50", "--no-wait"})

if err != nil {
t.Fatal(err)
Expand Down
8 changes: 4 additions & 4 deletions pkg/serving/config_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ func UpdateScaleWindow(template *servingv1.RevisionTemplateSpec, window string)
return UpdateRevisionTemplateAnnotation(template, autoscaling.WindowAnnotationKey, window)
}

// UpdateConcurrencyTarget updates container concurrency annotation
func UpdateConcurrencyTarget(template *servingv1.RevisionTemplateSpec, target int) error {
// UpdateScaleTarget updates container concurrency annotation
func UpdateScaleTarget(template *servingv1.RevisionTemplateSpec, target int) error {
return UpdateRevisionTemplateAnnotation(template, autoscaling.TargetAnnotationKey, strconv.Itoa(target))
}

// UpdateConcurrencyUtilization updates container target utilization percentage annotation
func UpdateConcurrencyUtilization(template *servingv1.RevisionTemplateSpec, target int) error {
// UpdateScaleUtilization updates container target utilization percentage annotation
func UpdateScaleUtilization(template *servingv1.RevisionTemplateSpec, target int) error {
return UpdateRevisionTemplateAnnotation(template, autoscaling.TargetUtilizationPercentageKey, strconv.Itoa(target))
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/serving/config_changes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ func TestScaleWindow(t *testing.T) {

func TestUpdateConcurrencyTarget(t *testing.T) {
template, _ := getRevisionTemplate()
err := UpdateConcurrencyTarget(template, 10)
err := UpdateScaleTarget(template, 10)
assert.NilError(t, err)
// Verify update is successful or not
checkAnnotationValueInt(t, template, autoscaling.TargetAnnotationKey, 10)
// Update with invalid value
err = UpdateConcurrencyTarget(template, -1)
err = UpdateScaleTarget(template, -1)
assert.ErrorContains(t, err, "should be at least 0.01")
}

Expand Down Expand Up @@ -479,7 +479,7 @@ func checkContainerConcurrency(t *testing.T, template *servingv1.RevisionTemplat
func updateConcurrencyConfiguration(template *servingv1.RevisionTemplateSpec, minScale, maxScale, target, limit, utilization int) {
UpdateMinScale(template, minScale)
UpdateMaxScale(template, maxScale)
UpdateConcurrencyTarget(template, target)
UpdateScaleTarget(template, target)
UpdateConcurrencyLimit(template, int64(limit))
UpdateConcurrencyUtilization(template, utilization)
UpdateScaleUtilization(template, utilization)
}
4 changes: 2 additions & 2 deletions test/e2e/service_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestServiceOptions(t *testing.T) {
defer r.DumpIfFailed()

t.Log("create and validate service with concurrency options")
serviceCreateWithOptions(r, "svc1", "--concurrency-limit", "250", "--concurrency-target", "300", "--concurrency-utilization", "50")
serviceCreateWithOptions(r, "svc1", "--concurrency-limit", "250", "--scale-target", "300", "--scale-utilization", "50")
validateServiceConcurrencyTarget(r, "svc1", "300")
validateServiceConcurrencyLimit(r, "svc1", "250")
validateServiceConcurrencyUtilization(r, "svc1", "50")
Expand All @@ -60,7 +60,7 @@ func TestServiceOptions(t *testing.T) {
validateServiceConcurrencyLimit(r, "svc1", "300")

t.Log("update concurrency options with invalid values for service")
out := r.KnTest().Kn().Run("service", "update", "svc1", "--concurrency-limit", "-1", "--concurrency-target", "0")
out := r.KnTest().Kn().Run("service", "update", "svc1", "--concurrency-limit", "-1", "--scale-target", "0")
r.AssertError(out)
assert.Check(r.T(), util.ContainsAll(out.Stderr, "should be at least 0.01"))

Expand Down