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

Under hardenedBSD(freebsd downstream) nomad does not run. #5950

Closed
peacetara opened this issue Jul 11, 2019 · 4 comments
Closed

Under hardenedBSD(freebsd downstream) nomad does not run. #5950

peacetara opened this issue Jul 11, 2019 · 4 comments

Comments

@peacetara
Copy link

peacetara commented Jul 11, 2019

Issue

Under HardenedBSD(which is a downstream fork of FreeBSD), the memory system is hardened and the 32bit compat code is taken out. This means that the gopsutil fingerprinting under nomad fails:

2019-07-11T11:00:18.218-0700 [WARN ] client.fingerprint_mgr.memory: error reading memory information: error="cannot allocate memory"

which happens on this call (kdump output):

83482 nomad    SCTL  "vfs.bufspace"
83482 nomad    RET   __sysctl -1 errno 12 Cannot allocate memory

This call fails because go expects a uint32, but it's actually a uint64 in size.

Solutions

upsteam gopsutil properly uses a uint64 here

but gopsutil is vendored with an older version that uses uint32 here.

It looks like there was some work recently in #5201 to upgrade gopsutil. I'd like you to perhaps re-apply that patch and upgrade your vendored gopsutil.

Alternatively, one can apply this patch:

diff --git a/vendor/github.com/shirou/gopsutil/mem/mem_freebsd.go b/vendor/github.com/shirou/gopsutil/mem/mem_freebsd.go
index e691227db..fcb4c3668 100644
--- a/vendor/github.com/shirou/gopsutil/mem/mem_freebsd.go
+++ b/vendor/github.com/shirou/gopsutil/mem/mem_freebsd.go
@@ -41,7 +41,7 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
        if err != nil {
                return nil, err
        }
-       buffers, err := unix.SysctlUint32("vfs.bufspace")
+       buffers, err := unix.SysctlUint64("vfs.bufspace")
        if err != nil {
                return nil, err
        }

Which fixes the problem. I understand HardenedBSD is not officially supported, and so maybe you don't care much, except uint32 is apparently even wrong under FreeBSD. It currently works under FreeBSD because of compat code to let a uint32 work. That compat code will probably go away at some point :)

Anyways, for the adventurous among us, one can change the call like in the diff above in the meantime. if you want your HardenedBSD and Nomad to co-exist.

thanks to lattera & newnix in #HardenedBSD for their help.

Thanks for your time and consideration.

@preetapan
Copy link
Contributor

@peacetara Thanks for the report. Given the surface area of usage of gopsutil we would do a vendor upgrade in a major release, will consider this ticket then.

@tgross tgross added this to the 0.11.0 milestone Dec 9, 2019
@tgross
Copy link
Member

tgross commented Feb 13, 2020

Will be completed by #6957

@schmichael
Copy link
Member

@peacetara Can you test Nomad 0.11.0-rc1 or later and confirm that this works? https://releases.hashicorp.com/nomad/

Closing for now because it ought to have fixed your issue, but please reopen if not!

@github-actions
Copy link

github-actions bot commented Nov 9, 2022

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 Nov 9, 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

4 participants