From bb68466d7800f9dbfcf997381a72f0bf71c267a2 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Fri, 1 Mar 2024 18:08:41 +1300 Subject: [PATCH 1/4] Allow separating the WWN vendor extension Provide a way to get the disk WWN without the vendor extension. Signed-off-by: Zane Bitter --- pkg/block/block.go | 6 +++++- pkg/block/block_darwin.go | 1 + pkg/block/block_linux.go | 14 ++++++++++++++ pkg/block/block_windows.go | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pkg/block/block.go b/pkg/block/block.go index 7a0dbde1..5e75eea6 100644 --- a/pkg/block/block.go +++ b/pkg/block/block.go @@ -233,9 +233,13 @@ type Disk struct { Model string `json:"model"` // SerialNumber is the serial number of the disk. SerialNumber string `json:"serial_number"` - // WWN is the World-wide Number of the disk. + // WWN is the World-wide Name of the disk. // See: https://en.wikipedia.org/wiki/World_Wide_Name WWN string `json:"wwn"` + // WWNNoExtension is the World-wide Name of the disk with any vendor + // extensions excluded. + // See: https://en.wikipedia.org/wiki/World_Wide_Name + WWNNoExtension string `json:"wwnNoExtension"` // Partitions contains an array of pointers to `Partition` structs, one for // each partition on the disk. Partitions []*Partition `json:"partitions"` diff --git a/pkg/block/block_darwin.go b/pkg/block/block_darwin.go index 9b026253..c6b6c266 100644 --- a/pkg/block/block_darwin.go +++ b/pkg/block/block_darwin.go @@ -258,6 +258,7 @@ func (info *Info) load() error { Model: ioregPlist.ModelNumber, SerialNumber: ioregPlist.SerialNumber, WWN: "", + WWNNoExtension: "", Partitions: make([]*Partition, 0, len(disk.Partitions)+len(disk.APFSVolumes)), } diff --git a/pkg/block/block_linux.go b/pkg/block/block_linux.go index 3c24cf86..376b5ff5 100644 --- a/pkg/block/block_linux.go +++ b/pkg/block/block_linux.go @@ -183,6 +183,18 @@ func diskBusPath(paths *linuxpath.Paths, disk string) string { return util.UNKNOWN } +func diskWWNNoExtension(paths *linuxpath.Paths, disk string) string { + info, err := udevInfoDisk(paths, disk) + if err != nil { + return util.UNKNOWN + } + + if wwn, ok := info["ID_WWN"]; ok { + return wwn + } + return util.UNKNOWN +} + func diskWWN(paths *linuxpath.Paths, disk string) string { info, err := udevInfoDisk(paths, disk) if err != nil { @@ -326,6 +338,7 @@ func disks(ctx *context.Context, paths *linuxpath.Paths) []*Disk { model := diskModel(paths, dname) serialNo := diskSerialNumber(paths, dname) wwn := diskWWN(paths, dname) + wwnNoExtension := diskWWNNoExtension(paths, dname) removable := diskIsRemovable(paths, dname) if storageController == STORAGE_CONTROLLER_LOOP && size == 0 { @@ -345,6 +358,7 @@ func disks(ctx *context.Context, paths *linuxpath.Paths) []*Disk { Model: model, SerialNumber: serialNo, WWN: wwn, + WWNNoExtension: wwnNoExtension, } parts := diskPartitions(ctx, paths, dname) diff --git a/pkg/block/block_windows.go b/pkg/block/block_windows.go index be39f6c0..270e19f9 100644 --- a/pkg/block/block_windows.go +++ b/pkg/block/block_windows.go @@ -155,6 +155,7 @@ func (i *Info) load() error { Model: strings.TrimSpace(*diskdrive.Caption), SerialNumber: strings.TrimSpace(*diskdrive.SerialNumber), WWN: util.UNKNOWN, // TODO: add information + WWNNoExtension: util.UNKNOWN, // TODO: add information Partitions: make([]*Partition, 0), } for _, diskpartition := range win32DiskPartitionDescriptions { From e576a6aaf6460595e6418d218c7fa1d943aa2e35 Mon Sep 17 00:00:00 2001 From: Kishen V Date: Tue, 20 Feb 2024 16:53:06 +0530 Subject: [PATCH 2/4] Read core and physical package ID of the CPUs that are online Add tests for files in topology directory for offline CPUs Signed-off-by: Kishen V --- pkg/cpu/cpu_linux.go | 9 ++ pkg/cpu/cpu_linux_test.go | 89 ++++++++++++++++++ .../snapshots/linux-amd64-offlineCPUs.tar.gz | Bin 0 -> 11968 bytes 3 files changed, 98 insertions(+) create mode 100644 testdata/snapshots/linux-amd64-offlineCPUs.tar.gz diff --git a/pkg/cpu/cpu_linux.go b/pkg/cpu/cpu_linux.go index 7ff48741..3ec2e847 100644 --- a/pkg/cpu/cpu_linux.go +++ b/pkg/cpu/cpu_linux.go @@ -22,6 +22,7 @@ import ( var ( regexForCpulCore = regexp.MustCompile("^cpu([0-9]+)$") + onlineFile = "online" ) func (i *Info) load() error { @@ -64,6 +65,10 @@ func processorsGet(ctx *context.Context) []*Processor { continue } + onlineFilePath := filepath.Join(paths.SysDevicesSystemCPU, fmt.Sprintf("cpu%d", lpID), onlineFile) + if util.SafeIntFromFile(ctx, onlineFilePath) == 0 { + continue + } procID := processorIDFromLogicalProcessorID(ctx, lpID) proc, found := procs[procID] if !found { @@ -201,6 +206,10 @@ func CoresForNode(ctx *context.Context, nodeID int) ([]*ProcessorCore, error) { ) continue } + onlineFilePath := filepath.Join(cpuPath, onlineFile) + if util.SafeIntFromFile(ctx, onlineFilePath) == 0 { + continue + } coreIDPath := filepath.Join(cpuPath, "topology", "core_id") coreID := util.SafeIntFromFile(ctx, coreIDPath) core := findCoreByID(coreID) diff --git a/pkg/cpu/cpu_linux_test.go b/pkg/cpu/cpu_linux_test.go index 3c334b57..46b05781 100644 --- a/pkg/cpu/cpu_linux_test.go +++ b/pkg/cpu/cpu_linux_test.go @@ -7,12 +7,16 @@ package cpu_test import ( + "bytes" + "io" "os" "path/filepath" + "strings" "testing" "github.com/jaypipes/ghw/pkg/cpu" "github.com/jaypipes/ghw/pkg/option" + "github.com/jaypipes/ghw/pkg/topology" "github.com/jaypipes/ghw/testdata" ) @@ -71,3 +75,88 @@ func TestArmCPU(t *testing.T) { } } } + +func TestCheckCPUTopologyFilesForOfflineCPU(t *testing.T) { + if _, ok := os.LookupEnv("GHW_TESTING_SKIP_CPU"); ok { + t.Skip("Skipping CPU tests.") + } + + testdataPath, err := testdata.SnapshotsDirectory() + if err != nil { + t.Fatalf("Expected nil err, but got %v", err) + } + + offlineCPUSnapshot := filepath.Join(testdataPath, "linux-amd64-offlineCPUs.tar.gz") + + // Capture stderr + rErr, wErr, err := os.Pipe() + if err != nil { + t.Fatalf("Cannot pipe StdErr. %v", err) + } + os.Stderr = wErr + + info, err := cpu.New(option.WithSnapshot(option.SnapshotOptions{ + Path: offlineCPUSnapshot, + })) + if err != nil { + t.Fatalf("Expected nil err, but got %v", err) + } + if info == nil { + t.Fatalf("Expected non-nil CPUInfo, but got nil") + } + + if len(info.Processors) == 0 { + t.Fatalf("Expected >0 processors but got 0.") + } + wErr.Close() + var bufErr bytes.Buffer + if _, err := io.Copy(&bufErr, rErr); err != nil { + t.Fatalf("Failed to copy data to buffer: %v", err) + } + errorOutput := bufErr.String() + if strings.Contains(errorOutput, "WARNING: failed to read int from file:") { + t.Fatalf("Unexpected warning related to missing files under topology directory was reported") + } +} +func TestNumCoresAmongOfflineCPUs(t *testing.T) { + if _, ok := os.LookupEnv("GHW_TESTING_SKIP_CPU"); ok { + t.Skip("Skipping CPU tests.") + } + + testdataPath, err := testdata.SnapshotsDirectory() + if err != nil { + t.Fatalf("Expected nil err, but got %v", err) + } + + offlineCPUSnapshot := filepath.Join(testdataPath, "linux-amd64-offlineCPUs.tar.gz") + + // Capture stderr + rErr, wErr, err := os.Pipe() + if err != nil { + t.Fatalf("Cannot pipe the StdErr. %v", err) + } + info, err := topology.New(option.WithSnapshot(option.SnapshotOptions{ + Path: offlineCPUSnapshot, + })) + if err != nil { + t.Fatalf("Error determining node topology. %v", err) + } + + if len(info.Nodes) < 1 { + t.Fatal("No nodes found. Must contain one or more nodes") + } + for _, node := range info.Nodes { + if len(node.Cores) < 1 { + t.Fatal("No cores found. Must contain one or more cores") + } + } + wErr.Close() + var bufErr bytes.Buffer + if _, err := io.Copy(&bufErr, rErr); err != nil { + t.Fatalf("Failed to copy data to buffer: %v", err) + } + errorOutput := bufErr.String() + if strings.Contains(errorOutput, "WARNING: failed to read int from file:") { + t.Fatalf("Unexpected warnings related to missing files under topology directory was raised") + } +} diff --git a/testdata/snapshots/linux-amd64-offlineCPUs.tar.gz b/testdata/snapshots/linux-amd64-offlineCPUs.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..7e71fa09f5b3c9aaf677e3e1283aa8ec679a67c8 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H^k^J=#?rdO}=df9W?B>vi?m zuiv_#UD`W~eq2;|w(IMbdqP@t&y-<$1Vx&8>0tX@SoOLh9b6e_$y@x{+^#(j4c|j< zUy6*H0&YpUA9G@k+n=bObq#Cd*%E2I7-1XGz)#}alr-N)kg&b5!~KxfwiG6yr{IR$ z3%rVA09M+M@pNFlnVFVL)LDf5-d81>p>9PEH)#o82kPB6}l$bg=W!jf0^I zhR712`{+_}KP43S(Sx6X`#kV;03AP8C4s6C0VW?HL0au=g5Ymcg~g52)r5%4J{GX((+PZq0Xb z0lj(`(~D0Bu}T*4+or~=VY&$@aC^l@CytOT+M6OFW&rBceUg2V@&gz5CQ}6DgPJ?6 zy5cO3VK@OgRS7)IJJxGy5Pk`g+$_1jL+T*$_QU_T{Yt=Lsb0T%yh|G5e3esSkx~!8XnHFFb`RmY z{y?T`y4;%jip!M*wSNGmK}RxeF#zA7zbcFon#bEC!3Pxjui{<^Xk52%82+8-&OhOuB{vT}rd4Ox!{%H4)&?EyY0z&+XYxZdCg8pLLJ0_M=L=reJU=f4|8|HoAsda3x%Cd z9EI5K+|fk43^AWWz4xK1boq+DzDQ{5Ddv-4uL2Na;fT+I--D`{+SU{EM4Lg@hVb(& zI&QV3kHWdASq0H44OP4B>)ycx0m_CndUkvzivJF3%2K-<>l?U$EGZq3Wr;@+EZe3+t) zZrF#-&em8OHo40K!f`PE(gbZBqX3K85wXTpa)Vzx#l>DzAsX(971z#rD4d`jaGh literal 0 HcmV?d00001 From a89ba880382ac86d3e36f75a5ac73ceab90012d5 Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Fri, 5 Apr 2024 17:05:06 -0400 Subject: [PATCH 3/4] update egress endpoints and Go version in actions Updates the Go version matrix we test for in the Github Actions as well as ensure that the 5 common github.com DNS names (no prefix, api, proxy, objects.githubcontent and raw.githubcontent) are all allowed in egress endpoints. Signed-off-by: Jay Pipes --- .github/workflows/fmtcheck.yml | 6 +++++- .github/workflows/lint.yml | 3 ++- .github/workflows/test.yml | 26 +++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.github/workflows/fmtcheck.yml b/.github/workflows/fmtcheck.yml index 623863a9..b1294b8b 100644 --- a/.github/workflows/fmtcheck.yml +++ b/.github/workflows/fmtcheck.yml @@ -20,11 +20,15 @@ jobs: disable-sudo: true allowed-endpoints: > github.com:443 + api.github.com:443 + proxy.github.com:443 + raw.githubusercontent.com:443 + objects.githubusercontent.com:443 - name: checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: setup go uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 with: - go-version: 1.19 + go-version: 1.21 - name: check fmt run: 'bash -c "diff -u <(echo -n) <(gofmt -d .)"' diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e8488e9a..1f10df35 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -22,6 +22,7 @@ jobs: allowed-endpoints: > github.com:443 api.github.com:443 + proxy.github.com:443 raw.githubusercontent.com:443 objects.githubusercontent.com:443 - name: checkout code @@ -29,7 +30,7 @@ jobs: - name: setup go uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1 with: - go-version: 1.19 + go-version: 1.21 - name: lint uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 977703ea..2fda80b7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: [ '1.19', '1.20'] + go: [ '1.19', '1.20', '1.21'] steps: - name: harden runner uses: step-security/harden-runner@55d479fb1c5bcad5a4f9099a5d9f37c8857b2845 # v2.4.1 @@ -26,6 +26,10 @@ jobs: disable-sudo: true allowed-endpoints: > github.com:443 + api.github.com:443 + proxy.github.com:443 + raw.githubusercontent.com:443 + objects.githubusercontent.com:443 - name: checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: setup go @@ -51,6 +55,10 @@ jobs: disable-sudo: true allowed-endpoints: > github.com:443 + api.github.com:443 + proxy.github.com:443 + raw.githubusercontent.com:443 + objects.githubusercontent.com:443 - name: checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: setup go @@ -67,7 +75,7 @@ jobs: runs-on: windows-2022 strategy: matrix: - go: [ '1.19' ] + go: [ '1.20', '1.21' ] steps: - name: harden runner uses: step-security/harden-runner@55d479fb1c5bcad5a4f9099a5d9f37c8857b2845 # v2.4.1 @@ -76,6 +84,10 @@ jobs: disable-sudo: true allowed-endpoints: > github.com:443 + api.github.com:443 + proxy.github.com:443 + raw.githubusercontent.com:443 + objects.githubusercontent.com:443 - name: checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: setup go @@ -98,7 +110,7 @@ jobs: runs-on: windows-2019 strategy: matrix: - go: [ '1.18' ] + go: [ '1.19' ] steps: - name: harden runner uses: step-security/harden-runner@55d479fb1c5bcad5a4f9099a5d9f37c8857b2845 # v2.4.1 @@ -107,6 +119,10 @@ jobs: disable-sudo: true allowed-endpoints: > github.com:443 + api.github.com:443 + proxy.github.com:443 + raw.githubusercontent.com:443 + objects.githubusercontent.com:443 - name: checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: setup go @@ -145,6 +161,10 @@ jobs: disable-sudo: true allowed-endpoints: > github.com:443 + api.github.com:443 + proxy.github.com:443 + raw.githubusercontent.com:443 + objects.githubusercontent.com:443 - name: checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: setup go From dc8cee0e2799d8d604978214a895d4beeaa211a6 Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Sun, 7 Apr 2024 10:09:26 -0400 Subject: [PATCH 4/4] add proxy.golang.org:443 to egress Signed-off-by: Jay Pipes --- .github/workflows/fmtcheck.yml | 1 + .github/workflows/lint.yml | 1 + .github/workflows/test.yml | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/.github/workflows/fmtcheck.yml b/.github/workflows/fmtcheck.yml index b1294b8b..4af89409 100644 --- a/.github/workflows/fmtcheck.yml +++ b/.github/workflows/fmtcheck.yml @@ -24,6 +24,7 @@ jobs: proxy.github.com:443 raw.githubusercontent.com:443 objects.githubusercontent.com:443 + proxy.golang.org:443 - name: checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: setup go diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1f10df35..dcb6451e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,6 +25,7 @@ jobs: proxy.github.com:443 raw.githubusercontent.com:443 objects.githubusercontent.com:443 + proxy.golang.org:443 - name: checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: setup go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2fda80b7..cd4e9fc3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,6 +30,7 @@ jobs: proxy.github.com:443 raw.githubusercontent.com:443 objects.githubusercontent.com:443 + proxy.golang.org:443 - name: checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: setup go @@ -59,6 +60,7 @@ jobs: proxy.github.com:443 raw.githubusercontent.com:443 objects.githubusercontent.com:443 + proxy.golang.org:443 - name: checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: setup go @@ -88,6 +90,7 @@ jobs: proxy.github.com:443 raw.githubusercontent.com:443 objects.githubusercontent.com:443 + proxy.golang.org:443 - name: checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: setup go @@ -123,6 +126,7 @@ jobs: proxy.github.com:443 raw.githubusercontent.com:443 objects.githubusercontent.com:443 + proxy.golang.org:443 - name: checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: setup go @@ -165,6 +169,7 @@ jobs: proxy.github.com:443 raw.githubusercontent.com:443 objects.githubusercontent.com:443 + proxy.golang.org:443 - name: checkout code uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 - name: setup go