Skip to content
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
3 changes: 3 additions & 0 deletions .github/workflows/run-integration-tests-canary-smi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
kubernetes-version: 1.31.0
driver: 'none'
timeout-minutes: 3

- name: Install Linkerd and SMI
run: |
curl --proto '=https' --tlsv1.2 -sSfL https://run.linkerd.io/install-edge | sh
export PATH=$PATH:/home/runner/.linkerd2/bin
curl -sL https://linkerd.github.io/linkerd-smi/install | sh
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ inputs:
skip-tls-verify:
description: True if the insecure-skip-tls-verify option should be used. Input should be 'true' or 'false'.
default: false
timeout:
description: 'Timeout for the rollout status'
required: false
default: 10m
Comment thread
benjaminbob21 marked this conversation as resolved.
resource-type:
description: Either Microsoft.ContainerService/managedClusters or Microsoft.ContainerService/fleets'.
required: false
Expand Down
8 changes: 5 additions & 3 deletions src/actions/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export async function deploy(
kubectl: Kubectl,
manifestFilePaths: string[],
deploymentStrategy: DeploymentStrategy,
resourceType: ClusterType
resourceType: ClusterType,
timeout?: string
Comment thread
benjaminbob21 marked this conversation as resolved.
) {
// update manifests
const inputManifestFiles: string[] = updateManifestFiles(manifestFilePaths)
Expand All @@ -36,7 +37,8 @@ export async function deploy(
inputManifestFiles,
deploymentStrategy,
kubectl,
trafficSplitMethod
trafficSplitMethod,
timeout
)
core.debug(`Deployed manifest files: ${deployedManifestFiles}`)
core.endGroup()
Expand All @@ -50,7 +52,7 @@ export async function deploy(
])
)

await checkManifestStability(kubectl, resourceTypes, resourceType)
await checkManifestStability(kubectl, resourceTypes, resourceType, timeout)
core.endGroup()

// print ingresses
Expand Down
62 changes: 45 additions & 17 deletions src/actions/promote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,26 @@ export async function promote(
kubectl: Kubectl,
manifests: string[],
deploymentStrategy: DeploymentStrategy,
resourceType: ClusterType
resourceType: ClusterType,
timeout?: string
) {
switch (deploymentStrategy) {
case DeploymentStrategy.CANARY:
await promoteCanary(kubectl, manifests)
await promoteCanary(kubectl, manifests, timeout)
break
case DeploymentStrategy.BLUE_GREEN:
await promoteBlueGreen(kubectl, manifests, resourceType)
await promoteBlueGreen(kubectl, manifests, resourceType, timeout)
Comment thread
benjaminbob21 marked this conversation as resolved.
break
default:
throw Error('Invalid promote deployment strategy')
}
}

