mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-06-28 07:49:27 +08:00
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:
@@ -22,16 +22,17 @@ import {DeployResult} from '../../types/deployResult'
|
||||
export async function deployBlueGreen(
|
||||
kubectl: Kubectl,
|
||||
files: string[],
|
||||
routeStrategy: RouteStrategy
|
||||
routeStrategy: RouteStrategy,
|
||||
timeout?: string
|
||||
): Promise<BlueGreenDeployment> {
|
||||
const blueGreenDeployment = await (async () => {
|
||||
switch (routeStrategy) {
|
||||
case RouteStrategy.INGRESS:
|
||||
return await deployBlueGreenIngress(kubectl, files)
|
||||
return await deployBlueGreenIngress(kubectl, files, timeout)
|
||||
case RouteStrategy.SMI:
|
||||
return await deployBlueGreenSMI(kubectl, files)
|
||||
return await deployBlueGreenSMI(kubectl, files, timeout)
|
||||
default:
|
||||
return await deployBlueGreenService(kubectl, files)
|
||||
return await deployBlueGreenService(kubectl, files, timeout)
|
||||
}
|
||||
})()
|
||||
|
||||
@@ -39,7 +40,8 @@ export async function deployBlueGreen(
|
||||
const routeDeployment = await routeBlueGreenForDeploy(
|
||||
kubectl,
|
||||
files,
|
||||
routeStrategy
|
||||
routeStrategy,
|
||||
timeout
|
||||
)
|
||||
core.endGroup()
|
||||
|
||||
@@ -52,7 +54,8 @@ export async function deployBlueGreen(
|
||||
|
||||
export async function deployBlueGreenSMI(
|
||||
kubectl: Kubectl,
|
||||
filePaths: string[]
|
||||
filePaths: string[],
|
||||
timeout?: string
|
||||
): Promise<BlueGreenDeployment> {
|
||||
// get all kubernetes objects defined in manifest files
|
||||
const manifestObjects: BlueGreenManifests = getManifestObjects(filePaths)
|
||||
@@ -67,20 +70,23 @@ export async function deployBlueGreenSMI(
|
||||
|
||||
const otherObjDeployment: DeployResult = await deployObjects(
|
||||
kubectl,
|
||||
newObjectsList
|
||||
newObjectsList,
|
||||
timeout
|
||||
)
|
||||
|
||||
// make extraservices and trafficsplit
|
||||
const smiAndSvcDeployment = await setupSMI(
|
||||
kubectl,
|
||||
manifestObjects.serviceEntityList
|
||||
manifestObjects.serviceEntityList,
|
||||
timeout
|
||||
)
|
||||
|
||||
// create new deloyments
|
||||
const blueGreenDeployment: BlueGreenDeployment = await deployWithLabel(
|
||||
kubectl,
|
||||
manifestObjects.deploymentEntityList,
|
||||
GREEN_LABEL_VALUE
|
||||
GREEN_LABEL_VALUE,
|
||||
timeout
|
||||
)
|
||||
|
||||
blueGreenDeployment.objects.push(...newObjectsList)
|
||||
@@ -98,7 +104,8 @@ export async function deployBlueGreenSMI(
|
||||
|
||||
export async function deployBlueGreenIngress(
|
||||
kubectl: Kubectl,
|
||||
filePaths: string[]
|
||||
filePaths: string[],
|
||||
timeout?: string
|
||||
): Promise<BlueGreenDeployment> {
|
||||
// get all kubernetes objects defined in manifest files
|
||||
const manifestObjects: BlueGreenManifests = getManifestObjects(filePaths)
|
||||
@@ -111,14 +118,15 @@ export async function deployBlueGreenIngress(
|
||||
const workloadDeployment: BlueGreenDeployment = await deployWithLabel(
|
||||
kubectl,
|
||||
servicesAndDeployments,
|
||||
GREEN_LABEL_VALUE
|
||||
GREEN_LABEL_VALUE,
|
||||
timeout
|
||||
)
|
||||
|
||||
const otherObjects = [].concat(
|
||||
manifestObjects.otherObjects,
|
||||
manifestObjects.unroutedServiceEntityList
|
||||
)
|
||||
await deployObjects(kubectl, otherObjects)
|
||||
await deployObjects(kubectl, otherObjects, timeout)
|
||||
core.debug(
|
||||
`new objects after processing services and other objects: \n
|
||||
${JSON.stringify(servicesAndDeployments)}`
|
||||
@@ -132,7 +140,8 @@ export async function deployBlueGreenIngress(
|
||||
|
||||
export async function deployBlueGreenService(
|
||||
kubectl: Kubectl,
|
||||
filePaths: string[]
|
||||
filePaths: string[],
|
||||
timeout?: string
|
||||
): Promise<BlueGreenDeployment> {
|
||||
const manifestObjects: BlueGreenManifests = getManifestObjects(filePaths)
|
||||
|
||||
@@ -140,7 +149,8 @@ export async function deployBlueGreenService(
|
||||
const blueGreenDeployment: BlueGreenDeployment = await deployWithLabel(
|
||||
kubectl,
|
||||
manifestObjects.deploymentEntityList,
|
||||
GREEN_LABEL_VALUE
|
||||
GREEN_LABEL_VALUE,
|
||||
timeout
|
||||
)
|
||||
|
||||
// create other non deployment and non service entities
|
||||
@@ -150,7 +160,7 @@ export async function deployBlueGreenService(
|
||||
manifestObjects.unroutedServiceEntityList
|
||||
)
|
||||
|
||||
await deployObjects(kubectl, newObjectsList)
|
||||
await deployObjects(kubectl, newObjectsList, timeout)
|
||||
// returning deployment details to check for rollout stability
|
||||
return {
|
||||
deployResult: blueGreenDeployment.deployResult,
|
||||
|
||||
Reference in New Issue
Block a user