chore: Remove deprecated requests/limits flags (#1110)

* chore: Remove deprecated requests/limits flags

* chore: Add changelog entry
This commit is contained in:
David Simansky 2020-11-11 14:52:59 +01:00 committed by GitHub
parent d1a1fc94ce
commit 8d3580a4b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 17 additions and 277 deletions

View File

@ -52,6 +52,10 @@
| 🎁 | 🎁
| Add arm64 binary to the release | Add arm64 binary to the release
| https://github.com/knative/client/pull/1106[#1106] | https://github.com/knative/client/pull/1106[#1106]
| 🗑
| Drop deprecated `--requests-cpu,--requests-memory,--limits-cpu,--limits-memory` flags support
| https://github.com/knative/client/pull/1110[#1110]
|=== |===
## v0.18.1 (2020-10-13) ## v0.18.1 (2020-10-13)

View File

@ -53,8 +53,6 @@ kn service apply s0 --filename my-svc.yml
--label-revision stringArray Revision label to set. name=value; you may provide this flag any number of times to set multiple labels. To unset, specify the label name followed by a "-" (e.g., name-). This flag takes precedence over the "label" flag. --label-revision stringArray Revision label to set. name=value; you may provide this flag any number of times to set multiple labels. To unset, specify the label name followed by a "-" (e.g., name-). This flag takes precedence over the "label" flag.
--label-service stringArray Service label to set. name=value; you may provide this flag any number of times to set multiple labels. To unset, specify the label name followed by a "-" (e.g., name-). This flag takes precedence over the "label" flag. --label-service stringArray Service label to set. name=value; you may provide this flag any number of times to set multiple labels. To unset, specify the label name followed by a "-" (e.g., name-). This flag takes precedence over the "label" flag.
--limit strings The resource requirement limits for this Service. For example, 'cpu=100m,memory=256Mi'. You can use this flag multiple times. To unset a resource limit, append "-" to the resource name, e.g. '--limit memory-'. --limit strings The resource requirement limits for this Service. For example, 'cpu=100m,memory=256Mi'. You can use this flag multiple times. To unset a resource limit, append "-" to the resource name, e.g. '--limit memory-'.
--limits-cpu string DEPRECATED: please use --limit instead. The limits on the requested CPU (e.g., 1000m).
--limits-memory string DEPRECATED: please use --limit instead. The limits on the requested memory (e.g., 1024Mi).
--lock-to-digest Keep the running image for the service constant when not explicitly specifying the image. (--no-lock-to-digest pulls the image tag afresh with each new revision) (default true) --lock-to-digest Keep the running image for the service constant when not explicitly specifying the image. (--no-lock-to-digest pulls the image tag afresh with each new revision) (default true)
--mount stringArray Mount a ConfigMap (prefix cm: or config-map:), a Secret (prefix secret: or sc:), or an existing Volume (without any prefix) on the specified directory. Example: --mount /mydir=cm:myconfigmap, --mount /mydir=secret:mysecret, or --mount /mydir=myvolume. When a configmap or a secret is specified, a corresponding volume is automatically generated. You can use this flag multiple times. For unmounting a directory, append "-", e.g. --mount /mydir-, which also removes any auto-generated volume. --mount stringArray Mount a ConfigMap (prefix cm: or config-map:), a Secret (prefix secret: or sc:), or an existing Volume (without any prefix) on the specified directory. Example: --mount /mydir=cm:myconfigmap, --mount /mydir=secret:mysecret, or --mount /mydir=myvolume. When a configmap or a secret is specified, a corresponding volume is automatically generated. You can use this flag multiple times. For unmounting a directory, append "-", e.g. --mount /mydir-, which also removes any auto-generated volume.
-n, --namespace string Specify the namespace to operate in. -n, --namespace string Specify the namespace to operate in.
@ -64,8 +62,6 @@ kn service apply s0 --filename my-svc.yml
-p, --port string The port where application listens on, in the format 'NAME:PORT', where 'NAME' is optional. Examples: '--port h2c:8080' , '--port 8080'. -p, --port string The port where application listens on, in the format 'NAME:PORT', where 'NAME' is optional. Examples: '--port h2c:8080' , '--port 8080'.
--pull-secret string Image pull secret to set. An empty argument ("") clears the pull secret. The referenced secret must exist in the service's namespace. --pull-secret string Image pull secret to set. An empty argument ("") clears the pull secret. The referenced secret must exist in the service's namespace.
--request strings The resource requirement requests for this Service. For example, 'cpu=100m,memory=256Mi'. You can use this flag multiple times. To unset a resource request, append "-" to the resource name, e.g. '--request cpu-'. --request strings The resource requirement requests for this Service. For example, 'cpu=100m,memory=256Mi'. You can use this flag multiple times. To unset a resource request, append "-" to the resource name, e.g. '--request cpu-'.
--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}}") --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 int Minimum and maximum number of replicas.
--scale-init int Initial number of replicas with which a service starts. Can be 0 or a positive integer. --scale-init int Initial number of replicas with which a service starts. Can be 0 or a positive integer.

