From 26801516dee4e70bfcbf56547f3c1ac881596ad0 Mon Sep 17 00:00:00 2001 From: audrastump Date: Thu, 21 Nov 2024 13:37:13 -0800 Subject: [PATCH 01/10] added fleet exception to rollout cmd --- src/actions/deploy.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/actions/deploy.ts b/src/actions/deploy.ts index 17311298c..7d9aca0da 100644 --- a/src/actions/deploy.ts +++ b/src/actions/deploy.ts @@ -45,7 +45,10 @@ export async function deploy( KubernetesConstants.DiscoveryAndLoadBalancerResource.SERVICE ]) ) - await checkManifestStability(kubectl, resourceTypes) + const fleetName = core.getInput('fleet-name') || '' + if (!fleetName) { + await checkManifestStability(kubectl, resourceTypes) + } core.endGroup() // print ingresses From 3f36780ce6a3428f518b1a7be15e0257b61e1e68 Mon Sep 17 00:00:00 2001 From: audrastump Date: Thu, 21 Nov 2024 13:52:39 -0800 Subject: [PATCH 02/10] removed fleet check for rollout --- src/actions/deploy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/actions/deploy.ts b/src/actions/deploy.ts index 7d9aca0da..123c5d30f 100644 --- a/src/actions/deploy.ts +++ b/src/actions/deploy.ts @@ -45,8 +45,8 @@ export async function deploy( KubernetesConstants.DiscoveryAndLoadBalancerResource.SERVICE ]) ) - const fleetName = core.getInput('fleet-name') || '' - if (!fleetName) { + const resourceType = core.getInput('resource-type') || '' + if (resourceType.toLowerCase() != 'Microsoft.ContainerService/fleets') { await checkManifestStability(kubectl, resourceTypes) } core.endGroup() From fe81f8d8652203b9ec49d123b926e3fed12d3b22 Mon Sep 17 00:00:00 2001 From: audrastump Date: Wed, 27 Nov 2024 08:10:53 -0800 Subject: [PATCH 03/10] modified casing --- src/actions/deploy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/deploy.ts b/src/actions/deploy.ts index 123c5d30f..0ff73fec9 100644 --- a/src/actions/deploy.ts +++ b/src/actions/deploy.ts @@ -46,7 +46,7 @@ export async function deploy( ]) ) const resourceType = core.getInput('resource-type') || '' - if (resourceType.toLowerCase() != 'Microsoft.ContainerService/fleets') { + if (resourceType.toLowerCase() != 'microsoft.containerservice/fleets') { await checkManifestStability(kubectl, resourceTypes) } core.endGroup() From e3c3f2a45aa0ccfcbdffcc74e201453c1561d6b1 Mon Sep 17 00:00:00 2001 From: audrastump Date: Wed, 27 Nov 2024 10:02:10 -0800 Subject: [PATCH 04/10] modified approach for fleet check --- src/actions/deploy.ts | 6 ++-- src/strategyHelpers/deploymentHelper.ts | 5 ++-- src/utilities/manifestStabilityUtils.test.ts | 31 ++++++++++++++++++++ src/utilities/manifestStabilityUtils.ts | 8 ++++- 4 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 src/utilities/manifestStabilityUtils.test.ts diff --git a/src/actions/deploy.ts b/src/actions/deploy.ts index 0ff73fec9..98a05a697 100644 --- a/src/actions/deploy.ts +++ b/src/actions/deploy.ts @@ -39,16 +39,14 @@ export async function deploy( // check manifest stability core.startGroup('Checking manifest stability') + const resourceType = core.getInput('resource-type') || '' const resourceTypes: Resource[] = getResources( deployedManifestFiles, models.DEPLOYMENT_TYPES.concat([ KubernetesConstants.DiscoveryAndLoadBalancerResource.SERVICE ]) ) - const resourceType = core.getInput('resource-type') || '' - if (resourceType.toLowerCase() != 'microsoft.containerservice/fleets') { - await checkManifestStability(kubectl, resourceTypes) - } + await checkManifestStability(kubectl, resourceTypes, resourceType) core.endGroup() // print ingresses diff --git a/src/strategyHelpers/deploymentHelper.ts b/src/strategyHelpers/deploymentHelper.ts index 24257701e..874e10566 100644 --- a/src/strategyHelpers/deploymentHelper.ts +++ b/src/strategyHelpers/deploymentHelper.ts @@ -138,9 +138,10 @@ function appendStableVersionLabelToResource(files: string[]): string[] { export async function checkManifestStability( kubectl: Kubectl, - resources: Resource[] + resources: Resource[], + resourceType: string ): Promise { - await KubernetesManifestUtility.checkManifestStability(kubectl, resources) + await KubernetesManifestUtility.checkManifestStability(kubectl, resources, resourceType) } export async function annotateAndLabelResources( diff --git a/src/utilities/manifestStabilityUtils.test.ts b/src/utilities/manifestStabilityUtils.test.ts new file mode 100644 index 000000000..711bc428f --- /dev/null +++ b/src/utilities/manifestStabilityUtils.test.ts @@ -0,0 +1,31 @@ +import * as fileUtils from './fileUtils' +import * as manifestStabilityUtils from './manifestStabilityUtils' +import * as path from 'path' +import * as fs from 'fs' +import {before} from 'node:test' +import {Kubectl} from '../types/kubectl' + +describe('manifestStabilityUtils', () => { + + const resourceType = 'microsoft.containerservice/fleets' + const resources = [ + { + type: 'deployment', + name: 'test', + namespace: 'default' + } + ] + const kc = new Kubectl('') + + it('should return immediately if the resource type is microsoft.containerservice/fleets', async () => { + const spy = jest.spyOn(manifestStabilityUtils, 'checkManifestStability') + const checkRolloutStatusSpy = jest.spyOn(kc, 'checkRolloutStatus') + + await manifestStabilityUtils.checkManifestStability(kc, resources, resourceType) + + expect(checkRolloutStatusSpy).not.toHaveBeenCalled() + expect(spy).toHaveReturned() + }) + + +}) \ No newline at end of file diff --git a/src/utilities/manifestStabilityUtils.ts b/src/utilities/manifestStabilityUtils.ts index cd4b1390b..660450507 100644 --- a/src/utilities/manifestStabilityUtils.ts +++ b/src/utilities/manifestStabilityUtils.ts @@ -9,8 +9,14 @@ const POD = 'pod' export async function checkManifestStability( kubectl: Kubectl, - resources: Resource[] + resources: Resource[], + resourceType: string ): Promise { + // Skip if resource type is microsoft.containerservice/fleets + if (resourceType.toLowerCase()=== 'microsoft.containerservice/fleets') { + core.info('Skipping checkManifestStability for microsoft.containerservice/fleets') + return + } let rolloutStatusHasErrors = false for (let i = 0; i < resources.length; i++) { const resource = resources[i] From c418a7c750a0d2e711065659979f42293da4d90c Mon Sep 17 00:00:00 2001 From: audrastump Date: Wed, 27 Nov 2024 10:36:06 -0800 Subject: [PATCH 05/10] tidying up --- src/utilities/manifestStabilityUtils.test.ts | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/utilities/manifestStabilityUtils.test.ts b/src/utilities/manifestStabilityUtils.test.ts index 711bc428f..2b2df4c14 100644 --- a/src/utilities/manifestStabilityUtils.test.ts +++ b/src/utilities/manifestStabilityUtils.test.ts @@ -1,13 +1,8 @@ -import * as fileUtils from './fileUtils' import * as manifestStabilityUtils from './manifestStabilityUtils' -import * as path from 'path' -import * as fs from 'fs' -import {before} from 'node:test' import {Kubectl} from '../types/kubectl' describe('manifestStabilityUtils', () => { - - const resourceType = 'microsoft.containerservice/fleets' + const kc = new Kubectl('') const resources = [ { type: 'deployment', @@ -15,17 +10,14 @@ describe('manifestStabilityUtils', () => { namespace: 'default' } ] - const kc = new Kubectl('') + const resourceType = 'microsoft.containerservice/fleets' it('should return immediately if the resource type is microsoft.containerservice/fleets', async () => { const spy = jest.spyOn(manifestStabilityUtils, 'checkManifestStability') const checkRolloutStatusSpy = jest.spyOn(kc, 'checkRolloutStatus') - await manifestStabilityUtils.checkManifestStability(kc, resources, resourceType) expect(checkRolloutStatusSpy).not.toHaveBeenCalled() expect(spy).toHaveReturned() }) - - }) \ No newline at end of file From 561c01c67e10e40bbc0e3221b17c2cd195463bc1 Mon Sep 17 00:00:00 2001 From: audrastump Date: Wed, 27 Nov 2024 13:14:42 -0800 Subject: [PATCH 06/10] defaulting to Microsoft.ContainerService/managedClusters --- src/actions/deploy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/actions/deploy.ts b/src/actions/deploy.ts index 98a05a697..18b41bdf8 100644 --- a/src/actions/deploy.ts +++ b/src/actions/deploy.ts @@ -39,7 +39,7 @@ export async function deploy( // check manifest stability core.startGroup('Checking manifest stability') - const resourceType = core.getInput('resource-type') || '' + const resourceType = core.getInput('resource-type') || 'Microsoft.ContainerService/managedClusters' const resourceTypes: Resource[] = getResources( deployedManifestFiles, models.DEPLOYMENT_TYPES.concat([ From 57961604fcdb037cf3826bec14325690cc5c66b4 Mon Sep 17 00:00:00 2001 From: audrastump Date: Wed, 27 Nov 2024 13:16:46 -0800 Subject: [PATCH 07/10] ran prettier command --- src/actions/deploy.ts | 4 +++- src/strategyHelpers/deploymentHelper.ts | 6 +++++- src/utilities/manifestStabilityUtils.test.ts | 8 ++++++-- src/utilities/manifestStabilityUtils.ts | 8 +++++--- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/actions/deploy.ts b/src/actions/deploy.ts index 18b41bdf8..379a6987a 100644 --- a/src/actions/deploy.ts +++ b/src/actions/deploy.ts @@ -39,7 +39,9 @@ export async function deploy( // check manifest stability core.startGroup('Checking manifest stability') - const resourceType = core.getInput('resource-type') || 'Microsoft.ContainerService/managedClusters' + const resourceType = + core.getInput('resource-type') || + 'Microsoft.ContainerService/managedClusters' const resourceTypes: Resource[] = getResources( deployedManifestFiles, models.DEPLOYMENT_TYPES.concat([ diff --git a/src/strategyHelpers/deploymentHelper.ts b/src/strategyHelpers/deploymentHelper.ts index 874e10566..024f60f53 100644 --- a/src/strategyHelpers/deploymentHelper.ts +++ b/src/strategyHelpers/deploymentHelper.ts @@ -141,7 +141,11 @@ export async function checkManifestStability( resources: Resource[], resourceType: string ): Promise { - await KubernetesManifestUtility.checkManifestStability(kubectl, resources, resourceType) + await KubernetesManifestUtility.checkManifestStability( + kubectl, + resources, + resourceType + ) } export async function annotateAndLabelResources( diff --git a/src/utilities/manifestStabilityUtils.test.ts b/src/utilities/manifestStabilityUtils.test.ts index 2b2df4c14..e39bcc384 100644 --- a/src/utilities/manifestStabilityUtils.test.ts +++ b/src/utilities/manifestStabilityUtils.test.ts @@ -15,9 +15,13 @@ describe('manifestStabilityUtils', () => { it('should return immediately if the resource type is microsoft.containerservice/fleets', async () => { const spy = jest.spyOn(manifestStabilityUtils, 'checkManifestStability') const checkRolloutStatusSpy = jest.spyOn(kc, 'checkRolloutStatus') - await manifestStabilityUtils.checkManifestStability(kc, resources, resourceType) + await manifestStabilityUtils.checkManifestStability( + kc, + resources, + resourceType + ) expect(checkRolloutStatusSpy).not.toHaveBeenCalled() expect(spy).toHaveReturned() }) -}) \ No newline at end of file +}) diff --git a/src/utilities/manifestStabilityUtils.ts b/src/utilities/manifestStabilityUtils.ts index 660450507..9fcedb074 100644 --- a/src/utilities/manifestStabilityUtils.ts +++ b/src/utilities/manifestStabilityUtils.ts @@ -12,9 +12,11 @@ export async function checkManifestStability( resources: Resource[], resourceType: string ): Promise { - // Skip if resource type is microsoft.containerservice/fleets - if (resourceType.toLowerCase()=== 'microsoft.containerservice/fleets') { - core.info('Skipping checkManifestStability for microsoft.containerservice/fleets') + // Skip if resource type is microsoft.containerservice/fleets + if (resourceType.toLowerCase() === 'microsoft.containerservice/fleets') { + core.info( + 'Skipping checkManifestStability for microsoft.containerservice/fleets' + ) return } let rolloutStatusHasErrors = false From 5a88777946912388e13040a04a842dd92685db7b Mon Sep 17 00:00:00 2001 From: audrastump Date: Wed, 27 Nov 2024 13:25:20 -0800 Subject: [PATCH 08/10] modified manifest stablity check --- src/actions/promote.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/actions/promote.ts b/src/actions/promote.ts index 2c11384c4..5ccd2d1cf 100644 --- a/src/actions/promote.ts +++ b/src/actions/promote.ts @@ -166,6 +166,9 @@ async function promoteBlueGreen(kubectl: Kubectl, manifests: string[]) { // checking stability of newly created deployments core.startGroup('Checking manifest stability') + const resourceType = + core.getInput('resource-type') || + 'Microsoft.ContainerService/managedClusters' const deployedManifestFiles = deployResult.manifestFiles const resources: Resource[] = getResources( deployedManifestFiles, @@ -173,7 +176,7 @@ async function promoteBlueGreen(kubectl: Kubectl, manifests: string[]) { models.DiscoveryAndLoadBalancerResource.SERVICE ]) ) - await KubernetesManifestUtility.checkManifestStability(kubectl, resources) + await KubernetesManifestUtility.checkManifestStability(kubectl, resources, resourceType) core.endGroup() core.startGroup( From 2a64e0189bab837e9d566ef6fcc2848c534eb7e2 Mon Sep 17 00:00:00 2001 From: audrastump Date: Wed, 27 Nov 2024 13:31:00 -0800 Subject: [PATCH 09/10] ran prettier check --- src/actions/promote.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/actions/promote.ts b/src/actions/promote.ts index 5ccd2d1cf..da06a5d8c 100644 --- a/src/actions/promote.ts +++ b/src/actions/promote.ts @@ -176,7 +176,11 @@ async function promoteBlueGreen(kubectl: Kubectl, manifests: string[]) { models.DiscoveryAndLoadBalancerResource.SERVICE ]) ) - await KubernetesManifestUtility.checkManifestStability(kubectl, resources, resourceType) + await KubernetesManifestUtility.checkManifestStability( + kubectl, + resources, + resourceType + ) core.endGroup() core.startGroup( From 0dab943d8afb0409ef9236c83f4b56cd8b641e72 Mon Sep 17 00:00:00 2001 From: audrastump Date: Wed, 27 Nov 2024 13:39:50 -0800 Subject: [PATCH 10/10] moved lowercase check to beginning --- src/actions/deploy.ts | 3 ++- src/actions/promote.ts | 3 ++- src/utilities/manifestStabilityUtils.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/actions/deploy.ts b/src/actions/deploy.ts index 379a6987a..34c18b9d1 100644 --- a/src/actions/deploy.ts +++ b/src/actions/deploy.ts @@ -39,9 +39,10 @@ export async function deploy( // check manifest stability core.startGroup('Checking manifest stability') - const resourceType = + const resourceType = ( core.getInput('resource-type') || 'Microsoft.ContainerService/managedClusters' + ).toLowerCase() const resourceTypes: Resource[] = getResources( deployedManifestFiles, models.DEPLOYMENT_TYPES.concat([ diff --git a/src/actions/promote.ts b/src/actions/promote.ts index da06a5d8c..7a6c3075b 100644 --- a/src/actions/promote.ts +++ b/src/actions/promote.ts @@ -166,9 +166,10 @@ async function promoteBlueGreen(kubectl: Kubectl, manifests: string[]) { // checking stability of newly created deployments core.startGroup('Checking manifest stability') - const resourceType = + const resourceType = ( core.getInput('resource-type') || 'Microsoft.ContainerService/managedClusters' + ).toLowerCase() const deployedManifestFiles = deployResult.manifestFiles const resources: Resource[] = getResources( deployedManifestFiles, diff --git a/src/utilities/manifestStabilityUtils.ts b/src/utilities/manifestStabilityUtils.ts index 9fcedb074..51efd49f5 100644 --- a/src/utilities/manifestStabilityUtils.ts +++ b/src/utilities/manifestStabilityUtils.ts @@ -13,7 +13,7 @@ export async function checkManifestStability( resourceType: string ): Promise { // Skip if resource type is microsoft.containerservice/fleets - if (resourceType.toLowerCase() === 'microsoft.containerservice/fleets') { + if (resourceType === 'microsoft.containerservice/fleets') { core.info( 'Skipping checkManifestStability for microsoft.containerservice/fleets' )