-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add D-Bus method to get filesystem metadata #3656
Conversation
87a3542
to
e3674b7
Compare
Cockpit tests failed for commit 87a3542. @martinpitt, @jelly, @mvollmer please check. |
Cockpit tests failed for commit e3674b7. @martinpitt, @jelly, @mvollmer please check. |
5acae53
to
8273f20
Compare
5cb1a8d
to
62c7d21
Compare
There was a problem hiding this 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.
src/engine/sim_engine/pool.rs
Outdated
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")) | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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")) |
There was a problem hiding this comment.
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.
639a920
to
43027a8
Compare
There was a problem hiding this 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!
Signed-off-by: mulhern <[email protected]>
43027a8
to
b2e1777
Compare
infrastructure problem on tests, ignoring |
Related #3621