cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.8k stars 379 forks source link

probe for root dir instead of guessing #1588

Open Emilgardis opened 1 week ago

Emilgardis commented 1 week ago

Alternative to #1569

try this by doing cargo install cross --git https://github.com/cross-rs/cross --branch fix-mountinfov2

arakholia commented 4 days ago

Following up to https://github.com/cross-rs/cross/pull/1569#issuecomment-2492612588 here.

Unfortunately, this still didn't work in codespace (although it did work in local dev container). Same error:

# cross build --target armv7-unknown-linux-musleabihf --verbose
+ cargo metadata --format-version 1 --filter-platform armv7-unknown-linux-musleabihf
+ rustc --print sysroot
+ /usr/bin/docker
+ /usr/bin/docker version -f '{{ .Server.Os }},,,{{ .Server.Arch }}'
+ /usr/bin/docker info -f {{.SecurityOptions}}
+ rustup toolchain list
+ rustup target list --toolchain nightly-x86_64-unknown-linux-gnu
+ rustup component list --toolchain nightly-x86_64-unknown-linux-gnu
+ /usr/bin/docker inspect codespaces-439fb6
docker inspect found no containers matching HOSTNAME, retrying using mountinfo
attempting to use /proc/self/mountinfo to find container id
+ /usr/bin/docker info --format {{.DockerRootDir}}
Error: 
   0: couldn't find container id in mountinfo

Location:
   src/docker/shared.rs:1374

The issue seems to be that while I have Docker Root Dir: /var/lib/docker, /proc/self/mountinfo does not contain this path.

Here are the various dumps:

# docker info
Client: Docker Engine - Community
 Version:    27.3.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.17.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.30.3
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 24.0.9-2
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 88c3d9bc5b5a193f40b7c14fa996d23532d6f956
 runc version: bc20cb4497af9af01bea4a8044f1678ffca2745c
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.5.0-1025-azure
 Operating System: Ubuntu 22.04.5 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 7.744GiB
 Name: b731330a-a31e-4579-8437-1e182c507c34
 ID: cbda55b0-d789-4adb-85cb-d10b6f817007
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: codespacesdev
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
# cat /proc/self/mountinfo
728 675 0:46 / / rw,relatime - overlay overlay rw,lowerdir=/var/lib/docker/overlay2/l/AFUJF3HYLZHJNK4OV54KXVGQW5:/var/lib/docker/overlay2/l/VUADTRZ3AA2ZTUDPFPQR4VYIRO:/var/lib/docker/overlay2/l/NFUHFEEP6UMKMCUBBRU3PYHPC3:/var/lib/docker/overlay2/l/XTY65DJVA4OWXGL4BBLCVHSX2Y:/var/lib/docker/overlay2/l/2EOALKEXVVC24KITOSBRQM5XGX:/var/lib/docker/overlay2/l/Y65OLF4OU75IPRZOT7FI2IZ4FV:/var/lib/docker/overlay2/l/ZFC6D7YFU7DBP6G3DAJ5UTCZ5V:/var/lib/docker/overlay2/l/3LN3UNRIPRD6IALTY6QLIBD4ZA:/var/lib/docker/overlay2/l/HUAAIEDL7BZ6XTDTORY6EKG4BK:/var/lib/docker/overlay2/l/CPHP5XOT3NJ2XQBEXNGQTRNHZH:/var/lib/docker/overlay2/l/X4ZEFS2BJ5CP6KIGDQPMIP4TWT:/var/lib/docker/overlay2/l/L5FJKGBWBJYQF2DQKJCMUI5JRN,upperdir=/var/lib/docker/overlay2/b14e9c8d053c2c08fa4093e8208916f51f1e4626f49ea277fc91534b2617b2ff/diff,workdir=/var/lib/docker/overlay2/b14e9c8d053c2c08fa4093e8208916f51f1e4626f49ea277fc91534b2617b2ff/work,nouserxattr
729 728 0:49 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
730 728 0:50 / /dev rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755,inode64
731 730 0:51 / /dev/pts rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=666
732 728 0:23 / /sys ro,nosuid,nodev,noexec,relatime - sysfs sysfs rw
733 732 0:28 / /sys/fs/cgroup ro,nosuid,nodev,noexec,relatime - cgroup2 cgroup rw
734 730 0:48 / /dev/mqueue rw,nosuid,nodev,noexec,relatime - mqueue mqueue rw
735 730 0:52 / /dev/shm rw,nosuid,nodev,noexec,relatime - tmpfs shm rw,size=65536k,inode64
736 728 8:1 /containerTmp /tmp rw,relatime - ext4 /dev/sda1 rw
737 728 8:33 /.codespaces/agent/mount/cache /vscode rw,relatime - ext4 /dev/root rw,discard,errors=remount-ro
738 728 7:4 /codespacemount/workspace /workspaces rw,nodev,relatime master:279 - ext4 /dev/loop4 rw
739 728 8:33 /.codespaces/agent/mount /.codespaces/bin rw,relatime - ext4 /dev/root rw,discard,errors=remount-ro
740 728 7:4 /containers/d0ca26db78fc5bd0f6bc1ce668c42e9f0759a3262eda6efcb2b4bc0cdc4ed7ad/resolv.conf /etc/resolv.conf rw,nodev,relatime - ext4 /dev/loop4 rw
741 728 7:4 /containers/d0ca26db78fc5bd0f6bc1ce668c42e9f0759a3262eda6efcb2b4bc0cdc4ed7ad/hostname /etc/hostname rw,nodev,relatime - ext4 /dev/loop4 rw
742 728 7:4 /containers/d0ca26db78fc5bd0f6bc1ce668c42e9f0759a3262eda6efcb2b4bc0cdc4ed7ad/hosts /etc/hosts rw,nodev,relatime - ext4 /dev/loop4 rw
743 728 0:26 /docker.sock /run/docker-host.sock rw,nosuid,nodev - tmpfs tmpfs rw,size=1623976k,nr_inodes=819200,mode=755,inode64
744 738 8:33 /root/.codespaces/shared /workspaces/.codespaces/shared rw,relatime - ext4 /dev/root rw,discard,errors=remount-ro
745 738 7:4 /codespacemount/.persistedshare /workspaces/.codespaces/.persistedshare rw,nodev,relatime master:279 - ext4 /dev/loop4 rw
676 729 0:49 /bus /proc/bus ro,nosuid,nodev,noexec,relatime - proc proc rw
677 729 0:49 /fs /proc/fs ro,nosuid,nodev,noexec,relatime - proc proc rw
678 729 0:49 /irq /proc/irq ro,nosuid,nodev,noexec,relatime - proc proc rw
679 729 0:49 /sys /proc/sys ro,nosuid,nodev,noexec,relatime - proc proc rw
680 729 0:49 /sysrq-trigger /proc/sysrq-trigger ro,nosuid,nodev,noexec,relatime - proc proc rw
681 729 0:53 / /proc/acpi ro,relatime - tmpfs tmpfs ro,inode64
682 729 0:50 /null /proc/kcore rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755,inode64
683 729 0:50 /null /proc/keys rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755,inode64
684 729 0:50 /null /proc/timer_list rw,nosuid - tmpfs tmpfs rw,size=65536k,mode=755,inode64
685 729 0:54 / /proc/scsi ro,relatime - tmpfs tmpfs ro,inode64
686 732 0:55 / /sys/firmware ro,relatime - tmpfs tmpfs ro,inode64

Filtering by actual container ID:

# cat /proc/self/mountinfo | grep d0ca26db78fc
740 728 7:4 /containers/d0ca26db78fc5bd0f6bc1ce668c42e9f0759a3262eda6efcb2b4bc0cdc4ed7ad/resolv.conf /etc/resolv.conf rw,nodev,relatime - ext4 /dev/loop4 rw
741 728 7:4 /containers/d0ca26db78fc5bd0f6bc1ce668c42e9f0759a3262eda6efcb2b4bc0cdc4ed7ad/hostname /etc/hostname rw,nodev,relatime - ext4 /dev/loop4 rw
742 728 7:4 /containers/d0ca26db78fc5bd0f6bc1ce668c42e9f0759a3262eda6efcb2b4bc0cdc4ed7ad/hosts /etc/hosts rw,nodev,relatime - ext4 /dev/loop4 rw

Not a priority issue for me, since I simply set $HOSTNAME to the container ID derived from this file (by matching against /containers/). Not ideal but it works.

PS: I forgot to mention Docker is enabled by the "ghcr.io/devcontainers/features/docker-outside-of-docker:1" feature in dev container.