View File

@ -73,8 +73,6 @@ kn service create NAME --image IMAGE
--label-revision stringArray Revision label to set. name=value; you may provide this flag any number of times to set multiple labels. To unset, specify the label name followed by a "-" (e.g., name-). This flag takes precedence over the "label" flag. --label-revision stringArray Revision label to set. name=value; you may provide this flag any number of times to set multiple labels. To unset, specify the label name followed by a "-" (e.g., name-). This flag takes precedence over the "label" flag.
--label-service stringArray Service label to set. name=value; you may provide this flag any number of times to set multiple labels. To unset, specify the label name followed by a "-" (e.g., name-). This flag takes precedence over the "label" flag. --label-service stringArray Service label to set. name=value; you may provide this flag any number of times to set multiple labels. To unset, specify the label name followed by a "-" (e.g., name-). This flag takes precedence over the "label" flag.
--limit strings The resource requirement limits for this Service. For example, 'cpu=100m,memory=256Mi'. You can use this flag multiple times. To unset a resource limit, append "-" to the resource name, e.g. '--limit memory-'. --limit strings The resource requirement limits for this Service. For example, 'cpu=100m,memory=256Mi'. You can use this flag multiple times. To unset a resource limit, append "-" to the resource name, e.g. '--limit memory-'.
--limits-cpu string DEPRECATED: please use --limit instead. The limits on the requested CPU (e.g., 1000m).
--limits-memory string DEPRECATED: please use --limit instead. The limits on the requested memory (e.g., 1024Mi).
--lock-to-digest Keep the running image for the service constant when not explicitly specifying the image. (--no-lock-to-digest pulls the image tag afresh with each new revision) (default true) --lock-to-digest Keep the running image for the service constant when not explicitly specifying the image. (--no-lock-to-digest pulls the image tag afresh with each new revision) (default true)
--mount stringArray Mount a ConfigMap (prefix cm: or config-map:), a Secret (prefix secret: or sc:), or an existing Volume (without any prefix) on the specified directory. Example: --mount /mydir=cm:myconfigmap, --mount /mydir=secret:mysecret, or --mount /mydir=myvolume. When a configmap or a secret is specified, a corresponding volume is automatically generated. You can use this flag multiple times. For unmounting a directory, append "-", e.g. --mount /mydir-, which also removes any auto-generated volume. --mount stringArray Mount a ConfigMap (prefix cm: or config-map:), a Secret (prefix secret: or sc:), or an existing Volume (without any prefix) on the specified directory. Example: --mount /mydir=cm:myconfigmap, --mount /mydir=secret:mysecret, or --mount /mydir=myvolume. When a configmap or a secret is specified, a corresponding volume is automatically generated. You can use this flag multiple times. For unmounting a directory, append "-", e.g. --mount /mydir-, which also removes any auto-generated volume.
-n, --namespace string Specify the namespace to operate in. -n, --namespace string Specify the namespace to operate in.
@ -84,8 +82,6 @@ kn service create NAME --image IMAGE
-p, --port string The port where application listens on, in the format 'NAME:PORT', where 'NAME' is optional. Examples: '--port h2c:8080' , '--port 8080'. -p, --port string The port where application listens on, in the format 'NAME:PORT', where 'NAME' is optional. Examples: '--port h2c:8080' , '--port 8080'.
--pull-secret string Image pull secret to set. An empty argument ("") clears the pull secret. The referenced secret must exist in the service's namespace. --pull-secret string Image pull secret to set. An empty argument ("") clears the pull secret. The referenced secret must exist in the service's namespace.
--request strings The resource requirement requests for this Service. For example, 'cpu=100m,memory=256Mi'. You can use this flag multiple times. To unset a resource request, append "-" to the resource name, e.g. '--request cpu-'. --request strings The resource requirement requests for this Service. For example, 'cpu=100m,memory=256Mi'. You can use this flag multiple times. To unset a resource request, append "-" to the resource name, e.g. '--request cpu-'.
--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}}") --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 int Minimum and maximum number of replicas.
--scale-init int Initial number of replicas with which a service starts. Can be 0 or a positive integer. --scale-init int Initial number of replicas with which a service starts. Can be 0 or a positive integer.

