-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport of client/fingerprint: correctly fingerprint E/P cores of Ap…
…ple Silicon chips into release/1.5.x (#16690) This pull request was automerged via backport-assistant
- Loading branch information
1 parent
90ba690
commit d76453a
Showing
15 changed files
with
296 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:improvement | ||
fingerprint/cpu: correctly fingerprint P/E cores of Apple Silicon chips | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//go:build darwin && arm64 && cgo | ||
|
||
package fingerprint | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/nomad/ci" | ||
"github.com/hashicorp/nomad/client/config" | ||
"github.com/hashicorp/nomad/helper/testlog" | ||
"github.com/hashicorp/nomad/nomad/structs" | ||
"github.com/shoenig/test/must" | ||
) | ||
|
||
func TestCPUFingerprint_AppleSilicon(t *testing.T) { | ||
ci.Parallel(t) | ||
|
||
f := NewCPUFingerprint(testlog.HCLogger(t)) | ||
node := &structs.Node{Attributes: make(map[string]string)} | ||
|
||
request := &FingerprintRequest{Config: new(config.Config), Node: node} | ||
var response FingerprintResponse | ||
|
||
err := f.Fingerprint(request, &response) | ||
must.NoError(t, err) | ||
|
||
must.True(t, response.Detected) | ||
|
||
attributes := response.Attributes | ||
must.NotNil(t, attributes) | ||
must.MapContainsKey(t, attributes, "cpu.modelname") | ||
must.MapContainsKey(t, attributes, "cpu.numcores.power") | ||
must.MapContainsKey(t, attributes, "cpu.numcores.efficiency") | ||
must.MapContainsKey(t, attributes, "cpu.frequency.power") | ||
must.MapContainsKey(t, attributes, "cpu.frequency.efficiency") | ||
must.MapContainsKey(t, attributes, "cpu.totalcompute") | ||
must.Positive(t, response.Resources.CPU) | ||
must.Positive(t, response.NodeResources.Cpu.CpuShares) | ||
must.Positive(t, response.NodeResources.Cpu.SharesPerCore()) | ||
must.SliceEmpty(t, response.NodeResources.Cpu.ReservableCpuCores) | ||
|
||
// not included for mixed core types (that we can detect) | ||
must.MapNotContainsKey(t, attributes, "cpu.numcores") | ||
must.MapNotContainsKey(t, attributes, "cpu.frequency") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
//go:build !linux | ||
// +build !linux | ||
|
||
package fingerprint | ||
|
||
func (f *CPUFingerprint) deriveReservableCores(req *FingerprintRequest) ([]uint16, error) { | ||
return nil, nil | ||
func (_ *CPUFingerprint) deriveReservableCores(string) []uint16 { | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.