diff --git a/src/actions/deploy.ts b/src/actions/deploy.ts index 17311298c..34c18b9d1 100644 --- a/src/actions/deploy.ts +++ b/src/actions/deploy.ts @@ -39,13 +39,17 @@ export async function deploy( // check manifest stability core.startGroup('Checking manifest stability') + const resourceType = ( + core.getInput('resource-type') || + 'Microsoft.ContainerService/managedClusters' + ).toLowerCase() const resourceTypes: Resource[] = getResources( deployedManifestFiles, models.DEPLOYMENT_TYPES.concat([ KubernetesConstants.DiscoveryAndLoadBalancerResource.SERVICE ]) ) - await checkManifestStability(kubectl, resourceTypes) + await checkManifestStability(kubectl, resourceTypes, resourceType) core.endGroup() // print ingresses diff --git a/src/actions/promote.ts b/src/actions/promote.ts index 2c11384c4..7a6c3075b 100644 --- a/src/actions/promote.ts +++ b/src/actions/promote.ts @@ -166,6 +166,10 @@ 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' + ).toLowerCase() const deployedManifestFiles = deployResult.manifestFiles const resources: Resource[] = getResources( deployedManifestFiles, @@ -173,7 +177,11 @@ 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( diff --git a/src/strategyHelpers/deploymentHelper.ts b/src/strategyHelpers/deploymentHelper.ts index 24257701e..024f60f53 100644 --- a/src/strategyHelpers/deploymentHelper.ts +++ b/src/strategyHelpers/deploymentHelper.ts @@ -138,9 +138,14 @@ 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..e39bcc384 --- /dev/null +++ b/src/utilities/manifestStabilityUtils.test.ts @@ -0,0 +1,27 @@ +import * as manifestStabilityUtils from './manifestStabilityUtils' +import {Kubectl} from '../types/kubectl' + +describe('manifestStabilityUtils', () => { + const kc = new Kubectl('') + const resources = [ + { + type: 'deployment', + name: 'test', + namespace: 'default' + } + ] + 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() + }) +}) diff --git a/src/utilities/manifestStabilityUtils.ts b/src/utilities/manifestStabilityUtils.ts index cd4b1390b..51efd49f5 100644 --- a/src/utilities/manifestStabilityUtils.ts +++ b/src/utilities/manifestStabilityUtils.ts @@ -9,8 +9,16 @@ 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 === '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]