Skip to content

Commit d1acc1a

Browse files
audrastumpaudrastump
andauthored
enable fleet cluster deployment (#356)
* 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 <stumpaudra@microsoft.com>
1 parent bf768b3 commit d1acc1a

File tree

5 files changed

+57
-5
lines changed

5 files changed

+57
-5
lines changed

src/actions/deploy.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ export async function deploy(
3939

4040
// check manifest stability
4141
core.startGroup('Checking manifest stability')
42+
const resourceType = (
43+
core.getInput('resource-type') ||
44+
'Microsoft.ContainerService/managedClusters'
45+
).toLowerCase()
4246
const resourceTypes: Resource[] = getResources(
4347
deployedManifestFiles,
4448
models.DEPLOYMENT_TYPES.concat([
4549
KubernetesConstants.DiscoveryAndLoadBalancerResource.SERVICE
4650
])
4751
)
48-
await checkManifestStability(kubectl, resourceTypes)
52+
await checkManifestStability(kubectl, resourceTypes, resourceType)
4953
core.endGroup()
5054

5155
// print ingresses

src/actions/promote.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,22 @@ async function promoteBlueGreen(kubectl: Kubectl, manifests: string[]) {
166166

167167
// checking stability of newly created deployments
168168
core.startGroup('Checking manifest stability')
169+
const resourceType = (
170+
core.getInput('resource-type') ||
171+
'Microsoft.ContainerService/managedClusters'
172+
).toLowerCase()
169173
const deployedManifestFiles = deployResult.manifestFiles
170174
const resources: Resource[] = getResources(
171175
deployedManifestFiles,
172176
models.DEPLOYMENT_TYPES.concat([
173177
models.DiscoveryAndLoadBalancerResource.SERVICE
174178
])
175179
)
176-
await KubernetesManifestUtility.checkManifestStability(kubectl, resources)
180+
await KubernetesManifestUtility.checkManifestStability(
181+
kubectl,
182+
resources,
183+
resourceType
184+
)
177185
core.endGroup()
178186

179187
core.startGroup(

src/strategyHelpers/deploymentHelper.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,14 @@ function appendStableVersionLabelToResource(files: string[]): string[] {
138138

139139
export async function checkManifestStability(
140140
kubectl: Kubectl,
141-
resources: Resource[]
141+
resources: Resource[],
142+
resourceType: string
142143
): Promise<void> {
143-
await KubernetesManifestUtility.checkManifestStability(kubectl, resources)
144+
await KubernetesManifestUtility.checkManifestStability(
145+
kubectl,
146+
resources,
147+
resourceType
148+
)
144149
}
145150

146151
export async function annotateAndLabelResources(
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as manifestStabilityUtils from './manifestStabilityUtils'
2+
import {Kubectl} from '../types/kubectl'
3+
4+
describe('manifestStabilityUtils', () => {
5+
const kc = new Kubectl('')
6+
const resources = [
7+
{
8+
type: 'deployment',
9+
name: 'test',
10+
namespace: 'default'
11+
}
12+
]
13+
const resourceType = 'microsoft.containerservice/fleets'
14+
15+
it('should return immediately if the resource type is microsoft.containerservice/fleets', async () => {
16+
const spy = jest.spyOn(manifestStabilityUtils, 'checkManifestStability')
17+
const checkRolloutStatusSpy = jest.spyOn(kc, 'checkRolloutStatus')
18+
await manifestStabilityUtils.checkManifestStability(
19+
kc,
20+
resources,
21+
resourceType
22+
)
23+
24+
expect(checkRolloutStatusSpy).not.toHaveBeenCalled()
25+
expect(spy).toHaveReturned()
26+
})
27+
})

src/utilities/manifestStabilityUtils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@ const POD = 'pod'
99

1010
export async function checkManifestStability(
1111
kubectl: Kubectl,
12-
resources: Resource[]
12+
resources: Resource[],
13+
resourceType: string
1314
): Promise<void> {
15+
// Skip if resource type is microsoft.containerservice/fleets
16+
if (resourceType === 'microsoft.containerservice/fleets') {
17+
core.info(
18+
'Skipping checkManifestStability for microsoft.containerservice/fleets'
19+
)
20+
return
21+
}
1422
let rolloutStatusHasErrors = false
1523
for (let i = 0; i < resources.length; i++) {
1624
const resource = resources[i]

0 commit comments

Comments
 (0)