Compare commits

..

1 Commits

Author SHA1 Message Date
Vidya Reddy f742976337 Add ncc build to build script 2022-07-01 10:15:03 -07:00
5 changed files with 16 additions and 54 deletions
+8 -16
View File
@@ -65,30 +65,26 @@ async function promoteCanary(kubectl: Kubectl, manifests: string[]) {
// In case of SMI traffic split strategy when deployment is promoted, first we will redirect traffic to // In case of SMI traffic split strategy when deployment is promoted, first we will redirect traffic to
// canary deployment, then update stable deployment and then redirect traffic to stable deployment // canary deployment, then update stable deployment and then redirect traffic to stable deployment
core.startGroup('Redirecting traffic to canary deployment') core.info('Redirecting traffic to canary deployment')
await SMICanaryDeploymentHelper.redirectTrafficToCanaryDeployment( await SMICanaryDeploymentHelper.redirectTrafficToCanaryDeployment(
kubectl, kubectl,
manifests manifests
) )
core.endGroup()
core.startGroup('Deploying input manifests with SMI canary strategy') core.info('Deploying input manifests with SMI canary strategy')
await deploy.deploy(kubectl, manifests, DeploymentStrategy.CANARY) await deploy.deploy(kubectl, manifests, DeploymentStrategy.CANARY)
core.endGroup()
core.startGroup('Redirecting traffic to stable deployment') core.info('Redirecting traffic to stable deployment')
await SMICanaryDeploymentHelper.redirectTrafficToStableDeployment( await SMICanaryDeploymentHelper.redirectTrafficToStableDeployment(
kubectl, kubectl,
manifests manifests
) )
core.endGroup()
} else { } else {
core.startGroup('Deploying input manifests') core.info('Deploying input manifests')
await deploy.deploy(kubectl, manifests, DeploymentStrategy.CANARY) await deploy.deploy(kubectl, manifests, DeploymentStrategy.CANARY)
core.endGroup()
} }
core.startGroup('Deleting canary and baseline workloads') core.info('Deleting canary and baseline workloads')
try { try {
await canaryDeploymentHelper.deleteCanaryDeployment( await canaryDeploymentHelper.deleteCanaryDeployment(
kubectl, kubectl,
@@ -101,7 +97,6 @@ async function promoteCanary(kubectl: Kubectl, manifests: string[]) {
ex ex
) )
} }
core.endGroup()
} }
async function promoteBlueGreen(kubectl: Kubectl, manifests: string[]) { async function promoteBlueGreen(kubectl: Kubectl, manifests: string[]) {
@@ -114,7 +109,7 @@ async function promoteBlueGreen(kubectl: Kubectl, manifests: string[]) {
core.getInput('route-method', {required: true}) core.getInput('route-method', {required: true})
) )
core.startGroup('Deleting old deployment and making new one') core.info('Deleting old deployment and making new one')
let result let result
if (routeStrategy == RouteStrategy.INGRESS) { if (routeStrategy == RouteStrategy.INGRESS) {
result = await promoteBlueGreenIngress(kubectl, manifestObjects) result = await promoteBlueGreenIngress(kubectl, manifestObjects)
@@ -123,10 +118,9 @@ async function promoteBlueGreen(kubectl: Kubectl, manifests: string[]) {
} else { } else {
result = await promoteBlueGreenService(kubectl, manifestObjects) result = await promoteBlueGreenService(kubectl, manifestObjects)
} }
core.endGroup()
// checking stability of newly created deployments // checking stability of newly created deployments
core.startGroup('Checking manifest stability') core.info('Checking manifest stability')
const deployedManifestFiles = result.newFilePaths const deployedManifestFiles = result.newFilePaths
const resources: Resource[] = getResources( const resources: Resource[] = getResources(
deployedManifestFiles, deployedManifestFiles,
@@ -135,9 +129,8 @@ async function promoteBlueGreen(kubectl: Kubectl, manifests: string[]) {
]) ])
) )
await KubernetesManifestUtility.checkManifestStability(kubectl, resources) await KubernetesManifestUtility.checkManifestStability(kubectl, resources)
core.endGroup()
core.startGroup( core.info(
'Routing to new deployments and deleting old workloads and services' 'Routing to new deployments and deleting old workloads and services'
) )
if (routeStrategy == RouteStrategy.INGRESS) { if (routeStrategy == RouteStrategy.INGRESS) {
@@ -177,5 +170,4 @@ async function promoteBlueGreen(kubectl: Kubectl, manifests: string[]) {
manifestObjects.deploymentEntityList manifestObjects.deploymentEntityList
) )
} }
core.endGroup()
} }
+3 -6
View File
@@ -36,26 +36,24 @@ async function rejectCanary(kubectl: Kubectl, manifests: string[]) {
core.getInput('traffic-split-method', {required: true}) core.getInput('traffic-split-method', {required: true})
) )
if (trafficSplitMethod == TrafficSplitMethod.SMI) { if (trafficSplitMethod == TrafficSplitMethod.SMI) {
core.startGroup('Rejecting deployment with SMI canary strategy') core.info('Rejecting deployment with SMI canary strategy')
includeServices = true includeServices = true
await SMICanaryDeploymentHelper.redirectTrafficToStableDeployment( await SMICanaryDeploymentHelper.redirectTrafficToStableDeployment(
kubectl, kubectl,
manifests manifests
) )
core.endGroup()
} }
core.startGroup('Deleting baseline and canary workloads') core.info('Deleting baseline and canary workloads')
await canaryDeploymentHelper.deleteCanaryDeployment( await canaryDeploymentHelper.deleteCanaryDeployment(
kubectl, kubectl,
manifests, manifests,
includeServices includeServices
) )
core.endGroup()
} }
async function rejectBlueGreen(kubectl: Kubectl, manifests: string[]) { async function rejectBlueGreen(kubectl: Kubectl, manifests: string[]) {
core.startGroup('Rejecting deployment with blue green strategy') core.info('Rejecting deployment with blue green strategy')
const routeStrategy = parseRouteStrategy( const routeStrategy = parseRouteStrategy(
core.getInput('route-method', {required: true}) core.getInput('route-method', {required: true})
@@ -67,5 +65,4 @@ async function rejectBlueGreen(kubectl: Kubectl, manifests: string[]) {
} else { } else {
await rejectBlueGreenService(kubectl, manifests) await rejectBlueGreenService(kubectl, manifests)
} }
core.endGroup()
} }
+4 -5
View File
@@ -23,8 +23,7 @@ import {parseRouteStrategy, RouteStrategy} from '../types/routeStrategy'
import {ExecOutput} from '@actions/exec' import {ExecOutput} from '@actions/exec'
import { import {
getWorkflowAnnotationKeyLabel, getWorkflowAnnotationKeyLabel,
getWorkflowAnnotations, getWorkflowAnnotations
cleanLabel
} from '../utilities/workflowAnnotationUtils' } from '../utilities/workflowAnnotationUtils'
import { import {
annotateChildPods, annotateChildPods,
@@ -215,10 +214,10 @@ async function labelResources(
label: string label: string
) { ) {
const labels = [ const labels = [
`workflowFriendlyName=${cleanLabel( `workflowFriendlyName=${normalizeWorkflowStrLabel(
normalizeWorkflowStrLabel(process.env.GITHUB_WORKFLOW) process.env.GITHUB_WORKFLOW
)}`, )}`,
`workflow=${cleanLabel(label)}` `workflow=${label}`
] ]
checkForErrors([await kubectl.labelFiles(files, labels)], true) checkForErrors([await kubectl.labelFiles(files, labels)], true)
+1 -16
View File
@@ -1,7 +1,4 @@
import { import {prefixObjectKeys} from '../utilities/workflowAnnotationUtils'
cleanLabel,
prefixObjectKeys
} from '../utilities/workflowAnnotationUtils'
describe('WorkflowAnnotationUtils', () => { describe('WorkflowAnnotationUtils', () => {
describe('prefixObjectKeys', () => { describe('prefixObjectKeys', () => {
@@ -18,16 +15,4 @@ describe('WorkflowAnnotationUtils', () => {
expect(prefixObjectKeys(obj, prefix)).toEqual(expected) expect(prefixObjectKeys(obj, prefix)).toEqual(expected)
}) })
}) })
describe('cleanLabel', () => {
it('should clean label', () => {
const alreadyClean = 'alreadyClean'
expect(cleanLabel(alreadyClean)).toEqual(alreadyClean)
expect(cleanLabel('.startInvalid')).toEqual('startInvalid')
expect(cleanLabel('with%S0ME&invalid#chars')).toEqual(
'withS0MEinvalidchars'
)
expect(cleanLabel('with⚒️emoji')).toEqual('withemoji')
})
})
}) })
-11
View File
@@ -47,14 +47,3 @@ export function getWorkflowAnnotationKeyLabel(
.digest('hex') .digest('hex')
return `githubWorkflow_${hashKey}` return `githubWorkflow_${hashKey}`
} }
/**
* Cleans label to match valid kubernetes label specification by removing invalid characters
* @param label
* @returns cleaned label
*/
export function cleanLabel(label: string): string {
const removedInvalidChars = label.replace(/[^-A-Za-z0-9_.]/gi, '')
const regex = /([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]/
return regex.exec(removedInvalidChars)[0] || ''
}