Update to nomad-0.11.0.

This commit is contained in:
ajacoutot 2020-04-10 11:32:50 +00:00
parent 6d721dd916
commit 153e2b341a
3 changed files with 4 additions and 181 deletions

View File

@ -1,11 +1,11 @@
# $OpenBSD: Makefile,v 1.15 2020/03/26 19:07:46 ajacoutot Exp $
# $OpenBSD: Makefile,v 1.16 2020/04/10 11:32:50 ajacoutot Exp $
# bunch of undefined things in crypto/blake2b, shirou/gopsutil/disk, shirou/gopsutil/mem
NOT_FOR_ARCHS= i386
COMMENT= cluster scheduler
GH_TAGNAME= v0.10.5
GH_TAGNAME= v0.11.0
GH_ACCOUNT= hashicorp
GH_PROJECT= nomad

View File

@ -1,2 +1,2 @@
SHA256 (nomad-0.10.5.tar.gz) = uiO8vCkTi+miAzUxEU5Ef5Ki5XoPCnvqhHNIRci4nq8=
SIZE (nomad-0.10.5.tar.gz) = 43766198
SHA256 (nomad-0.11.0.tar.gz) = SGikk7g62DPq+U97VVLR7liqGl6faiDYa697eLKCwwc=
SIZE (nomad-0.11.0.tar.gz) = 52708805

View File

@ -1,177 +0,0 @@
$OpenBSD: patch-vendor_github_com_shirou_gopsutil_cpu_cpu_openbsd_go,v 1.3 2019/10/19 15:45:27 ajacoutot Exp $
Adapted from:
https://raw.githubusercontent.com/shirou/gopsutil/master/cpu/cpu_openbsd.go
Index: vendor/github.com/shirou/gopsutil/cpu/cpu_openbsd.go
--- vendor/github.com/shirou/gopsutil/cpu/cpu_openbsd.go.orig
+++ vendor/github.com/shirou/gopsutil/cpu/cpu_openbsd.go
@@ -10,13 +10,14 @@ import (
"os/exec"
"strconv"
"strings"
+ "syscall"
"github.com/shirou/gopsutil/internal/common"
"golang.org/x/sys/unix"
)
// sys/sched.h
-const (
+var (
CPUser = 0
CPNice = 1
CPSys = 2
@@ -28,6 +29,9 @@ const (
// sys/sysctl.h
const (
CTLKern = 1 // "high kernel": proc, limits
+ CTLHw = 6 // CTL_HW
+ SMT = 24 // HW_SMT
+ NCpuOnline = 25 // HW_NCPUONLINE
KernCptime = 40 // KERN_CPTIME
KernCptime2 = 71 // KERN_CPTIME2
)
@@ -35,18 +39,52 @@ const (
var ClocksPerSec = float64(128)
func init() {
- getconf, err := exec.LookPath("/usr/bin/getconf")
- if err != nil {
- return
- }
- out, err := invoke.Command(getconf, "CLK_TCK")
- // ignore errors
- if err == nil {
- i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64)
+ func() {
+ getconf, err := exec.LookPath("getconf")
+ if err != nil {
+ return
+ }
+ out, err := invoke.Command(getconf, "CLK_TCK")
+ // ignore errors
if err == nil {
- ClocksPerSec = float64(i)
+ i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64)
+ if err == nil {
+ ClocksPerSec = float64(i)
+ }
}
+ }()
+ func() {
+ v, err := unix.Sysctl("kern.osrelease") // can't reuse host.PlatformInformation because of circular import
+ if err != nil {
+ return
+ }
+ v = strings.ToLower(v)
+ version, err := strconv.ParseFloat(v, 64)
+ if err != nil {
+ return
+ }
+ if version >= 6.4 {
+ CPIntr = 4
+ CPIdle = 5
+ CPUStates = 6
+ }
+ }()
+}
+
+func smt() (bool, error) {
+ mib := []int32{CTLHw, SMT}
+ buf, _, err := common.CallSyscall(mib)
+ if err != nil {
+ return false, err
}
+
+ var ret bool
+ br := bytes.NewReader(buf)
+ if err := binary.Read(br, binary.LittleEndian, &ret); err != nil {
+ return false, err
+ }
+
+ return ret, nil
}
func Times(percpu bool) ([]TimesStat, error) {
@@ -63,13 +101,27 @@ func TimesWithContext(ctx context.Context, percpu bool
ncpu = 1
}
+ smt, err := smt()
+ if err == syscall.EOPNOTSUPP {
+ // if hw.smt is not applicable for this platform (e.g. i386),
+ // pretend it's enabled
+ smt = true
+ } else if err != nil {
+ return nil, err
+ }
+
for i := 0; i < ncpu; i++ {
- var cpuTimes [CPUStates]int64
+ j := i
+ if !smt {
+ j *= 2
+ }
+
+ var cpuTimes = make([]int32, CPUStates)
var mib []int32
if percpu {
- mib = []int32{CTLKern, KernCptime}
+ mib = []int32{CTLKern, KernCptime2, int32(j)}
} else {
- mib = []int32{CTLKern, KernCptime2, int32(i)}
+ mib = []int32{CTLKern, KernCptime}
}
buf, _, err := common.CallSyscall(mib)
if err != nil {
@@ -88,10 +140,10 @@ func TimesWithContext(ctx context.Context, percpu bool
Idle: float64(cpuTimes[CPIdle]) / ClocksPerSec,
Irq: float64(cpuTimes[CPIntr]) / ClocksPerSec,
}
- if !percpu {
- c.CPU = "cpu-total"
+ if percpu {
+ c.CPU = fmt.Sprintf("cpu%d", j)
} else {
- c.CPU = fmt.Sprintf("cpu%d", i)
+ c.CPU = "cpu-total"
}
ret = append(ret, c)
}
@@ -106,14 +158,33 @@ func Info() ([]InfoStat, error) {
func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
var ret []InfoStat
+ var err error
c := InfoStat{}
- v, err := unix.Sysctl("hw.model")
+ var u32 uint32
+ if u32, err = unix.SysctlUint32("hw.cpuspeed"); err != nil {
+ return nil, err
+ }
+ c.Mhz = float64(u32)
+
+ mib := []int32{CTLHw, NCpuOnline}
+ buf, _, err := common.CallSyscall(mib)
if err != nil {
return nil, err
}
- c.ModelName = v
+
+ var ncpu int32
+ br := bytes.NewReader(buf)
+ err = binary.Read(br, binary.LittleEndian, &ncpu)
+ if err != nil {
+ return nil, err
+ }
+ c.Cores = ncpu
+
+ if c.ModelName, err = unix.Sysctl("hw.model"); err != nil {
+ return nil, err
+ }
return append(ret, c), nil
}