async function promoteCanary(kubectl: Kubectl, manifests: string[]) {
async function promoteCanary(
kubectl: Kubectl,
manifests: string[],
timeout?: string
Comment thread
benjaminbob21 marked this conversation as resolved.
) {
let includeServices = false

const manifestFilesForDeployment: string[] = updateManifestFiles(manifests)
Expand All @@ -76,7 +81,8 @@ async function promoteCanary(kubectl: Kubectl, manifests: string[]) {
core.startGroup('Redirecting traffic to canary deployment')
await SMICanaryDeploymentHelper.redirectTrafficToCanaryDeployment(
kubectl,
manifests
manifests,
timeout
)
core.endGroup()

Expand All @@ -87,7 +93,8 @@ async function promoteCanary(kubectl: Kubectl, manifests: string[]) {
promoteResult = await SMICanaryDeploymentHelper.deploySMICanary(
manifestFilesForDeployment,
kubectl,
true
true,
timeout
)

core.endGroup()
Expand All @@ -96,7 +103,8 @@ async function promoteCanary(kubectl: Kubectl, manifests: string[]) {
const stableRedirectManifests =
await SMICanaryDeploymentHelper.redirectTrafficToStableDeployment(
kubectl,
manifests
manifests,
timeout
)

filesToAnnotate = promoteResult.manifestFiles.concat(
Expand All @@ -109,7 +117,8 @@ async function promoteCanary(kubectl: Kubectl, manifests: string[]) {
promoteResult = await PodCanaryHelper.deployPodCanary(
manifestFilesForDeployment,
kubectl,
true
true,
timeout
)
filesToAnnotate = promoteResult.manifestFiles
core.endGroup()
Expand Down Expand Up @@ -144,7 +153,8 @@ async function promoteCanary(kubectl: Kubectl, manifests: string[]) {
async function promoteBlueGreen(
kubectl: Kubectl,
manifests: string[],
resourceType: ClusterType
resourceType: ClusterType,
timeout?: string
) {
// update container images and pull secrets
const inputManifestFiles: string[] = updateManifestFiles(manifests)
Expand All @@ -160,11 +170,19 @@ async function promoteBlueGreen(
const {deployResult} = await (async () => {
switch (routeStrategy) {
case RouteStrategy.INGRESS:
return await promoteBlueGreenIngress(kubectl, manifestObjects)
return await promoteBlueGreenIngress(
kubectl,
manifestObjects,
timeout
)
case RouteStrategy.SMI:
return await promoteBlueGreenSMI(kubectl, manifestObjects)
return await promoteBlueGreenSMI(kubectl, manifestObjects, timeout)
default:
return await promoteBlueGreenService(kubectl, manifestObjects)
return await promoteBlueGreenService(
kubectl,
manifestObjects,
timeout
)
}
})()

Expand All @@ -182,7 +200,8 @@ async function promoteBlueGreen(
await KubernetesManifestUtility.checkManifestStability(
kubectl,
resources,
resourceType
resourceType,
timeout
)
core.endGroup()

Expand All @@ -201,23 +220,32 @@ async function promoteBlueGreen(
[].concat(
manifestObjects.deploymentEntityList,
manifestObjects.serviceEntityList
)
),
timeout
)
} else if (routeStrategy == RouteStrategy.SMI) {
await routeBlueGreenSMI(
kubectl,
NONE_LABEL_VALUE,
manifestObjects.serviceEntityList
)
await deleteGreenObjects(kubectl, manifestObjects.deploymentEntityList)
await cleanupSMI(kubectl, manifestObjects.serviceEntityList)
await deleteGreenObjects(
kubectl,
manifestObjects.deploymentEntityList,
timeout
)
await cleanupSMI(kubectl, manifestObjects.serviceEntityList, timeout)
Comment thread
benjaminbob21 marked this conversation as resolved.
} else {
await routeBlueGreenService(
kubectl,
NONE_LABEL_VALUE,
manifestObjects.serviceEntityList
)
await deleteGreenObjects(kubectl, manifestObjects.deploymentEntityList)
await deleteGreenObjects(
kubectl,
manifestObjects.deploymentEntityList,
timeout
)
}
core.endGroup()

Expand Down
31 changes: 21 additions & 10 deletions src/actions/reject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,26 @@ import {parseRouteStrategy, RouteStrategy} from '../types/routeStrategy'
export async function reject(
kubectl: Kubectl,
manifests: string[],
deploymentStrategy: DeploymentStrategy
deploymentStrategy: DeploymentStrategy,
timeout?: string
) {
switch (deploymentStrategy) {
case DeploymentStrategy.CANARY:
await rejectCanary(kubectl, manifests)
await rejectCanary(kubectl, manifests, timeout)
break
case DeploymentStrategy.BLUE_GREEN:
await rejectBlueGreen(kubectl, manifests)
await rejectBlueGreen(kubectl, manifests, timeout)
break
default:
throw 'Invalid delete deployment strategy'
}
}

async function rejectCanary(kubectl: Kubectl, manifests: string[]) {
async function rejectCanary(
kubectl: Kubectl,
manifests: string[],
timeout?: string
) {
let includeServices = false

const trafficSplitMethod = parseTrafficSplitMethod(
Expand All @@ -44,7 +49,8 @@ async function rejectCanary(kubectl: Kubectl, manifests: string[]) {
includeServices = true
await SMICanaryDeploymentHelper.redirectTrafficToStableDeployment(
kubectl,
manifests
manifests,
timeout
)
core.endGroup()
}
Expand All @@ -53,12 +59,17 @@ async function rejectCanary(kubectl: Kubectl, manifests: string[]) {
await canaryDeploymentHelper.deleteCanaryDeployment(
kubectl,
manifests,
includeServices
includeServices,
timeout
)
core.endGroup()
}

async function rejectBlueGreen(kubectl: Kubectl, manifests: string[]) {
async function rejectBlueGreen(
kubectl: Kubectl,
manifests: string[],
timeout?: string
) {
const routeStrategy = parseRouteStrategy(
core.getInput('route-method', {required: true})
)
Expand All @@ -67,11 +78,11 @@ async function rejectBlueGreen(kubectl: Kubectl, manifests: string[]) {
const manifestObjects: BlueGreenManifests = getManifestObjects(manifests)

if (routeStrategy == RouteStrategy.INGRESS) {
await rejectBlueGreenIngress(kubectl, manifestObjects)
await rejectBlueGreenIngress(kubectl, manifestObjects, timeout)
} else if (routeStrategy == RouteStrategy.SMI) {
await rejectBlueGreenSMI(kubectl, manifestObjects)
await rejectBlueGreenSMI(kubectl, manifestObjects, timeout)
} else {
await rejectBlueGreenService(kubectl, manifestObjects)
await rejectBlueGreenService(kubectl, manifestObjects, timeout)
}
core.endGroup()
}
30 changes: 27 additions & 3 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {parseDeploymentStrategy} from './types/deploymentStrategy'
import {getFilesFromDirectoriesAndURLs} from './utilities/fileUtils'
import {PrivateKubectl} from './types/privatekubectl'
import {parseResourceTypeInput} from './inputUtils'
import {parseDuration} from './utilities/durationUtils'

export async function run() {
// verify kubeconfig is set
Expand Down Expand Up @@ -52,6 +53,17 @@ export async function run() {
return
}

// Parse and validate timeout using extracted utility
let timeout: string
try {
const timeoutInput = core.getInput('timeout') || '10m'
timeout = parseDuration(timeoutInput)
core.debug(`Using timeout: ${timeout}`)
} catch (e) {
core.setFailed(`Invalid timeout parameter: ${e.message}`)
return
}

const kubectl = isPrivateCluster
? new PrivateKubectl(
kubectlPath,
Expand All @@ -65,15 +77,27 @@ export async function run() {
// run action
switch (action) {
case Action.DEPLOY: {
await deploy(kubectl, fullManifestFilePaths, strategy, resourceType)
await deploy(
kubectl,
fullManifestFilePaths,
strategy,
resourceType,
timeout
)
break
}
case Action.PROMOTE: {
await promote(kubectl, fullManifestFilePaths, strategy, resourceType)
await promote(
kubectl,
fullManifestFilePaths,
strategy,
resourceType,
timeout
)
break
}
case Action.REJECT: {
await reject(kubectl, fullManifestFilePaths, strategy)
await reject(kubectl, fullManifestFilePaths, strategy, timeout)
break
}
default: {
Expand Down
Loading
Loading