Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jaypipes
Copy link
Owner

This is the first step in actually overhauling the ghw library's context package and moving to a more standard context.Context usage. In order to standardize the context usage, we needed to change the way that the ghw-snapshot functionality worked to manually construct a pkg/context.Context and call pkg/context.Context:Do() while reading the snapshot tarball.

In order to do that, I created a new ghw-snapshot read command that accepts a single argument to the snapshot tarball path to read:

➜  ghw git:(overhaul-snapshot) ✗ GHW_DISABLE_WARNINGS=1 go run cmd/ghw-snapshot/main.go read testdata/snapshots/linux-amd64-intel-xeon-L5640.tar.gz
block storage (8 disks, 723GB physical storage)
cpu (2 physical packages, 12 cores, 24 hardware threads)
gpu (0 graphics cards)
memory (66GB physical, 63GB usable)
net (0 NICs)
topology NUMA (2 nodes)
chassis type=unknown vendor=unknown version=unknown
bios vendor=unknown version=unknown
baseboard vendor=unknown version=unknown product=unknown
product family=unknown name=unknown vendor=unknown sku=unknown version=unknown
PCI (82 devices)

➜  ghw git:(overhaul-snapshot) ✗ GHW_DISABLE_WARNINGS=1 go run cmd/ghw-snapshot/main.go read testdata/snapshots/linux-amd64-amd-ryzen-1600.tar.gz
block storage (8 disks, 3TB physical storage)
cpu (1 physical package, 6 cores, 12 hardware threads)
gpu (1 graphics card)
memory (32GB physical, 32GB usable)
net (4 NICs)
topology NUMA (0 nodes)
chassis type=unknown vendor=unknown version=unknown
bios vendor=unknown version=unknown
baseboard vendor=unknown version=unknown product=unknown
product family=unknown name=unknown vendor=unknown sku=unknown version=unknown
PCI (43 devices)

A followup series of patches will make the aforementioned changes to pkg/context and remove the pkg/context.Context:Do() method and put that entirely in the cmd/ghw-snapshot/command/read.go file which is the only place we actually use it.

This is the first step in actually overhauling the ghw library's context
package and moving to a more standard `context.Context` usage. In order
to standardize the context usage, we needed to change the way that the
ghw-snapshot functionality worked to manually construct a
`pkg/context.Context` and call `pkg/context.Context:Do()` while reading
the snapshot tarball.

In order to do that, I created a new `ghw-snapshot read` command that
accepts a single argument to the snapshot tarball path to read:

```
➜  ghw git:(overhaul-snapshot) ✗ GHW_DISABLE_WARNINGS=1 go run cmd/ghw-snapshot/main.go read testdata/snapshots/linux-amd64-intel-xeon-L5640.tar.gz
block storage (8 disks, 723GB physical storage)
cpu (2 physical packages, 12 cores, 24 hardware threads)
gpu (0 graphics cards)
memory (66GB physical, 63GB usable)
net (0 NICs)
topology NUMA (2 nodes)
chassis type=unknown vendor=unknown version=unknown
bios vendor=unknown version=unknown
baseboard vendor=unknown version=unknown product=unknown
product family=unknown name=unknown vendor=unknown sku=unknown version=unknown
PCI (82 devices)

➜  ghw git:(overhaul-snapshot) ✗ GHW_DISABLE_WARNINGS=1 go run cmd/ghw-snapshot/main.go read testdata/snapshots/linux-amd64-amd-ryzen-1600.tar.gz
block storage (8 disks, 3TB physical storage)
cpu (1 physical package, 6 cores, 12 hardware threads)
gpu (1 graphics card)
memory (32GB physical, 32GB usable)
net (4 NICs)
topology NUMA (0 nodes)
chassis type=unknown vendor=unknown version=unknown
bios vendor=unknown version=unknown
baseboard vendor=unknown version=unknown product=unknown
product family=unknown name=unknown vendor=unknown sku=unknown version=unknown
PCI (43 devices)
```

A followup series of patches will make the aforementioned changes to
`pkg/context` and remove the `pkg/context.Context:Do()` method and put
that entirely in the `cmd/ghw-snapshot/command/read.go` file which is
the only place we actually use it.

Signed-off-by: Jay Pipes <[email protected]>
@jaypipes
Copy link
Owner Author

@ffromani what do you think of this one? :)

Copy link
Collaborator

@ffromani ffromani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took me forever to review this PR!

  • STRONG +1 for the concept, let's support non-linux the best we can the most we can!
  • The implementation looks clean and straightforward, nothing obvious concern comes to mind.

So, nice work, let's move on!

@jaypipes jaypipes merged commit 80d3134 into main Oct 7, 2024
14 checks passed
@jaypipes jaypipes deleted the overhaul-snapshot branch October 7, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants