GoogleContainerTools / GoogleContainerTools/skaffold
Respect container exit code and job failure when using verify.executionMode.kubernetesCluster.jobManifestPath
- Dominant language
- Go
- Stars
- 15.9k
- Forks
- 1.7k
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 10
Description
This is a communication issue between Google Cloud Build verify and Skaffold verify. Skaffold allows you to specify a Kubernetes Job file.
``` yaml
apiVersion: skaffold/v4beta13
kind: Config
verify:
- name: "verify-fail"
container:
name: test-verifier
image: ubuntu
executionMode:
kubernetesCluster:
jobManifestPath: test-job.yaml
```
test-job.yaml is a Kubernetes job
``` yaml
apiVersion: batch/v1
kind: Job
metadata:
name: test-verifier
namespace: deployment-ns
spec:
template:
spec:
containers:
- name: test-verifier
image: ubuntu
command: ["/bin/sh"]
args: ["-c", "echo 'Test fail'; exit 1"]
restartPolicy: Never
backoffLimit: 0
podFailurePolicy:
rules:
- action: FailJob
onExitCodes:
containerName: test-verifier
operator: NotIn
values: [0]
```
The exit code is not respected; it does not cause the Google Cloud deploy verify to fail. I would suppose that Skaffold is not picking up the exit code of the test-verifier container and the subsequent failure of the test-verifier job. I would expect the behavior to be the same as
```yaml
apiVersion: skaffold/v4beta13
kind: Config
verify:
- name: "verify-fail"
container:
name: test-verifier
image: ubuntu
command: ["/bin/sh"]
args: ["-c", "echo 'Test fail'; exit 1" ]
executionMode:
kubernetesCluster: {}
```
but run in the default namespace rather than in the namespace specified in the Kubernetes Job definition. This version causes Google Cloud Deploy verify to fail as expected.
Contributor guide
Assessment
This issue has not been assessed yet.