added try catch logic to prevent future failures if annotations fail since failing annotations shouldn't affect users

This commit is contained in:
Jaiveer Katariya
2022-12-07 15:04:46 -05:00
parent 724205aecf
commit 6d9b280d23
3 changed files with 21 additions and 10 deletions
@@ -70,3 +70,4 @@ jobs:
run: | run: |
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Deployment name=nginx-deployment containerName=nginx:1.14.2 labels=app:nginx,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_basic selectorLabels=app:nginx python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Deployment name=nginx-deployment containerName=nginx:1.14.2 labels=app:nginx,workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_basic selectorLabels=app:nginx
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Service name=nginx-service labels=workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_basic selectorLabels=app:nginx python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Service name=nginx-service labels=workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_basic selectorLabels=app:nginx
python test/integration/k8s-deploy-test.py namespace=${{ env.NAMESPACE }} kind=Service name=nginx-service labels=workflow:actions.github.com-k8s-deploy,workflowFriendlyName:Minikube_Integration_Tests_-_basic selectorLabels=app:nginx
+9 -1
View File
@@ -155,7 +155,7 @@ export async function annotateAndLabelResources(
const deploymentConfig = await getDeploymentConfig() const deploymentConfig = await getDeploymentConfig()
const annotationKeyLabel = getWorkflowAnnotationKeyLabel() const annotationKeyLabel = getWorkflowAnnotationKeyLabel()
try {
await annotateResources( await annotateResources(
files, files,
kubectl, kubectl,
@@ -165,7 +165,15 @@ export async function annotateAndLabelResources(
workflowFilePath, workflowFilePath,
deploymentConfig deploymentConfig
) )
} catch (ex) {
core.warning(`Failed to annotate resources: ${ex} `)
}
try {
await labelResources(files, kubectl, annotationKeyLabel) await labelResources(files, kubectl, annotationKeyLabel)
} catch (ex) {
core.warning(`Failed to label resources: ${ex}`)
}
} }
async function annotateResources( async function annotateResources(
+2
View File
@@ -241,6 +241,8 @@ def main():
RESULT, msg = verifyIngress(k8_object, parsedArgs) RESULT, msg = verifyIngress(k8_object, parsedArgs)
if kind == "TrafficSplit": if kind == "TrafficSplit":
RESULT, msg = verifyTSObject(k8_object, parsedArgs) RESULT, msg = verifyTSObject(k8_object, parsedArgs)
if kind == "Pod":
RESULT, msg = verifyPod(k8_object, parsedArgs)
if not RESULT: if not RESULT:
sys.exit(f"{kind} {name} failed check: {msg}") sys.exit(f"{kind} {name} failed check: {msg}")