warewulf icon indicating copy to clipboard operation
warewulf copied to clipboard

wwctl container exec command does not pass arguments

Open mslacken opened this issue 3 years ago • 5 comments

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

mslacken avatar Jan 24 '22 13:01 mslacken

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.

jcsiadal avatar Jan 25 '22 05:01 jcsiadal

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 avatar Jan 26 '22 08:01 mslacken

@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 avatar Dec 18 '22 07:12 anderbubble

@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

mslacken avatar Dec 19 '22 09:12 mslacken

Still this isn't bug, but a known issue

mslacken avatar Sep 29 '23 10:09 mslacken