Skip to content

Exclude stderr content from parsing UID/GID information within Docker executor

Tomasz Maczukin requested to merge 27598-fix-uid-gid-parsing-in-docker into main

What does this MR do?

  1. Splits the executors/docker/internal/exec.Docker.Exec() behavior to output separately stdout and stderr
  2. Ignores the stderr part when parsing the id -u and id -g output (fix for #27598 (closed))

Why was this MR needed?

When we were implementing the solution for #1736 (closed) we've decided to check the values of UID and GID defined for the container's run context by executing id -u and id -g commands inside of the container. And for that we've extracted the Exec() call from Docker's executor core to a dedicated package.

However, in the executor's output that is proxied directly to GitLab, Runner doesn't distinguish stdout and stderr streams. When extracting the Exec() method we've taken this behavior as is.

But as it's mentioned in #27598 (closed), stderr may get an unexpected output and for the UID/GID parsing we're in fact interested only in the normal output.

What's the best way to test this MR?

Run an image build with the following Dockerfile

FROM alpine

RUN printf '#!/bin/sh -e\necho "hello from entrypoint"\nexec "$@"\n' >> /entrypoint && chmod +x /entrypoint

ENTRYPOINT ["/entrypoint"]

CMD ["/bin/sh"]

What are the relevant issue numbers?

Closes #27598 (closed)

Edited by Steve Xuereb

Merge request reports