warewulf
warewulf copied to clipboard
wwctl container exec command does not pass arguments
It is not possible to pass any commandline argument which is prefixed with a -
, so for the command
wwctl container exec $CONTAINER /bin/FOO --BAAR
the commandline argument --BAAR
won't be passed to FOO
. This is a known issue with cobra, see spf13/cobra#739
As workaround, one may want to chroot to /var/lib/warewulf/chroots/$CONTAINER/rootfs
If a command like "wwctl container path $CONTAINER" could print the canonical path to chroot directory it would be helpful for scripting. Or maybe a more generic "wwctl container info" command, with output options.
Another workaround is to use double hyphen two times, so e.g. the following comand works
wwctl container exex $CONTAINER /usr/bin/ls -- -- -l -h
@mslacken I'd like to look further into this; but, since you made the workaround suggestion, can you explain why
$ sudo wwctl container exec openhpc-slurm-opa-compute-2 -- -- /bin/ls --help
works, but
$ sudo wwctl container exec openhpc-slurm-opa-compute-2 -- /bin/ls --help
does not? I'd think that, if the second example worked, then that'd be basically what other such tools do, and this could be closed.
@anderbubble The reason for the -- --
is that wwctl exec
itself calls wwctl exec __child
. So you have to use the dashes two times, as the cobra is also called two times
See https://github.com/hpcng/warewulf/blob/7b15fd4dabb87d31470b01dce87a5542236e484e/internal/app/wwctl/container/exec/main.go#L22
Still this isn't bug, but a known issue