View File

@ -56,8 +56,6 @@ kn service update NAME
--label-revision stringArray Revision label to set. name=value; you may provide this flag any number of times to set multiple labels. To unset, specify the label name followed by a "-" (e.g., name-). This flag takes precedence over the "label" flag. --label-revision stringArray Revision label to set. name=value; you may provide this flag any number of times to set multiple labels. To unset, specify the label name followed by a "-" (e.g., name-). This flag takes precedence over the "label" flag.
--label-service stringArray Service label to set. name=value; you may provide this flag any number of times to set multiple labels. To unset, specify the label name followed by a "-" (e.g., name-). This flag takes precedence over the "label" flag. --label-service stringArray Service label to set. name=value; you may provide this flag any number of times to set multiple labels. To unset, specify the label name followed by a "-" (e.g., name-). This flag takes precedence over the "label" flag.
--limit strings The resource requirement limits for this Service. For example, 'cpu=100m,memory=256Mi'. You can use this flag multiple times. To unset a resource limit, append "-" to the resource name, e.g. '--limit memory-'. --limit strings The resource requirement limits for this Service. For example, 'cpu=100m,memory=256Mi'. You can use this flag multiple times. To unset a resource limit, append "-" to the resource name, e.g. '--limit memory-'.
--limits-cpu string DEPRECATED: please use --limit instead. The limits on the requested CPU (e.g., 1000m).
--limits-memory string DEPRECATED: please use --limit instead. The limits on the requested memory (e.g., 1024Mi).
--lock-to-digest Keep the running image for the service constant when not explicitly specifying the image. (--no-lock-to-digest pulls the image tag afresh with each new revision) (default true) --lock-to-digest Keep the running image for the service constant when not explicitly specifying the image. (--no-lock-to-digest pulls the image tag afresh with each new revision) (default true)
--mount stringArray Mount a ConfigMap (prefix cm: or config-map:), a Secret (prefix secret: or sc:), or an existing Volume (without any prefix) on the specified directory. Example: --mount /mydir=cm:myconfigmap, --mount /mydir=secret:mysecret, or --mount /mydir=myvolume. When a configmap or a secret is specified, a corresponding volume is automatically generated. You can use this flag multiple times. For unmounting a directory, append "-", e.g. --mount /mydir-, which also removes any auto-generated volume. --mount stringArray Mount a ConfigMap (prefix cm: or config-map:), a Secret (prefix secret: or sc:), or an existing Volume (without any prefix) on the specified directory. Example: --mount /mydir=cm:myconfigmap, --mount /mydir=secret:mysecret, or --mount /mydir=myvolume. When a configmap or a secret is specified, a corresponding volume is automatically generated. You can use this flag multiple times. For unmounting a directory, append "-", e.g. --mount /mydir-, which also removes any auto-generated volume.
-n, --namespace string Specify the namespace to operate in. -n, --namespace string Specify the namespace to operate in.
@ -67,8 +65,6 @@ kn service update NAME
-p, --port string The port where application listens on, in the format 'NAME:PORT', where 'NAME' is optional. Examples: '--port h2c:8080' , '--port 8080'. -p, --port string The port where application listens on, in the format 'NAME:PORT', where 'NAME' is optional. Examples: '--port h2c:8080' , '--port 8080'.
--pull-secret string Image pull secret to set. An empty argument ("") clears the pull secret. The referenced secret must exist in the service's namespace. --pull-secret string Image pull secret to set. An empty argument ("") clears the pull secret. The referenced secret must exist in the service's namespace.
--request strings The resource requirement requests for this Service. For example, 'cpu=100m,memory=256Mi'. You can use this flag multiple times. To unset a resource request, append "-" to the resource name, e.g. '--request cpu-'. --request strings The resource requirement requests for this Service. For example, 'cpu=100m,memory=256Mi'. You can use this flag multiple times. To unset a resource request, append "-" to the resource name, e.g. '--request cpu-'.
--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}}") --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 int Minimum and maximum number of replicas.
--scale-init int Initial number of replicas with which a service starts. Can be 0 or a positive integer. --scale-init int Initial number of replicas with which a service starts. Can be 0 or a positive integer.

