Repository navigation
Conversation
a0a1908 to
36be14c
Compare
|
The failing jobs aren't failing in |
36be14c to
76b115f
Compare
|
Needs rebasing |
Add nerdctl compose attach, like docker compose attach: it attaches to the container of a service by running nerdctl attach on it. --index selects the container when the service has several instances, and --detach-keys and --no-stdin are passed to nerdctl attach. Like nerdctl attach, it needs a container created with stdin_open and tty. compose up runs such a service in the foreground, like nerdctl run -it, so the test detaches from it with the detach keys. The container lookup is moved from Exec into a serviceContainer helper shared by both commands. Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
76b115f to
2695bab
Compare
|
Rebased on main after #5301 merged; the only conflict was the command registration. |
Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
|
The almalinux-8 failure was my test. Attach took more than 3s to connect there, so the command and the detach keys arrived together. a25d232 waits before sending the command too. |
Waiting before sending the command made the attach test lose the output in the in-host jobs, so go back to feeding it right away like TestAttach does. Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
|
Reverted that wait in 78b2a6a, it made the attach test lose its output on the in-host jobs. The test now matches the version that passed the test workflow, and the almalinux-8 job is in the flaky workflow. |
compose attach loads the project before it runs nerdctl attach, which can take several seconds on slow runners, and input that is pending together with the detach keys when nerdctl attach starts can get lost. Send the command once a second for a while before detaching, so a later one reaches the container whenever attach is up. Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
|
The revert still failed on the rootless jobs, so 51ca1c9 sends the command once a second for a while before detaching. When compose takes a few seconds to start nerdctl attach, the input and the detach keys end up racing, like the note in TestAttach says. |
Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
I added
nerdctl compose attach, one more Compose command listed as unimplemented in the command reference (tracked in #3867).It follows
docker compose attach:nerdctl compose attach SERVICEattaches to the service's container by runningnerdctl attachon it, likecompose execrunsnerdctl exec.--indexselects the container when the service has several instances (default 1).--detach-keysand--no-stdinare passed through tonerdctl attach.nerdctl attach, it needs a container created withstdin_open: trueandtty: true. Otherwise the container logs through the logging binary and there is no fifo to attach to.compose upruns such a service in the foreground, likenerdctl run -it, so you detach from it with ctrl-p ctrl-q before attaching. I noted both in the command reference.To avoid duplicating the container lookup, I moved it from
Composer.Execinto aserviceContainerhelper that both commands use. Exec's behavior and error messages are unchanged.Changes:
pkg/composer/attach.go:Composer.Attachpkg/composer/exec.go: the sharedserviceContainerhelpercmd/nerdctl/compose/compose_attach.go: the commandcmd/nerdctl/compose/compose_attach_linux_test.go: tests for an out-of-range index, and for attaching to a service withstdin_openandttythrough a pseudo-TTY (start the project under a pseudo-TTY and detach fromcompose up, then attach, send a command, check its output and detach with ctrl-p ctrl-q), followingTestAttachdocs/command-reference.md: documented the command and removed it from the unimplemented listNotes
I ran the compose integration tests locally, rootful, in a privileged container with nerdctl, containerd, runc, CNI and BuildKit built from this branch (
docker buildx build --target out-full):It passed in three runs in a row. Running the whole
./cmd/nerdctl/compose/package found one problem in an earlier version of this PR, which I fixed: starting the service withrun -ditleaves nothing to attach to (failed to open stdout fifo), so the test now detaches fromcompose upinstead. With that earlier version the other 77 compose tests passed. Rootless is only covered by CI.Like #5300 and #5301, this adds a line to the compose command list, so a trivial rebase may be needed depending on merge order.