Skip to content

Commit

Permalink
drivers: fix capabilities on non-linux systems (#24450)
Browse files Browse the repository at this point in the history
Recently we moved from github.com/syndtr/gocapability to
github.com/moby/sys/capability due to the former package no longer being
maintainer. The new package's capability function works differently: the
known/supported functionality is split now, and the .ListSupported() call will
always return an empty list on non-linux systems. This means Nomad agents won't
start on darwin or windows.
  • Loading branch information
pkazmierczak authored Nov 13, 2024
1 parent ff8ca8a commit 5dfb38d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion drivers/shared/capabilities/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package capabilities
import (
"fmt"
"regexp"
"runtime"

"github.com/moby/sys/capability"
)
Expand Down Expand Up @@ -40,7 +41,17 @@ func NomadDefaults() *Set {
func Supported() *Set {
s := New(nil)

list, _ := capability.ListSupported()
var list []capability.Cap

switch runtime.GOOS {
case "linux":
list, _ = capability.ListSupported()
default:
// capability.ListSupported() will always return an empty list on
// non-linux systems
list = capability.ListKnown()
}

// accumulate every capability supported by this system
for _, c := range list {
s.Add(c.String())
Expand Down

0 comments on commit 5dfb38d

Please sign in to comment.