Azure / k8s-deploy

GitHub Action for deploying to Kubernetes clusters
MIT License
252 stars 103 forks source link

Bug: Canary deployment the promote action doesn't fail even when kubectl apply return error #305

Open cha7ri opened 9 months ago

cha7ri commented 9 months ago

What happened?

I changed an immutable field in the deployment matchLabels , when deploying it using canary, the promote action should fail because it can't apply the new deployment manifest, but it didn't. I can see the kubectl error in the logs

  The Deployment "forked-myapp-dev" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/instance":"forked-myapp-dev", "app.kubernetes.io/name":"myapp-tmp"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable

I think the issue from the code is the exit code is not handled here https://github.com/Azure/k8s-deploy/blob/93550c22f0e0656c2a6b0cf5252a94cc3e2710fc/src/actions/promote.ts#L107

I think the issue can be fixed by adding checkForErros like here https://github.com/Azure/k8s-deploy/blob/93550c22f0e0656c2a6b0cf5252a94cc3e2710fc/src/strategyHelpers/deploymentHelper.ts#L58C10-L58C24

Expected behaviour

The pipeline should fail if it can't apply the manifest

Version

Runner

self-hosted

Relevant log output

  The Deployment "forked-myapp-dev" is invalid: spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{"app.kubernetes.io/instance":"forked-myapp-dev", "app.kubernetes.io/name":"myapp-tmp"}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: field is immutable
github-actions[bot] commented 9 months ago

This issue is idle because it has been open for 14 days with no activity.

cha7ri commented 6 months ago

Any updates?