mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-04-16 11:32:19 +08:00
* 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>
88 lines
2.3 KiB
TypeScript
88 lines
2.3 KiB
TypeScript
import * as core from '@actions/core'
|
|
|
|
import {Kubectl} from '../../types/kubectl'
|
|
|
|
import {BlueGreenDeployment} from '../../types/blueGreenTypes'
|
|
import {deployWithLabel, NONE_LABEL_VALUE} from './blueGreenHelper'
|
|
|
|
import {validateIngresses} from './ingressBlueGreenHelper'
|
|
import {validateServicesState} from './serviceBlueGreenHelper'
|
|
import {validateTrafficSplitsState} from './smiBlueGreenHelper'
|
|
|
|
export async function promoteBlueGreenIngress(
|
|
kubectl: Kubectl,
|
|
manifestObjects,
|
|
timeout?: string
|
|
): Promise<BlueGreenDeployment> {
|
|
//checking if anything to promote
|
|
const {areValid, invalidIngresses} = await validateIngresses(
|
|
kubectl,
|
|
manifestObjects.ingressEntityList,
|
|
manifestObjects.serviceNameMap
|
|
)
|
|
if (!areValid) {
|
|
throw new Error(
|
|
`Ingresses are not in promote state: ${invalidIngresses.toString()}`
|
|
)
|
|
}
|
|
|
|
// create stable deployments with new configuration
|
|
const result: BlueGreenDeployment = await deployWithLabel(
|
|
kubectl,
|
|
[].concat(
|
|
manifestObjects.deploymentEntityList,
|
|
manifestObjects.serviceEntityList
|
|
),
|
|
NONE_LABEL_VALUE,
|
|
timeout
|
|
)
|
|
|
|
// create stable services with new configuration
|
|
return result
|
|
}
|
|
|
|
export async function promoteBlueGreenService(
|
|
kubectl: Kubectl,
|
|
manifestObjects,
|
|
timeout?: string
|
|
): Promise<BlueGreenDeployment> {
|
|
// checking if services are in the right state ie. targeting green deployments
|
|
if (
|
|
!(await validateServicesState(kubectl, manifestObjects.serviceEntityList))
|
|
) {
|
|
throw new Error('Found services not in promote state')
|
|
}
|
|
|
|
// creating stable deployments with new configurations
|
|
return await deployWithLabel(
|
|
kubectl,
|
|
manifestObjects.deploymentEntityList,
|
|
NONE_LABEL_VALUE,
|
|
timeout
|
|
)
|
|
}
|
|
|
|
export async function promoteBlueGreenSMI(
|
|
kubectl: Kubectl,
|
|
manifestObjects,
|
|
timeout?: string
|
|
): Promise<BlueGreenDeployment> {
|
|
// checking if there is something to promote
|
|
if (
|
|
!(await validateTrafficSplitsState(
|
|
kubectl,
|
|
manifestObjects.serviceEntityList
|
|
))
|
|
) {
|
|
throw Error('Not in promote state SMI')
|
|
}
|
|
|
|
// create stable deployments with new configuration
|
|
return await deployWithLabel(
|
|
kubectl,
|
|
manifestObjects.deploymentEntityList,
|
|
NONE_LABEL_VALUE,
|
|
timeout
|
|
)
|
|
}
|