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

chore: Remove deprecated requests/limits flags #1110

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 0 additions & 4 deletions docs/cmd/kn_service_apply.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-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-'.
--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)
--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.
Expand All @@ -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'.
--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-'.
--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-init int Initial number of replicas with which a service starts. Can be 0 or a positive integer.
Expand Down
4 changes: 0 additions & 4 deletions docs/cmd/kn_service_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-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-'.
--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)
--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.
Expand All @@ -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'.
--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-'.
--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-init int Initial number of replicas with which a service starts. Can be 0 or a positive integer.
Expand Down
4 changes: 0 additions & 4 deletions docs/cmd/kn_service_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-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-'.
--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)
--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.
Expand All @@ -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'.
--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-'.
--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-init int Initial number of replicas with which a service starts. Can be 0 or a positive integer.
Expand Down
37 changes: 2 additions & 35 deletions pkg/kn/commands/service/create_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,40 +445,7 @@ func TestServiceCreateWithResources(t *testing.T) {
r.Validate()
}

func TestServiceCreateWithResourcesWarning(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) {
func TestServiceCreateWithDeprecatedResourcesError(t *testing.T) {
client := knclient.NewMockKnServiceClient(t)
r := client.Recorder()

Expand All @@ -487,7 +454,7 @@ func TestServiceCreateWithResourcesError(t *testing.T) {
"--request", "memory=64Mi",
"--no-wait", "--revision-name=")
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()
}
Expand Down
139 changes: 2 additions & 137 deletions pkg/kn/commands/service/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz",
Expand Down Expand Up @@ -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) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz",
Expand Down Expand Up @@ -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) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz",
Expand Down Expand Up @@ -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) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo",
Expand Down Expand Up @@ -620,8 +485,8 @@ func TestServiceCreateScaleWithMinScaleSet(t *testing.T) {
func TestServiceCreateRequestsLimitsCPUMemory(t *testing.T) {
action, created, _, err := fakeServiceCreate([]string{
"service", "create", "foo", "--image", "gcr.io/foo/bar:baz",
"--requests-cpu", "250m", "--limits-cpu", "1000m",
"--requests-memory", "64Mi", "--limits-memory", "1024Mi",
"--request", "cpu=250m", "--limit", "cpu=1000m",
"--request", "memory=64Mi", "--limit", "memory=1024Mi",
"--no-wait"}, false)

if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/kn/commands/service/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ func TestServiceUpdateRequestsLimitsCPU(t *testing.T) {
service := createMockServiceWithResources(t, "250", "64Mi", "1000m", "1024Mi")

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 {
t.Fatal(err)
} else if !action.Matches("update", "services") {
Expand Down Expand Up @@ -616,7 +616,7 @@ func TestServiceUpdateRequestsLimitsMemory(t *testing.T) {
service := createMockServiceWithResources(t, "100m", "64Mi", "1000m", "1024Mi")

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 {
t.Fatal(err)
} else if !action.Matches("update", "services") {
Expand Down Expand Up @@ -655,8 +655,8 @@ func TestServiceUpdateRequestsLimitsCPU_and_Memory(t *testing.T) {

action, updated, _, err := fakeServiceUpdate(service, []string{
"service", "update", "foo",
"--requests-cpu", "500m", "--limits-cpu", "2000m",
"--requests-memory", "128Mi", "--limits-memory", "2048Mi", "--no-wait"})
"--request", "cpu=500m,memory=128Mi",
"--limit", "cpu=2000m,memory=2048Mi", "--no-wait"})
if err != nil {
t.Fatal(err)
} else if !action.Matches("update", "services") {
Expand Down
Loading