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

ghw-snapshot: capture cpu, memory, topology data #203

Merged
merged 3 commits into from
Jan 6, 2021

Conversation

ffromani
Copy link
Collaborator

@ffromani ffromani commented Dec 17, 2020

Needed for #66 (see #66 (comment) and following)

Add support to capture data ghw cares about in
/sys/system/devices/{cpu,node}.
With this patch, we can create snapshot we can reuse
to test the cpu, memory and topology packages using
the codeto consume snapshot added in commit 1a9fae7

There is quite a lot of opportunity to extract code
from ghw-snapshot and add it to the newly created snapshot
pkg, to make it easier to reuse and more testable.

This refactoring is deferred to a later change because
the new logic added is complex enough to stand in its own.

Signed-off-by: Francesco Romani fromani@redhat.com

@ffromani
Copy link
Collaborator Author

it seems ghw-snapshot is saving absolute (not relative) links for block devices pointing to the original scratchdir. This breaks block devices snapshot usage in my case.
Working on a fix, can be squashed in this PR or an additional one. Any preferences?
Same goes for snapshots: I'm collecting the promised reference snapshot from an handful systems I have access to, I can either push a followup PR or add here in the next few days. Of course they're going to be a bunch of blobs from git perspective.
I'd be happy to do whatever works best forreviewers!

@ffromani ffromani force-pushed the add-cpu-node-snapshot branch 2 times, most recently from c607ec2 to f932dd5 Compare December 18, 2020 10:46
@jaypipes
Copy link
Owner

it seems ghw-snapshot is saving absolute (not relative) links for block devices pointing to the original scratchdir. This breaks block devices snapshot usage in my case.

Yes, I did that on purpose after failing miserably with relative links :) The reason is because if you pass a directory containing relative links to Docker as a volume mount, Docker won't read the contents of the relative link (for security reasons). Docker considers a relative link to be simply a file that contains a string with a filepath in it:

moby/moby#1676

Working on a fix, can be squashed in this PR or an additional one. Any preferences?

I'd definitely be interested in your solution to this :) Please file a separate PR, though, as it will help for reviewing!

Best,
-jay

@ffromani
Copy link
Collaborator Author

it seems ghw-snapshot is saving absolute (not relative) links for block devices pointing to the original scratchdir. This breaks block devices snapshot usage in my case.

Yes, I did that on purpose after failing miserably with relative links :) The reason is because if you pass a directory containing relative links to Docker as a volume mount, Docker won't read the contents of the relative link (for security reasons). Docker considers a relative link to be simply a file that contains a string with a filepath in it:

moby/moby#1676\

Ah, darn, I added to this PR because I'm using the same approach I followed for /sys/devices/system/node/node0/cpu? (which symlink back to /sys/devices/system/cpu/cpu? :( I'll test with docker (and podman) then.

Working on a fix, can be squashed in this PR or an additional one. Any preferences?

I'd definitely be interested in your solution to this :) Please file a separate PR, though, as it will help for reviewing!

OK, so I already made a little mess so I'll stay put and wait for further instructions. Apologies!

@ffromani
Copy link
Collaborator Author

ffromani commented Jan 5, 2021

I think we have a good resolution onhttps://github.com//pull/205 - I will rebase this on top of it when we reach consensus.

@ffromani
Copy link
Collaborator Author

ffromani commented Jan 5, 2021

works, but forgot to snapshot the relevant content under /sys/devices/system/memory. Will update ASAP.

Add support to capture data ghw cares about in
/sys/system/devices/{cpu,node}.
With this patch, we can create snapshot we can reuse
to test the `cpu`, `memory` and `topology` packages using
the codeto consume snapshot added in commit 1a9fae7

There is quite a lot of opportunity to extract code
from ghw-snapshot and add it to the newl created `snapshot`
pkg, to make it easier to reuse and more testable.

This refactoring is deferred to a later change because
the new logic added is complex enough to stand in its own.

Signed-off-by: Francesco Romani <fromani@redhat.com>
When snapshotting the block device tree structure,
better use relative paths - not absolute, otherwise
the link target will reference the buildDir path (not
the unpackDir path), making the link broken.

Signed-off-by: Francesco Romani <fromani@redhat.com>
@ffromani
Copy link
Collaborator Author

ffromani commented Jan 6, 2021

updated! now the snapshot captures the /sys/devices/system/memory ghw cares about. Please note the example snapshot was removed from this PR. I'll add again shortly (in another PR) once I get access again to my test system.

Copy link
Owner

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

++

@jaypipes jaypipes merged commit 23650de into jaypipes:master Jan 6, 2021
@jaypipes jaypipes added this to the v0.7 milestone Jan 12, 2021
@ffromani ffromani deleted the add-cpu-node-snapshot branch May 24, 2021 06:52
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