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

Static build nomad #13388

Closed
chairwa opened this issue Jun 16, 2022 · 2 comments
Closed

Static build nomad #13388

chairwa opened this issue Jun 16, 2022 · 2 comments

Comments

@chairwa
Copy link

chairwa commented Jun 16, 2022

Hashicorp consul is released in static building binary, while nomad binary is dynamic.
I myself tried to static compile nomad in the following way, and run on Android 9 (although not officially support)

Nomad version

Nomad v1.3.2-dev (da9f22f+CHANGES)

Operating system and Environment details

compile-time : Ubuntu 16.04.7 LTS aarch64
runtime : Android 9

Issue

change GNUmakefile to build nomad statically
-GO_LDFLAGS := "-X github.com/hashicorp/nomad/version.GitCommit=$(GIT_COMMIT)$(GIT_DIRTY)"
+GO_LDFLAGS := "-X github.com/hashicorp/nomad/version.GitCommit=$(GIT_COMMIT)$(GIT_DIRTY) -extldflags '-static'"

make pkg/linux_arm64/nomad
==> Building pkg/linux_arm64/nomad with tags ui ...
/tmp/go-link-483762744/000008.o:In function ‘mygetgrouplist’:
//os/user/getgrouplist_unix.go:15: Warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-483762744/000007.o:In function ‘mygetgrgid_r’:
/
/os/user/cgo_lookup_unix.go:37: Warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-483762744/000007.o:In function ‘mygetgrnam_r’:
//os/user/cgo_lookup_unix.go:42: Warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-483762744/000007.o:In function ‘mygetpwnam_r’:
/
/os/user/cgo_lookup_unix.go:32: Warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-483762744/000007.o:In function ‘mygetpwuid_r’:
/_/os/user/cgo_lookup_unix.go:27: Warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-483762744/000004.o:In function ‘_cgo_6cc2654a8ed3_C2func_getaddrinfo’:
/tmp/go-build/cgo-gcc-prolog:58: Warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

Run the static binary on Android as client, connected to cloud nomad server OK

Reproduction steps

Expected Result

Compiling OK
Running OK

Actual Result

Compiling with warning
Running with partial error

Job file (if appropriate)

Nomad Server logs (if appropriate)

nomad node status 08611e8d
Driver Status = mock_driver
Node Events
Time Subsystem Message
2022-06-16T14:33:49+08:00 Cluster Node reregistered by heartbeat
2022-06-16T14:33:36+08:00 Cluster Node heartbeat missed
2022-06-16T14:31:04+08:00 Cluster Node reregistered by heartbeat
2022-06-16T14:30:18+08:00 Cluster Node heartbeat missed
2022-06-16T14:25:35+08:00 Cluster Node registered

Nomad Client logs (if appropriate)

2022-06-16T07:00:00.413Z [ERROR] client.rpc: error performing RPC to server: error="rpc error: EOF" rpc=Node.GetClientAllocs server=124.222.220.96:4647
2022-06-16T07:00:00.837Z [ERROR] client.rpc: error performing RPC to server: error="rpc error: failed to get conn: EOF" rpc=Node.GetClientAllocs server=124.222.220.96:4647
2022-06-16T07:00:00.838Z [ERROR] client.rpc: error performing RPC to server which is not safe to automatically retry: error="rpc error: failed to get conn: EOF" rpc=Node.GetClientAllocs server=124.222.220.96:4647
2022-06-16T07:00:00.838Z [ERROR] client: error querying node allocations: error="rpc error: failed to get conn: EOF"
2022-06-16T07:00:12.279Z [ERROR] client.rpc: error performing RPC to server: error="rpc error: failed to get conn: EOF" rpc=Node.UpdateStatus server=124.222.220.96:4647
2022-06-16T07:00:12.280Z [ERROR] client.rpc: error performing RPC to server which is not safe to automatically retry: error="rpc error: failed to get conn: EOF" rpc=Node.UpdateStatus server=124.222.220.96:4647
2022-06-16T07:00:12.280Z [ERROR] client: error heartbeating. retrying: error="failed to update status: rpc error: failed to get conn: EOF" period=1.93388765s
@DerekStrickland
Copy link
Contributor

Hi @chairwa. Thanks for using Nomad and for submitting this issue!

This issue appears to be a duplicate of #5643. We document the challenge in contributing/cgo.md. Here's what that says:

"Nomad requires the use of CGO on Linux.

Issue #5643 tracks the desire for Nomad to not require CGO.

One of the core features of Nomad (the exec driver) depends on nsenter.
Until nsenter no longer requires CGO, the standalone Nomad executable on Linux will not be able to ship without depending on CGO."

I'm going to close this as a duplicate, but if you've got more ideas about how to resolve this dependency, we'd welcome input or PRs for that issue.

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants