Open dleehr opened 5 years ago
The tool specifies the bash:4.4.12
container, which has an ENTRYPOINT set: https://github.com/tianon/docker-bash/blob/3682e16bca63b20ab51745afa30156e2740fc5c6/4.4/Dockerfile#L126
When calrissian builds up a container to run, it appears to be providing the command in a way that's not compatible with the entrypoint.
YAML from the pod created to run this tool:
apiVersion: v1
kind: Pod
metadata:
name: docker-run-cmd-cwl-pod-bczhwgdg
namespace: default
spec:
containers:
- args:
- -c 'echo '"'"'moo'"'"' > cow'
command:
- /bin/sh
- -c
env:
- name: HOME
value: /YgEWAF
- name: TMPDIR
value: /tmp
image: bash:4.4.12
imagePullPolicy: IfNotPresent
name: docker-run-cmd-cwl-container
resources:
requests:
cpu: "1"
memory: 8Mi
volumeMounts:
- mountPath: /YgEWAF
name: conformance-output-data
subPath: mlq5pjta
- mountPath: /tmp
name: tmpdir
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: default-token-9wdfw
readOnly: true
workingDir: /YgEWAF
volumes:
- name: conformance-test-data
persistentVolumeClaim:
claimName: conformance-test-data
readOnly: true
- name: conformance-output-data
persistentVolumeClaim:
claimName: conformance-output-data
- emptyDir: {}
name: tmpdir
- name: default-token-9wdfw
According to https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes:
Docker Entrypoint
= Kubernetes command
Docker Cmd
= Kubernetes args
We're building both in KubernetesPodBuilder
:
At first glance it might seem like we could straighten this out cleanly, but as mentioned in the comments, we need to provide the command as a space-separated string, and needs to be an argument to a shell. Otherwise we cannot redirect easily inside the container.
It might work to push the ['/bin/sh','-c']
into the args and leave container_command totally empty.
I tried removing the command
from the container spec, and pushing ['/bin/sh', '-c']
to the front of args. This stops us from stomping on the entrypoint, and doesn't fail any additional conformance tests. But 173 still fails because calrissian inserts /bin/sh -c
in between the entrypoint and the tool command:
containers:
- args:
- /bin/sh
- -c
- -c 'echo '"'"'moo'"'"' > cow'
Seems like there's no clean/simple way out of this. We wrap commands in a shell (sh -c
) because that's the only way to setup redirection to STDOUT and STDERR differently in kubernetes (see b956f7ebf18b24266670d366c366e11836239e2c and 09261991d08894d0dcd57e7a362beeb498c1b213). That approach works in most cases, but not where the entrypoint and the command can't be separated.
One path would be to inspect the image and incorporate its entrypoint, but that's not a terribly robust solution. I think the only clean solution here would be if we had another way to redirect without using a shell. That would let us simplify args down to just the Job's command_line