k8s-deploy icon indicating copy to clipboard operation
k8s-deploy copied to clipboard

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

Open cha7ri opened this issue 1 year ago • 2 comments

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

  • [X] I am using the latest 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

cha7ri avatar Nov 30 '23 13:11 cha7ri