From 269276d0331ef89627ed6d43acef23955d9c6bfe Mon Sep 17 00:00:00 2001 From: Lokananda Prabhu Date: Wed, 24 Jan 2024 13:26:10 +0530 Subject: [PATCH] Updated knative service to use max-scale, min-scale and target-utilization-percentage annotations --- .../__tests__/edit-application-utils.spec.ts | 6 +++--- ...-from-deployment-or-deployment-config.feature | 4 ++-- .../serverless/create-knative-workload.feature | 2 +- frontend/packages/knative-plugin/src/const.ts | 6 +++--- .../utils/__tests__/create-knative-utils.spec.ts | 16 +++++++++++----- .../src/utils/__tests__/knatify-utils.spec.ts | 4 ++-- .../src/utils/create-knative-utils.ts | 6 +++--- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/frontend/packages/dev-console/src/components/edit-application/__tests__/edit-application-utils.spec.ts b/frontend/packages/dev-console/src/components/edit-application/__tests__/edit-application-utils.spec.ts index bd97ee8a01b..1507c51bbad 100644 --- a/frontend/packages/dev-console/src/components/edit-application/__tests__/edit-application-utils.spec.ts +++ b/frontend/packages/dev-console/src/components/edit-application/__tests__/edit-application-utils.spec.ts @@ -181,11 +181,11 @@ describe('getServerlessData', () => { template: { metadata: { annotations: { - 'autoscaling.knative.dev/maxScale': '2', + 'autoscaling.knative.dev/max-scale': '2', 'autoscaling.knative.dev/window': '60s', 'autoscaling.knative.dev/target': '100', - 'autoscaling.knative.dev/targetUtilizationPercentage': '70', - 'autoscaling.knative.dev/minScale': '1', + 'autoscaling.knative.dev/target-utilization-percentage': '70', + 'autoscaling.knative.dev/min-scale': '1', }, }, spec: { diff --git a/frontend/packages/knative-plugin/integration-tests/features/serverless/create-knative-service-from-deployment-or-deployment-config.feature b/frontend/packages/knative-plugin/integration-tests/features/serverless/create-knative-service-from-deployment-or-deployment-config.feature index b71fbe4fc31..135d3b15777 100644 --- a/frontend/packages/knative-plugin/integration-tests/features/serverless/create-knative-service-from-deployment-or-deployment-config.feature +++ b/frontend/packages/knative-plugin/integration-tests/features/serverless/create-knative-service-from-deployment-or-deployment-config.feature @@ -70,7 +70,7 @@ Feature: Create Knative service from existing Deployment/Deployment Config workl And user clicks on save button And user right clicks on the knative service workoad "nodejs-ex-git1-sev" in Topology page And user selects option "Edit Service" from context options - Then user is able to see value of "autoscaling.knative.dev/targetUtilizationPercentage" as "4" + Then user is able to see value of "autoscaling.knative.dev/target-utilization-percentage" as "4" @regression @broken-test @@ -86,5 +86,5 @@ Feature: Create Knative service from existing Deployment/Deployment Config workl And user clicks on Create button in Make Serverless form And user right clicks on the knative service workoad "nodejs-ex-git2-sev" in Topology page And user selects option "Edit Service" from context options - Then user is able to see the value of "autoscaling.knative.dev/maxScale" and "autoscaling.knative.dev/minScale" as "6" and "3" percent respectively + Then user is able to see the value of "autoscaling.knative.dev/max-scale" and "autoscaling.knative.dev/min-scale" as "6" and "3" percent respectively And user is able to see "3" Pods running in Resources tab of sidebar for knative workload "nodejs-ex-git2-sev" diff --git a/frontend/packages/knative-plugin/integration-tests/features/serverless/create-knative-workload.feature b/frontend/packages/knative-plugin/integration-tests/features/serverless/create-knative-workload.feature index 0a3c1f14d8a..e4b4209235c 100644 --- a/frontend/packages/knative-plugin/integration-tests/features/serverless/create-knative-workload.feature +++ b/frontend/packages/knative-plugin/integration-tests/features/serverless/create-knative-workload.feature @@ -108,7 +108,7 @@ Feature: Create a workload of 'knative Service' type resource And user clicks Create button on Add page And user clicks on the Knative Service workload "dancer-ex-git" And user clicks on name KSVC "dancer-ex-git" - Then user will see value of autoscaling.knative.dev/maxScale, autoscaling.knative.dev/minScale, autoscaling.knative.dev/target, autoscaling.knative.dev/targetUtilizationPercentage, autoscaling.knative.dev/window under annotation and containerConcurrency under spec as under spec 5, 1, 3, 70, 9s and 15 respectively + Then user will see value of autoscaling.knative.dev/max-scale, autoscaling.knative.dev/min-scale, autoscaling.knative.dev/target, autoscaling.knative.dev/target-utilization-percentage, autoscaling.knative.dev/window under annotation and containerConcurrency under spec as under spec 5, 1, 3, 70, 9s and 15 respectively @regression @manual diff --git a/frontend/packages/knative-plugin/src/const.ts b/frontend/packages/knative-plugin/src/const.ts index cc241f89167..c0808711856 100644 --- a/frontend/packages/knative-plugin/src/const.ts +++ b/frontend/packages/knative-plugin/src/const.ts @@ -22,10 +22,10 @@ export const FLAG_CAMEL_KAMELETS = 'FLAG_CAMEL_KAMELETS'; export const CAMEL_K_PROVIDER_ANNOTATION = `${CAMEL_APIGROUP}/provider`; export const CAMEL_K_TYPE_LABEL = `${CAMEL_APIGROUP}/kamelet.type`; export const KNATIVE_AUTOSCALING_APIGROUP = 'autoscaling.knative.dev'; -export const KNATIVE_MINSCALE_ANNOTATION = `${KNATIVE_AUTOSCALING_APIGROUP}/minScale`; -export const KNATIVE_MAXSCALE_ANNOTATION = `${KNATIVE_AUTOSCALING_APIGROUP}/maxScale`; +export const KNATIVE_MINSCALE_ANNOTATION = `${KNATIVE_AUTOSCALING_APIGROUP}/min-scale`; +export const KNATIVE_MAXSCALE_ANNOTATION = `${KNATIVE_AUTOSCALING_APIGROUP}/max-scale`; export const KNATIVE_CONCURRENCYTARGET_ANNOTATION = `${KNATIVE_AUTOSCALING_APIGROUP}/target`; -export const KNATIVE_CONCURRENCYUTILIZATION_ANNOTATION = `${KNATIVE_AUTOSCALING_APIGROUP}/targetUtilizationPercentage`; +export const KNATIVE_CONCURRENCYUTILIZATION_ANNOTATION = `${KNATIVE_AUTOSCALING_APIGROUP}/target-utilization-percentage`; export const KNATIVE_AUTOSCALEWINDOW_ANNOTATION = `${KNATIVE_AUTOSCALING_APIGROUP}/window`; export const SERVERLESS_FUNCTION_LABEL_DEPRECATED = 'boson.dev/function'; // TODO: remove deprecated label for serverless function export const SERVERLESS_FUNCTION_LABEL = 'function.knative.dev'; diff --git a/frontend/packages/knative-plugin/src/utils/__tests__/create-knative-utils.spec.ts b/frontend/packages/knative-plugin/src/utils/__tests__/create-knative-utils.spec.ts index c6840396a2e..55935fc2f11 100644 --- a/frontend/packages/knative-plugin/src/utils/__tests__/create-knative-utils.spec.ts +++ b/frontend/packages/knative-plugin/src/utils/__tests__/create-knative-utils.spec.ts @@ -27,7 +27,7 @@ describe('Create knative Utils', () => { 8080, ); }); - it('expect to have minSccale, maxScale, target and containerConcurrency defined', () => { + it('expect to have min-scale, max-scale, target and containerConcurrency defined', () => { defaultData.route.unknownTargetPort = '8080'; const knDeploymentResource: K8sResourceKind = getKnativeServiceDepResource( defaultData, @@ -37,14 +37,18 @@ describe('Create knative Utils', () => { knDeploymentResource.spec.template.metadata.annotations['autoscaling.knative.dev/target'], ).toBe('1'); expect( - knDeploymentResource.spec.template.metadata.annotations['autoscaling.knative.dev/minScale'], + knDeploymentResource.spec.template.metadata.annotations[ + 'autoscaling.knative.dev/min-scale' + ], ).toBe('1'); expect( - knDeploymentResource.spec.template.metadata.annotations['autoscaling.knative.dev/maxScale'], + knDeploymentResource.spec.template.metadata.annotations[ + 'autoscaling.knative.dev/max-scale' + ], ).toBe('5'); expect(knDeploymentResource.spec.template.spec.containerConcurrency).toBe(1); }); - it('expect not to have minScale defined', () => { + it('expect not to have min-scale defined', () => { defaultData.serverless.scaling.minpods = 0; defaultData.route.unknownTargetPort = '8080'; const knDeploymentResource: K8sResourceKind = getKnativeServiceDepResource( @@ -52,7 +56,9 @@ describe('Create knative Utils', () => { 'imgStream', ); expect( - knDeploymentResource.spec.template.metadata.annotations['autoscaling.knative.dev/minScale'], + knDeploymentResource.spec.template.metadata.annotations[ + 'autoscaling.knative.dev/min-scale' + ], ).toBeUndefined(); }); diff --git a/frontend/packages/knative-plugin/src/utils/__tests__/knatify-utils.spec.ts b/frontend/packages/knative-plugin/src/utils/__tests__/knatify-utils.spec.ts index e5c670b1c75..91f406c4f87 100644 --- a/frontend/packages/knative-plugin/src/utils/__tests__/knatify-utils.spec.ts +++ b/frontend/packages/knative-plugin/src/utils/__tests__/knatify-utils.spec.ts @@ -26,8 +26,8 @@ describe('knatify-utils', () => { metadata: { ...ksvcData.spec.template.metadata, annotations: { - 'autoscaling.knative.dev/minScale': '1', - 'autoscaling.knative.dev/maxScale': '3', + 'autoscaling.knative.dev/min-scale': '1', + 'autoscaling.knative.dev/max-scale': '3', }, }, }, diff --git a/frontend/packages/knative-plugin/src/utils/create-knative-utils.ts b/frontend/packages/knative-plugin/src/utils/create-knative-utils.ts index 878d26b41af..d7e0bddfbca 100644 --- a/frontend/packages/knative-plugin/src/utils/create-knative-utils.ts +++ b/frontend/packages/knative-plugin/src/utils/create-knative-utils.ts @@ -131,13 +131,13 @@ export const getKnativeServiceDepResource = ( ...(concurrencytarget && { 'autoscaling.knative.dev/target': `${concurrencytarget}`, }), - ...(minpods && { 'autoscaling.knative.dev/minScale': `${minpods}` }), - ...(maxpods && { 'autoscaling.knative.dev/maxScale': `${maxpods}` }), + ...(minpods && { 'autoscaling.knative.dev/min-scale': `${minpods}` }), + ...(maxpods && { 'autoscaling.knative.dev/max-scale': `${maxpods}` }), ...(autoscalewindow && { 'autoscaling.knative.dev/window': `${autoscalewindow}${autoscalewindowUnit}`, }), ...(concurrencyutilization && { - 'autoscaling.knative.dev/targetUtilizationPercentage': `${concurrencyutilization}`, + 'autoscaling.knative.dev/target-utilization-percentage': `${concurrencyutilization}`, }), }, },