Skip to content

Commit

Permalink
enable fleet cluster deployment (#356)
Browse files Browse the repository at this point in the history
* added fleet exception to rollout cmd

* removed fleet check for rollout

* modified casing

* modified approach for fleet check

* tidying up

* defaulting to Microsoft.ContainerService/managedClusters

* ran prettier command

* modified manifest stablity check

* ran prettier check

* moved lowercase check to beginning

---------

Co-authored-by: audrastump <[email protected]>
  • Loading branch information
audrastump and audrastump authored Dec 6, 2024
1 parent bf768b3 commit d1acc1a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/actions/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/actions/promote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,22 @@ 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,
models.DEPLOYMENT_TYPES.concat([
models.DiscoveryAndLoadBalancerResource.SERVICE
])
)
await KubernetesManifestUtility.checkManifestStability(kubectl, resources)
await KubernetesManifestUtility.checkManifestStability(
kubectl,
resources,
resourceType
)
core.endGroup()

core.startGroup(
Expand Down
9 changes: 7 additions & 2 deletions src/strategyHelpers/deploymentHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,14 @@ function appendStableVersionLabelToResource(files: string[]): string[] {

export async function checkManifestStability(
kubectl: Kubectl,
resources: Resource[]
resources: Resource[],
resourceType: string
): Promise<void> {
await KubernetesManifestUtility.checkManifestStability(kubectl, resources)
await KubernetesManifestUtility.checkManifestStability(
kubectl,
resources,
resourceType
)
}

export async function annotateAndLabelResources(
Expand Down
27 changes: 27 additions & 0 deletions src/utilities/manifestStabilityUtils.test.ts
Original file line number Diff line number Diff line change
@@ -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()
})
})
10 changes: 9 additions & 1 deletion src/utilities/manifestStabilityUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@ const POD = 'pod'

export async function checkManifestStability(
kubectl: Kubectl,
resources: Resource[]
resources: Resource[],
resourceType: string
): Promise<void> {
// 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]
Expand Down

0 comments on commit d1acc1a

Please sign in to comment.