Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make generate fails under podman due to unset $HOME, and is subtly broken under docker #9089

Closed
intelfx opened this issue Dec 22, 2023 · 1 comment
Assignees
Milestone

Comments

@intelfx
Copy link
Contributor

intelfx commented Dec 22, 2023

Invoking make generate (or, equivalently, .dapper generate) fails at go generate:

Unmodified tree build log with podman

make-generate.log

$ make generate
./.dapper generate
<...>
COMMIT k3s:master
--> c5d9ede7f540
Successfully tagged localhost/k3s:master
c5d9ede7f5401ce8ec923b746df13e3510c573a975a9b650c367e1980a3ce6c5
Running: go generate
go: downloading github.com/sirupsen/logrus v1.9.3
<...>
go: downloading github.com/gofrs/uuid v4.4.0+incompatible
build cache is required, but could not be located: GOCACHE is not defined and neither $XDG_CACHE_HOME nor $HOME are defined
main.go:1: running "go": exit status 1
FATA[0074] exit status 1
make: *** [Makefile:13: generate] Error 1

This presumably happens because Dockerfile.dapper sets HOME=${DAPPER_SOURCE} in the same statement as DAPPER_SOURCE=..., which is then not substituted correctly. The problem is not immediately visible on docker only because docker resets an unset $HOME to /root:

Patched tree build log with docker, with changes to make the problem visible

make-generate-docker.log

$ git diff
diff --git a/Dockerfile.dapper b/Dockerfile.dapper
index af99d3d35e..81b5af3184 100644
--- a/Dockerfile.dapper
+++ b/Dockerfile.dapper
@@ -56,7 +56,7 @@ ENV DAPPER_RUN_ARGS="--privileged -v k3s-cache:/go/src/github.com/k3s-io/k3s/.ca
     DAPPER_SOURCE="/go/src/github.com/k3s-io/k3s/" \
     DAPPER_OUTPUT="./bin ./dist ./build/out ./build/static ./pkg/static ./pkg/deploy" \
     DAPPER_DOCKER_SOCKET=true \
-    HOME=${DAPPER_SOURCE} \
+    HOME= \
     CROSS=true \
     STATIC_BUILD=true

diff --git a/scripts/generate b/scripts/generate
index ebdaf31cc5..142592f36f 100755
--- a/scripts/generate
+++ b/scripts/generate
@@ -8,4 +8,6 @@ mkdir -p build/data
 GO=${GO-go}

 echo Running: "${GO}" generate
+env | grep HOME=
+exit 1
 "${GO}" generate

$ make generate
./.dapper generate
<...>
Successfully tagged k3s:master

Running: go generate
HOME=/root
FATA[0002] exit status 1
make: *** [Makefile:13: generate] Error 1

Still, this causes the Go cache (mounted at /go/src/github.com/k3s-io/k3s/.cache) to be effectively broken and unused because $HOME doesn't point to it.

intelfx added a commit to intelfx/k3s that referenced this issue Dec 22, 2023
$HOME refers to $DAPPER_SOURCE, which is set in the same expression and
is thus not visible at the time of substitution.

This problem is not immediately visible with Docker, Inc.'s docker
merely because it resets an unset `$HOME` to `/root` (but still breaking
the Go cache). Under podman, this problem is immediately visible because
an unset `$HOME` remains unset and subsequently breaks the `go generate`
invocation.

Fixes k3s-io#9089.
intelfx added a commit to intelfx/k3s that referenced this issue Dec 22, 2023
`$HOME` refers to `$DAPPER_SOURCE`, which is set in the same expression
and is thus not visible at the time of substitution.

This problem is not immediately visible with Docker, Inc.'s docker
merely because it resets an unset `$HOME` to `/root` (but still breaking
the Go cache). Under podman, this problem is immediately visible because
an unset `$HOME` remains unset and subsequently breaks the `go generate`
invocation.

Fixes k3s-io#9089.

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
@brandond brandond added this to the v1.29.1+k3s1 milestone Jan 3, 2024
@brandond
Copy link
Member

brandond commented Jan 3, 2024

Not sure this needs any other testing, since it's just used at build time.

brandond pushed a commit to brandond/k3s that referenced this issue Jan 10, 2024
`$HOME` refers to `$DAPPER_SOURCE`, which is set in the same expression
and is thus not visible at the time of substitution.

