projectcalico / calico

Cloud native networking and network security
https://docs.tigera.io/calico/latest/about/
Apache License 2.0
6.04k stars 1.35k forks source link

Add RUN_AS_ROOT Docker args to cni-plugin commands. #9455

Closed oberonv1 closed 2 weeks ago

oberonv1 commented 2 weeks ago

Description

Hi, developer from the GKE Networking team here hoping to fix a minor bug. GKE builds the cni-plugin image as root and therefore has UID=0. When UID=0, we get the following error:

docker run \
    -v /workspace/louhi_ws/go/src/github.com/projectcalico/calico/cni-plugin/flannel-cni-plugin:/go/src/github.com/flannel-io/cni-plugin:z \
    -e LOCAL_USER_ID=0 -w /go/src/github.com/flannel-io/cni-plugin --rm calico/go-build:v0.91 \
    /bin/sh -xe -c ' \
        ARCH=amd64 VERSION=v1.2.0-flannel2-go1.22.7 make build_linux'
Starting with UID: 0
useradd: UID 0 is not unique
su-exec: getpwnam(user): Success
make: *** [Makefile:173: bin/amd64/flannel] Error 1
make: Leaving directory '/workspace/louhi_ws/go/src/github.com/projectcalico/calico/cni-plugin'
 "gcr.io/louhi-prod-1/addon-builder" failed: step exited with non-zero status: 2

RUN_AS_ROOT='true' is added to the EXTRA_DOCKER_ARGS when UID=0 in lib.Makefile: https://github.com/projectcalico/calico/blob/master/lib.Makefile#L235-L238

We added the EXTRA_DOCKER_ARGS to the Makefile rules installing the CNI binaries without issue internally and the change passes all GKE e2e testing. We'd like to upstream this change to avoid having to carry it internally indefinitely.

Release Note

Add RUN_AS_ROOT Docker args to cni-plugin commands.

Reminder for the reviewer

Make sure that this PR has the correct labels and milestone set.

Every PR needs one docs-* label.

Every PR needs one release-note-* label.

Other optional labels:

caseydavenport commented 2 weeks ago

/sem-approve