View File

@ -445,40 +445,7 @@ func TestServiceCreateWithResources(t *testing.T) {
r.Validate() r.Validate()
} }
func TestServiceCreateWithResourcesWarning(t *testing.T) { func TestServiceCreateWithDeprecatedResourcesError(t *testing.T) {
client := knclient.NewMockKnServiceClient(t)
r := client.Recorder()
r.GetService("foo", nil, errors.NewNotFound(servingv1.Resource("service"), "foo"))
service := getService("foo")
template := &service.Spec.Template
template.Spec.Containers[0].Resources.Requests = corev1.ResourceList{
corev1.ResourceMemory: parseQuantity(t, "64Mi"),
}
template.Spec.Containers[0].Resources.Limits = corev1.ResourceList{
corev1.ResourceCPU: parseQuantity(t, "1000m"),
}
template.Spec.Containers[0].Image = "gcr.io/foo/bar:baz"
template.Annotations = map[string]string{servinglib.UserImageAnnotationKey: "gcr.io/foo/bar:baz"}
r.CreateService(service, nil)
output, err := executeServiceCommand(client, "create", "foo", "--image", "gcr.io/foo/bar:baz",
"--requests-memory", "64Mi",
"--limits-cpu", "1000m",
"--no-wait", "--revision-name=")
assert.NilError(t, err)
assert.Assert(t, util.ContainsAll(output, "WARNING", "--requests-cpu", "--requests-memory", "deprecated", "removed", "--request", "instead"))
assert.Assert(t, util.ContainsAll(output, "WARNING", "--limits-cpu", "--limits-memory", "deprecated", "removed", "--limit", "instead"))
assert.Assert(t, util.ContainsAll(output, "created", "foo", "default"))
r.Validate()
}
func TestServiceCreateWithResourcesError(t *testing.T) {
client := knclient.NewMockKnServiceClient(t) client := knclient.NewMockKnServiceClient(t)
r := client.Recorder() r := client.Recorder()
@ -487,7 +454,7 @@ func TestServiceCreateWithResourcesError(t *testing.T) {
"--request", "memory=64Mi", "--request", "memory=64Mi",
"--no-wait", "--revision-name=") "--no-wait", "--revision-name=")
assert.Assert(t, err != nil) assert.Assert(t, err != nil)
assert.Assert(t, util.ContainsAll(output, "only one of", "DEPRECATED", "--requests-cpu", "--requests-memory", "--request", "can be specified")) assert.Assert(t, util.ContainsAll(output, "unknown", "flag", "--requests-memory"))
r.Validate() r.Validate()
} }

View File