This problem is not immediately visible with Docker, Inc.'s docker
merely because it resets an unset `$HOME` to `/root` (but still breaking
the Go cache). Under podman, this problem is immediately visible because
an unset `$HOME` remains unset and subsequently breaks the `go generate`
invocation.

Fixes k3s-io#9089.

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
(cherry picked from commit a7fe1aa)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
brandond pushed a commit to brandond/k3s that referenced this issue Jan 10, 2024
`$HOME` refers to `$DAPPER_SOURCE`, which is set in the same expression
and is thus not visible at the time of substitution.

This problem is not immediately visible with Docker, Inc.'s docker
merely because it resets an unset `$HOME` to `/root` (but still breaking
the Go cache). Under podman, this problem is immediately visible because
an unset `$HOME` remains unset and subsequently breaks the `go generate`
invocation.

Fixes k3s-io#9089.

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
(cherry picked from commit a7fe1aa)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
brandond pushed a commit to brandond/k3s that referenced this issue Jan 10, 2024
`$HOME` refers to `$DAPPER_SOURCE`, which is set in the same expression
and is thus not visible at the time of substitution.

This problem is not immediately visible with Docker, Inc.'s docker
merely because it resets an unset `$HOME` to `/root` (but still breaking
the Go cache). Under podman, this problem is immediately visible because
an unset `$HOME` remains unset and subsequently breaks the `go generate`
invocation.

Fixes k3s-io#9089.

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
(cherry picked from commit a7fe1aa)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
brandond pushed a commit to brandond/k3s that referenced this issue Jan 10, 2024
`$HOME` refers to `$DAPPER_SOURCE`, which is set in the same expression
and is thus not visible at the time of substitution.

This problem is not immediately visible with Docker, Inc.'s docker
merely because it resets an unset `$HOME` to `/root` (but still breaking
the Go cache). Under podman, this problem is immediately visible because
an unset `$HOME` remains unset and subsequently breaks the `go generate`
invocation.

Fixes k3s-io#9089.

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
(cherry picked from commit a7fe1aa)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
brandond pushed a commit to brandond/k3s that referenced this issue Jan 10, 2024
`$HOME` refers to `$DAPPER_SOURCE`, which is set in the same expression
and is thus not visible at the time of substitution.

This problem is not immediately visible with Docker, Inc.'s docker
merely because it resets an unset `$HOME` to `/root` (but still breaking
the Go cache). Under podman, this problem is immediately visible because
an unset `$HOME` remains unset and subsequently breaks the `go generate`
invocation.

Fixes k3s-io#9089.

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
(cherry picked from commit a7fe1aa)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
brandond pushed a commit that referenced this issue Jan 12, 2024
`$HOME` refers to `$DAPPER_SOURCE`, which is set in the same expression
and is thus not visible at the time of substitution.

This problem is not immediately visible with Docker, Inc.'s docker
merely because it resets an unset `$HOME` to `/root` (but still breaking
the Go cache). Under podman, this problem is immediately visible because
an unset `$HOME` remains unset and subsequently breaks the `go generate`
invocation.

Fixes #9089.

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
(cherry picked from commit a7fe1aa)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
brandond pushed a commit that referenced this issue Jan 12, 2024
`$HOME` refers to `$DAPPER_SOURCE`, which is set in the same expression
and is thus not visible at the time of substitution.

This problem is not immediately visible with Docker, Inc.'s docker
merely because it resets an unset `$HOME` to `/root` (but still breaking
the Go cache). Under podman, this problem is immediately visible because
an unset `$HOME` remains unset and subsequently breaks the `go generate`
invocation.

Fixes #9089.

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
(cherry picked from commit a7fe1aa)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
brandond pushed a commit that referenced this issue Jan 12, 2024
`$HOME` refers to `$DAPPER_SOURCE`, which is set in the same expression
and is thus not visible at the time of substitution.

This problem is not immediately visible with Docker, Inc.'s docker
merely because it resets an unset `$HOME` to `/root` (but still breaking
the Go cache). Under podman, this problem is immediately visible because
an unset `$HOME` remains unset and subsequently breaks the `go generate`
invocation.

Fixes #9089.

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
(cherry picked from commit a7fe1aa)
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
@VestigeJ VestigeJ self-assigned this Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done Issue
Development

No branches or pull requests

3 participants