From 54f80102b0245ae7ca37103dafcf63c52ea47c89 Mon Sep 17 00:00:00 2001 From: Bruce Ashfield Date: Fri, 15 Mar 2024 19:06:05 +0000 Subject: k3s: set version.UpstreamGolang in binaries k3s will refuse to start if the golang version it was built with doesn't match the VERSION_GOLANG linker variable. As an example: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/61668 We query our version of the compiler and set it in the binaries to ensure they match. Note: this may cause issues if you bump the golang compiler, but k3s doesn't rebuild. We'll worry about that when it happens. With this change, k3s starts and the node becomes ready. root@qemux86-64:~# uname -a Linux qemux86-64 6.6.20-yocto-standard #1 SMP PREEMPT_DYNAMIC Sun Mar 3 16:28:22 UTC 2024 x86_64 GNU/Linux root@qemux86-64:~# kubectl get nodes NAME STATUS ROLES AGE VERSION qemux86-64 Ready control-plane,master 10m v1.28.7-k3s1 Signed-off-by: Bruce Ashfield --- recipes-containers/k3s/k3s_git.bb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes-containers/k3s/k3s_git.bb b/recipes-containers/k3s/k3s_git.bb index 93a44e33..e33cb44b 100644 --- a/recipes-containers/k3s/k3s_git.bb +++ b/recipes-containers/k3s/k3s_git.bb @@ -76,7 +76,8 @@ do_compile() { cp ${WORKDIR}/modules.txt vendor/ - ${GO} build -trimpath -tags "$TAGS" -ldflags "${GO_BUILD_LDFLAGS} -w -s" -o ./dist/artifacts/k3s ./cmd/server/main.go + VERSION_GOLANG="$(go version | cut -d" " -f3)" + ${GO} build -trimpath -tags "$TAGS" -ldflags "-X github.com/k3s-io/k3s/pkg/version.UpstreamGolang=$VERSION_GOLANG ${GO_BUILD_LDFLAGS} -w -s" -o ./dist/artifacts/k3s ./cmd/server/main.go # Use UPX if it is enabled (and thus exists) to compress binary if command -v upx > /dev/null 2>&1; then -- cgit v1.2.3-54-g00ecf