Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overhaul ghw-snapshot tool #382

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

overhaul ghw-snapshot tool #382

wants to merge 1 commit into from

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 <jaypipes@gmail.com>
@jaypipes
Copy link
Owner Author

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

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.

1 participant