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

Add D-Bus method to get filesystem metadata #3656

Merged

Conversation

mulkieran
Copy link
Member

@mulkieran mulkieran commented Jul 24, 2024

Related #3621

@mulkieran mulkieran self-assigned this Jul 24, 2024
@mulkieran mulkieran force-pushed the debug-filesystem-metadata branch from 87a3542 to e3674b7 Compare July 24, 2024 21:20
Copy link

Cockpit tests failed for commit 87a3542. @martinpitt, @jelly, @mvollmer please check.

Copy link

Cockpit tests failed for commit e3674b7. @martinpitt, @jelly, @mvollmer please check.

@mulkieran mulkieran force-pushed the debug-filesystem-metadata branch 6 times, most recently from 5acae53 to 8273f20 Compare August 1, 2024 02:58
@mulkieran mulkieran marked this pull request as ready for review August 1, 2024 13:35
@mulkieran mulkieran force-pushed the debug-filesystem-metadata branch 3 times, most recently from 5cb1a8d to 62c7d21 Compare August 1, 2024 13:59
@mulkieran mulkieran requested a review from jbaublitz August 1, 2024 14:02
Copy link
Member

@jbaublitz jbaublitz left a comment

Choose a reason for hiding this comment

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

There's one aspect of data structure that I think we need to rethink, but other than that this looks good.

Comment on lines 762 to 777
fn current_fs_metadata(&self, fs_name: Option<&str>) -> StratisResult<String> {
self.filesystems
.iter()
.filter_map(|(name, uuid, fs)| {
if fs_name.map(|n| *n == **name).unwrap_or(true) {
Some(serde_json::to_string(&fs.record(name, *uuid)).map_err(|e| e.into()))
} else {
None
}
})
.collect::<StratisResult<Vec<_>>>()
.map(|v| v.join("\n"))
}
Copy link
Member

Choose a reason for hiding this comment

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

If I'm understanding this correctly, this means if fs_name is None it will return a bunch of JSON blobs separated by newlines for all filesystems present in the pool. Wouldn't it be better to put this all into a JSON object mapping UUIDs to metadata? I'm unaware of any JSON parser that can handle multiple separate blobs of JSON at once.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jbaublitz That's exactly what it does. I was of two minds about this, but then I found that jq is fine with distinct blobs of JSON and I grew more satisfied with it.

$ cat junk.txt | jq
{}
{
  "key": 2
}

But your proposed solution is likely better.

Copy link
Member

Choose a reason for hiding this comment

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

I don't know of any JSON parser in a programming language like Python that will do the same unfortunately.

Comment on lines 733 to 760
pub fn current_fs_metadata(&self, fs_name: Option<&str>) -> StratisResult<String> {
self.filesystems
.iter()
.filter_map(|(name, uuid, fs)| {
if fs_name.map(|n| *n == **name).unwrap_or(true) {
Some(serde_json::to_string(&fs.record(name, *uuid)).map_err(|e| e.into()))
} else {
None
}
})
.collect::<StratisResult<Vec<_>>>()
.map(|v| v.join("\n"))
}

/// Read filesystem metadata from mdv
pub fn last_fs_metadata(&self, fs_name: Option<&str>) -> StratisResult<String> {
self.mdv
.filesystems()?
.iter()
.filter_map(|fssave| {
if fs_name.map(|n| *n == fssave.name).unwrap_or(true) {
Some(serde_json::to_string(fssave).map_err(|e| e.into()))
} else {
None
}
})
.collect::<StratisResult<Vec<_>>>()
.map(|v| v.join("\n"))
Copy link
Member

Choose a reason for hiding this comment

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

Same comment here as in the SimPool.

@mulkieran mulkieran force-pushed the debug-filesystem-metadata branch 2 times, most recently from 639a920 to 43027a8 Compare August 1, 2024 19:45
@jbaublitz jbaublitz self-requested a review August 1, 2024 20:08
Copy link
Member

@jbaublitz jbaublitz left a comment

Choose a reason for hiding this comment

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

This looks better. Thanks!

@mulkieran mulkieran force-pushed the debug-filesystem-metadata branch from 43027a8 to b2e1777 Compare August 1, 2024 21:39
@mulkieran
Copy link
Member Author

infrastructure problem on tests, ignoring

@mulkieran mulkieran merged commit 7f16aac into stratis-storage:master Aug 2, 2024
48 of 49 checks passed
@mulkieran mulkieran deleted the debug-filesystem-metadata branch August 2, 2024 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done (1)
Development

Successfully merging this pull request may close these issues.

2 participants