cross icon indicating copy to clipboard operation
cross copied to clipboard

Fix in docker_inspect_self_mountinfo() fo Gitlab runner

Open zweikaesehoch opened this issue 1 year ago • 6 comments

Crossbuilding in our buildimage on a Gitlab runner failed: image

Container ID could not be resolved from /proc/self/mountinfo, because "/docker/" string was expected, but "/docker-data/" provided: image

I extended string matching with "/docker-data/" and our pipeline is working again.

zweikaesehoch avatar Oct 07 '24 10:10 zweikaesehoch

We further investigated the error which led us to our custom data-root setting in /etc/docker/daemon.json: image

The fallback implemented due to https://github.com/cross-rs/cross/issues/1321 misses the container id because of our changed data-root to "docker-data" instead of default "docker".

The real issue here is, that docker_inspect_self_mountinfo() wont work, if data-root setting contains no "/docker/".

The current PR bears no value for other users now. One would need to parse daemon.json data-root setting to make the fallback more robust.

Pseudocode:

Look into /etc/docker/daemon.json
if data-root is set
  extract last path element as DATA_ROOT
  if DATA_ROOT not equals "/docker"
    add DATA_ROOT to OR-filter strings in line 1367

zweikaesehoch avatar Oct 07 '24 14:10 zweikaesehoch

This is currently blocking me and I have no authority over our agents. Is there something I can do as a workaround?

andrejohansson avatar Nov 18 '24 08:11 andrejohansson

This is currently blocking me and I have no authority over our agents. Is there something I can do as a workaround?

if you add -v do you get any debug messages about docker inspect found no containers matching HOSTNAME, retrying using mountinfo? if no, try setting the HOSTNAME envvar to the name of a container

I think I have a workaround, I'll create a new PR and then you and @zweikaesehoch could maybe try it

Emilgardis avatar Nov 18 '24 08:11 Emilgardis

I have also run into this issue attempting to run cross on GitHub Codespaces. It seems local devcontainers use /var/lib/docker/containers/ while on the Codespaces it uses just /containers/. The following pattern match (similar to this PR) resolved the issue and seems to handle both uses cases:

.filter(|s| s.contains("/docker/") || s.contains("/containers/"))```

although there may be a better way.

arakholia avatar Nov 21 '24 23:11 arakholia

Please give #1588 a try 👍🏼

Emilgardis avatar Nov 22 '24 00:11 Emilgardis

My workaround was to just use the cross-rs images directly as the base image in CI. No docker-in-docker.

andrejohansson avatar Nov 22 '24 20:11 andrejohansson