@ -240,34 +240,6 @@ func TestServiceCreateEnv(t *testing.T) {
} }
} }
func TestServiceCreateWithDeprecatedRequests(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz",
"--requests-cpu", "250m", "--requests-memory", "64Mi",
"--no-wait"}, false)
if err != nil {
t.Fatal(err)
} else if !action.Matches("create", "services") {
t.Fatalf("Bad action %v", action)
}
expectedRequestsVars := corev1.ResourceList{
corev1.ResourceCPU: parseQuantity(t, "250m"),
corev1.ResourceMemory: parseQuantity(t, "64Mi"),
}
template := &created.Spec.Template
if err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(
template.Spec.Containers[0].Resources.Requests,
expectedRequestsVars) {
t.Fatalf("wrong requests vars %v", template.Spec.Containers[0].Resources.Requests)
}
}
func TestServiceCreateWithRequests(t *testing.T) { func TestServiceCreateWithRequests(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{ action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "service", "create", "foo", "--image", "gcr.io/foo/bar:baz",
@ -296,34 +268,6 @@ func TestServiceCreateWithRequests(t *testing.T) {
} }
} }
func TestServiceCreateWithDeprecatedLimits(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz",
"--limits-cpu", "1000m", "--limits-memory", "1024Mi",
"--no-wait"}, false)
if err != nil {
t.Fatal(err)
} else if !action.Matches("create", "services") {
t.Fatalf("Bad action %v", action)
}
expectedLimitsVars := corev1.ResourceList{
corev1.ResourceCPU: parseQuantity(t, "1000m"),
corev1.ResourceMemory: parseQuantity(t, "1024Mi"),
}
template := &created.Spec.Template
if err != nil {
t.Fatal(err)
} else if !reflect.DeepEqual(
template.Spec.Containers[0].Resources.Limits,
expectedLimitsVars) {
t.Fatalf("wrong limits vars %v", template.Spec.Containers[0].Resources.Limits)
}
}
func TestServiceCreateWithLimits(t *testing.T) { func TestServiceCreateWithLimits(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{ action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "service", "create", "foo", "--image", "gcr.io/foo/bar:baz",
@ -352,45 +296,6 @@ func TestServiceCreateWithLimits(t *testing.T) {
} }
} }
func TestServiceCreateDeprecatedRequestsLimitsCPU(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz",
"--requests-cpu", "250m", "--limits-cpu", "1000m",
"--no-wait"}, false)
if err != nil {
t.Fatal(err)
} else if !action.Matches("create", "services") {
t.Fatalf("Bad action %v", action)
}
expectedRequestsVars := corev1.ResourceList{
corev1.ResourceCPU: parseQuantity(t, "250m"),
}
expectedLimitsVars := corev1.ResourceList{
corev1.ResourceCPU: parseQuantity(t, "1000m"),
}
template := &created.Spec.Template
if err != nil {
t.Fatal(err)
} else {
if !reflect.DeepEqual(
template.Spec.Containers[0].Resources.Requests,
expectedRequestsVars) {
t.Fatalf("wrong requests vars %v", template.Spec.Containers[0].Resources.Requests)
}
if !reflect.DeepEqual(
template.Spec.Containers[0].Resources.Limits,
expectedLimitsVars) {
t.Fatalf("wrong limits vars %v", template.Spec.Containers[0].Resources.Limits)
}
}
}
func TestServiceCreateRequestsLimitsCPU(t *testing.T) { func TestServiceCreateRequestsLimitsCPU(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{ action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "service", "create", "foo", "--image", "gcr.io/foo/bar:baz",
@ -430,46 +335,6 @@ func TestServiceCreateRequestsLimitsCPU(t *testing.T) {
} }
} }
func TestServiceCreateDeprecatedRequestsLimitsMemory(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo",
"--image", "gcr.io/foo/bar:baz",
"--requests-memory", "64Mi",
"--limits-memory", "1024Mi", "--no-wait"}, false)
if err != nil {
t.Fatal(err)
} else if !action.Matches("create", "services") {
t.Fatalf("Bad action %v", action)
}
expectedRequestsVars := corev1.ResourceList{
corev1.ResourceMemory: parseQuantity(t, "64Mi"),
}
expectedLimitsVars := corev1.ResourceList{
corev1.ResourceMemory: parseQuantity(t, "1024Mi"),
}
template := &created.Spec.Template
if err != nil {
t.Fatal(err)
} else {
if !reflect.DeepEqual(
template.Spec.Containers[0].Resources.Requests,
expectedRequestsVars) {
t.Fatalf("wrong requests vars %v", template.Spec.Containers[0].Resources.Requests)
}
if !reflect.DeepEqual(
template.Spec.Containers[0].Resources.Limits,
expectedLimitsVars) {
t.Fatalf("wrong limits vars %v", template.Spec.Containers[0].Resources.Limits)
}
}
}
func TestServiceCreateRequestsLimitsMemory(t *testing.T) { func TestServiceCreateRequestsLimitsMemory(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{ action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "service", "create", "foo",
@ -620,8 +485,8 @@ func TestServiceCreateScaleWithMinScaleSet(t *testing.T) {
func TestServiceCreateRequestsLimitsCPUMemory(t *testing.T) { func TestServiceCreateRequestsLimitsCPUMemory(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{ action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz", "service", "create", "foo", "--image", "gcr.io/foo/bar:baz",
"--requests-cpu", "250m", "--limits-cpu", "1000m", "--request", "cpu=250m", "--limit", "cpu=1000m",
"--requests-memory", "64Mi", "--limits-memory", "1024Mi", "--request", "memory=64Mi", "--limit", "memory=1024Mi",
"--no-wait"}, false) "--no-wait"}, false)
if err != nil { if err != nil {

View File

@ -578,7 +578,7 @@ func TestServiceUpdateRequestsLimitsCPU(t *testing.T) {
service := createMockServiceWithResources(t, "250", "64Mi", "1000m", "1024Mi") service := createMockServiceWithResources(t, "250", "64Mi", "1000m", "1024Mi")
action, updated, _, err := fakeServiceUpdate(service, []string{ action, updated, _, err := fakeServiceUpdate(service, []string{
"service", "update", "foo", "--requests-cpu", "500m", "--limits-cpu", "1000m", "--no-wait"}) "service", "update", "foo", "--request", "cpu=500m", "--limit", "cpu=1000m", "--no-wait"})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} else if !action.Matches("update", "services") { } else if !action.Matches("update", "services") {
@ -616,7 +616,7 @@ func TestServiceUpdateRequestsLimitsMemory(t *testing.T) {
service := createMockServiceWithResources(t, "100m", "64Mi", "1000m", "1024Mi") service := createMockServiceWithResources(t, "100m", "64Mi", "1000m", "1024Mi")
action, updated, _, err := fakeServiceUpdate(service, []string{ action, updated, _, err := fakeServiceUpdate(service, []string{
"service", "update", "foo", "--requests-memory", "128Mi", "--limits-memory", "2048Mi", "--no-wait"}) "service", "update", "foo", "--request", "memory=128Mi", "--limit", "memory=2048Mi", "--no-wait"})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} else if !action.Matches("update", "services") { } else if !action.Matches("update", "services") {
@ -655,8 +655,8 @@ func TestServiceUpdateRequestsLimitsCPU_and_Memory(t *testing.T) {
action, updated, _, err := fakeServiceUpdate(service, []string{ action, updated, _, err := fakeServiceUpdate(service, []string{
"service", "update", "foo", "service", "update", "foo",
"--requests-cpu", "500m", "--limits-cpu", "2000m", "--request", "cpu=500m,memory=128Mi",
"--requests-memory", "128Mi", "--limits-memory", "2048Mi", "--no-wait"}) "--limit", "cpu=2000m,memory=2048Mi", "--no-wait"})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} else if !action.Matches("update", "services") { } else if !action.Matches("update", "services") {

View File

@ -20,7 +20,6 @@ import (
"strings" "strings"
corev1 "k8s.io/api/core/v1" corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"knative.dev/client/pkg/util" "knative.dev/client/pkg/util"
"github.com/spf13/pflag" "github.com/spf13/pflag"
@ -38,12 +37,11 @@ type PodSpecFlags struct {
Command string Command string
Arg []string Arg []string
RequestsFlags, LimitsFlags ResourceFlags // TODO: Flag marked deprecated in release v0.15.0, remove in release v0.18.0 Resources ResourceOptions
Resources ResourceOptions Port string
Port string ServiceAccountName string
ServiceAccountName string ImagePullSecrets string
ImagePullSecrets string User int64
User int64
} }
type ResourceFlags struct { type ResourceFlags struct {
@ -133,24 +131,6 @@ func (p *PodSpecFlags) AddFlags(flagset *pflag.FlagSet) []string {
"To unset a resource request, append \"-\" to the resource name, e.g. '--request cpu-'.") "To unset a resource request, append \"-\" to the resource name, e.g. '--request cpu-'.")
flagNames = append(flagNames, "request") flagNames = append(flagNames, "request")
flagset.StringVar(&p.RequestsFlags.CPU, "requests-cpu", "",
"DEPRECATED: please use --request instead. The requested CPU (e.g., 250m).")
flagNames = append(flagNames, "requests-cpu")
flagset.StringVar(&p.RequestsFlags.Memory, "requests-memory", "",
"DEPRECATED: please use --request instead. The requested memory (e.g., 64Mi).")
flagNames = append(flagNames, "requests-memory")
// TODO: Flag marked deprecated in release v0.15.0, remove in release v0.18.0
flagset.StringVar(&p.LimitsFlags.CPU, "limits-cpu", "",
"DEPRECATED: please use --limit instead. The limits on the requested CPU (e.g., 1000m).")
flagNames = append(flagNames, "limits-cpu")
// TODO: Flag marked deprecated in release v0.15.0, remove in release v0.18.0
flagset.StringVar(&p.LimitsFlags.Memory, "limits-memory", "",
"DEPRECATED: please use --limit instead. The limits on the requested memory (e.g., 1024Mi).")
flagNames = append(flagNames, "limits-memory")
flagset.StringVarP(&p.Port, "port", "p", "", "The port where application listens on, in the format 'NAME:PORT', where 'NAME' is optional. Examples: '--port h2c:8080' , '--port 8080'.") flagset.StringVarP(&p.Port, "port", "p", "", "The port where application listens on, in the format 'NAME:PORT', where 'NAME' is optional. Examples: '--port h2c:8080' , '--port 8080'.")
flagNames = append(flagNames, "port") flagNames = append(flagNames, "port")
@ -230,19 +210,6 @@ func (p *PodSpecFlags) ResolvePodSpec(podSpec *corev1.PodSpec, flags *pflag.Flag
} }
} }
limitsResources, err := p.computeResources(p.LimitsFlags)
if err != nil {
return err
}
requestsResources, err := p.computeResources(p.RequestsFlags)
if err != nil {
return err
}
err = UpdateResourcesDeprecated(podSpec, requestsResources, limitsResources)
if err != nil {
return err
}
requestsToRemove, limitsToRemove, err := p.Resources.Validate() requestsToRemove, limitsToRemove, err := p.Resources.Validate()
if err != nil { if err != nil {
return err return err
@ -291,29 +258,3 @@ func (p *PodSpecFlags) ResolvePodSpec(podSpec *corev1.PodSpec, flags *pflag.Flag
return nil return nil
} }
func (p *PodSpecFlags) computeResources(resourceFlags ResourceFlags) (corev1.ResourceList, error) {
resourceList := corev1.ResourceList{}
if resourceFlags.CPU != "" {
cpuQuantity, err := resource.ParseQuantity(resourceFlags.CPU)
if err != nil {
return corev1.ResourceList{},
fmt.Errorf("Error parsing %q: %w", resourceFlags.CPU, err)
}
resourceList[corev1.ResourceCPU] = cpuQuantity
}
if resourceFlags.Memory != "" {
memoryQuantity, err := resource.ParseQuantity(resourceFlags.Memory)
if err != nil {
return corev1.ResourceList{},
fmt.Errorf("Error parsing %q: %w", resourceFlags.Memory, err)
}
resourceList[corev1.ResourceMemory] = memoryQuantity
}
return resourceList, nil
}

View File

@ -224,31 +224,6 @@ func UpdateResources(spec *corev1.PodSpec, resources corev1.ResourceRequirements
return nil return nil
} }
// UpdateResourcesDeprecated updates resources as requested
func UpdateResourcesDeprecated(spec *corev1.PodSpec, requestsResourceList corev1.ResourceList, limitsResourceList corev1.ResourceList) error {
container, err := containerOfPodSpec(spec)
if err != nil {
return err
}
if container.Resources.Requests == nil {
container.Resources.Requests = corev1.ResourceList{}
}
for k, v := range requestsResourceList {
container.Resources.Requests[k] = v
}
if container.Resources.Limits == nil {
container.Resources.Limits = corev1.ResourceList{}
}
for k, v := range limitsResourceList {
container.Resources.Limits[k] = v
}
return nil
}
// UpdateServiceAccountName updates the service account name used for the corresponding knative service // UpdateServiceAccountName updates the service account name used for the corresponding knative service
func UpdateServiceAccountName(spec *corev1.PodSpec, serviceAccountName string) { func UpdateServiceAccountName(spec *corev1.PodSpec, serviceAccountName string) {
serviceAccountName = strings.TrimSpace(serviceAccountName) serviceAccountName = strings.TrimSpace(serviceAccountName)