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

enable fleet cluster deployment #356

Merged
merged 10 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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') {
bfoley13 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading