Add timeout to the rollout status (#425)

* Added timeout to the rollout status and tests for it

* Fixed integration test errors

* Fix for blue green integration test

* Probable fix for integration errors

* No jobs run error fixed

* Changed timeout to file level constant

* Added parsing logic for timeout

* Made tests more concise

* implemented timeout validation check in an extracted utils mod

* Changed function name to parseDuration

* Removed timeout parameter from getResource

---------

Co-authored-by: David Gamero <david340804@gmail.com>
Co-authored-by: Suneha Bose <123775811+bosesuneha@users.noreply.github.com>
This commit is contained in:
benjamin
2025-07-09 13:22:21 -04:00
committed by GitHub
parent e207ec429b
commit ac0b58c9a5
28 changed files with 1677 additions and 209 deletions
+7 -4
View File
@@ -28,7 +28,8 @@ export const STABLE_LABEL_VALUE = 'stable'
export async function deleteCanaryDeployment(
kubectl: Kubectl,
manifestFilePaths: string[],
includeServices: boolean
includeServices: boolean,
timeout?: string
): Promise<string[]> {
if (manifestFilePaths == null || manifestFilePaths.length == 0) {
throw new Error('Manifest files for deleting canary deployment not found')
@@ -37,7 +38,8 @@ export async function deleteCanaryDeployment(
const deletedFiles = await cleanUpCanary(
kubectl,
manifestFilePaths,
includeServices
includeServices,
timeout
)
return deletedFiles
}
@@ -193,7 +195,8 @@ function addCanaryLabelsAndAnnotations(inputObject: any, type: string) {
async function cleanUpCanary(
kubectl: Kubectl,
files: string[],
includeServices: boolean
includeServices: boolean,
timeout?: string
): Promise<string[]> {
const deleteObject = async function (
kind: string,
@@ -201,7 +204,7 @@ async function cleanUpCanary(
namespace: string | undefined
) {
try {
const result = await kubectl.delete([kind, name], namespace)
const result = await kubectl.delete([kind, name], namespace, timeout)
checkForErrors([result])
} catch (ex) {
// Ignore failures of delete if it doesn't exist
@@ -13,7 +13,8 @@ import {K8sObject} from '../../types/k8sObject'
export async function deployPodCanary(
filePaths: string[],
kubectl: Kubectl,
onlyDeployStable: boolean = false
onlyDeployStable: boolean = false,
timeout?: string
): Promise<DeployResult> {
const newObjectsList = []
const percentage = parseInt(core.getInput('percentage', {required: true}))
@@ -100,7 +101,8 @@ export async function deployPodCanary(
const execResult = await kubectl.apply(
manifestFiles,
forceDeployment,
serverSideApply
serverSideApply,
timeout
)
return {execResult, manifestFiles}
}
+34 -16
View File
@@ -19,7 +19,8 @@ const TRAFFIC_SPLIT_OBJECT = 'TrafficSplit'
export async function deploySMICanary(
filePaths: string[],
kubectl: Kubectl,
onlyDeployStable: boolean = false
onlyDeployStable: boolean = false,
timeout?: string
): Promise<DeployResult> {
const canaryReplicasInput = core.getInput('baseline-and-canary-replicas')
let canaryReplicaCount
@@ -107,19 +108,26 @@ export async function deploySMICanary(
const newFilePaths = fileHelper.writeObjectsToFile(newObjectsList)
const forceDeployment = core.getInput('force').toLowerCase() === 'true'
const serverSideApply = core.getInput('server-side').toLowerCase() === 'true'
const result = await kubectl.apply(
newFilePaths,
forceDeployment,
serverSideApply
serverSideApply,
timeout
)
const svcDeploymentFiles = await createCanaryService(
kubectl,
filePaths,
timeout
)
const svcDeploymentFiles = await createCanaryService(kubectl, filePaths)
newFilePaths.push(...svcDeploymentFiles)
return {execResult: result, manifestFiles: newFilePaths}
}
async function createCanaryService(
kubectl: Kubectl,
filePaths: string[]
filePaths: string[],
timeout?: string
): Promise<string[]> {
const newObjectsList = []
const trafficObjectsList: string[] = []
@@ -161,7 +169,8 @@ async function createCanaryService(
name,
0,
0,
1000
1000,
timeout
)
trafficObjectsList.push(trafficObject)
@@ -220,7 +229,8 @@ async function createCanaryService(
const result = await kubectl.apply(
manifestFiles,
forceDeployment,
serverSideApply
serverSideApply,
timeout
)
checkForErrors([result])
return manifestFiles
@@ -228,23 +238,26 @@ async function createCanaryService(
export async function redirectTrafficToCanaryDeployment(
kubectl: Kubectl,
manifestFilePaths: string[]
manifestFilePaths: string[],
timeout?: string
) {
await adjustTraffic(kubectl, manifestFilePaths, 0, 1000)
await adjustTraffic(kubectl, manifestFilePaths, 0, 1000, timeout)
}
export async function redirectTrafficToStableDeployment(
kubectl: Kubectl,
manifestFilePaths: string[]
manifestFilePaths: string[],
timeout?: string
): Promise<string[]> {
return await adjustTraffic(kubectl, manifestFilePaths, 1000, 0)
return await adjustTraffic(kubectl, manifestFilePaths, 1000, 0, timeout)
}
async function adjustTraffic(
kubectl: Kubectl,
manifestFilePaths: string[],
stableWeight: number,
canaryWeight: number
canaryWeight: number,
timeout?: string
) {
if (!manifestFilePaths || manifestFilePaths?.length == 0) {
return
@@ -269,7 +282,8 @@ async function adjustTraffic(
name,
stableWeight,
0,
canaryWeight
canaryWeight,
timeout
)
)
}
@@ -289,7 +303,8 @@ async function adjustTraffic(
const result = await kubectl.apply(
trafficSplitManifests,
forceDeployment,
serverSideApply
serverSideApply,
timeout
)
checkForErrors([result])
return trafficSplitManifests
@@ -329,14 +344,16 @@ async function createTrafficSplitManifestFile(
serviceName: string,
stableWeight: number,
baselineWeight: number,
canaryWeight: number
canaryWeight: number,
timeout?: string
): Promise<string> {
const smiObjectString = await getTrafficSplitObject(
kubectl,
serviceName,
stableWeight,
baselineWeight,
canaryWeight
canaryWeight,
timeout
)
const manifestFile = fileHelper.writeManifestToFile(
smiObjectString,
@@ -358,7 +375,8 @@ async function getTrafficSplitObject(
name: string,
stableWeight: number,
baselineWeight: number,
canaryWeight: number
canaryWeight: number,
timeout?: string
): Promise<string> {
// cached version
if (!trafficSplitAPIVersion) {