Rewrite stratis-decode-dm in Rust#3977
Rewrite stratis-decode-dm in Rust#3977mulkieran wants to merge 3 commits intostratis-storage:masterfrom
Conversation
edc06f1 to
fa60f3e
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThis PR rewrites the stratis-decode-dm utility from Python to Rust, integrating D-Bus communication capabilities through new dependencies. Associated CI pipeline changes remove Python linting infrastructure and update build configurations to support the new client_dbus_enabled feature flag. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/bin/utils/decode_dm.rs (2)
116-118: Consider more descriptiveexpectmessages.The
expect("Obviously")messages could be more helpful for debugging if these ever fail unexpectedly. A message like"interface name is valid by construction"would be clearer.Suggested improvement
let (pool_interface_name, filesystem_interface_name) = ( - InterfaceName::try_from(POOL_INTERFACE.clone()).expect("Obviously"), - InterfaceName::try_from(FILESYSTEM_INTERFACE.clone()).expect("Obviously"), + InterfaceName::try_from(POOL_INTERFACE.clone()).expect("pool interface name is valid by construction"), + InterfaceName::try_from(FILESYSTEM_INTERFACE.clone()).expect("filesystem interface name is valid by construction"), );🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/bin/utils/decode_dm.rs` around lines 116 - 118, Replace the placeholder expect messages on the InterfaceName::try_from calls for POOL_INTERFACE and FILESYSTEM_INTERFACE with descriptive failure texts; update the two expect("Obviously") usages to something like "interface name is valid by construction" or "failed to convert POOL_INTERFACE to InterfaceName" / "failed to convert FILESYSTEM_INTERFACE to InterfaceName" so any panic includes which constant conversion failed (refer to InterfaceName::try_from, POOL_INTERFACE, FILESYSTEM_INTERFACE).
19-27: Consider documenting or externalizingREVISION_NUMBER.The revision number
9is hardcoded and determines the D-Bus interface version (e.g.,org.storage.stratis3.pool.r9). If the interface revision changes, this will need manual updating. Consider adding a comment explaining how this value relates to stratisd's D-Bus interface versioning, or whether it should be shared with other parts of the codebase.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/bin/utils/decode_dm.rs` around lines 19 - 27, REVISION_NUMBER is hardcoded (9) and drives the generated D-Bus interface strings (REVISION, POOL_INTERFACE, FILESYSTEM_INTERFACE); add a short doc comment above REVISION_NUMBER explaining that it maps to stratisd's D-Bus interface revision and how/where it should be updated, or refactor to obtain the value from a shared constant or configuration (env var/const in a common module) so multiple modules share the same source of truth; ensure the comment references stratisd D-Bus versioning and update usages of REVISION, POOL_INTERFACE, and FILESYSTEM_INTERFACE to rely on the single documented/shared source.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.packit.yaml:
- Line 13: Replace the temporary fork reference in .packit.yaml: change the git
clone URL string "git clone https://github.com/mulkieran/ci
--branch=issue_stratisd_3976 --depth=1 ../distro" back to the official upstream
repository (e.g., use "git clone https://github.com/stratis-storage/ci" with the
appropriate branch or default) so the packit configuration points to
stratis-storage/ci instead of mulkieran/ci before merging.
---
Nitpick comments:
In `@src/bin/utils/decode_dm.rs`:
- Around line 116-118: Replace the placeholder expect messages on the
InterfaceName::try_from calls for POOL_INTERFACE and FILESYSTEM_INTERFACE with
descriptive failure texts; update the two expect("Obviously") usages to
something like "interface name is valid by construction" or "failed to convert
POOL_INTERFACE to InterfaceName" / "failed to convert FILESYSTEM_INTERFACE to
InterfaceName" so any panic includes which constant conversion failed (refer to
InterfaceName::try_from, POOL_INTERFACE, FILESYSTEM_INTERFACE).
- Around line 19-27: REVISION_NUMBER is hardcoded (9) and drives the generated
D-Bus interface strings (REVISION, POOL_INTERFACE, FILESYSTEM_INTERFACE); add a
short doc comment above REVISION_NUMBER explaining that it maps to stratisd's
D-Bus interface revision and how/where it should be updated, or refactor to
obtain the value from a shared constant or configuration (env var/const in a
common module) so multiple modules share the same source of truth; ensure the
comment references stratisd D-Bus versioning and update usages of REVISION,
POOL_INTERFACE, and FILESYSTEM_INTERFACE to rely on the single documented/shared
source.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (9)
.githooks/pre-commit.github/workflows/main.yml.packit.yamlCargo.tomlMakefilesrc/bin/utils/cmds.rssrc/bin/utils/decode_dm.rssrc/bin/utils/mod.rssrc/bin/utils/stratis-decode-dm
💤 Files with no reviewable changes (3)
- .githooks/pre-commit
- src/bin/utils/stratis-decode-dm
- .github/workflows/main.yml
| actions: | ||
| post-upstream-clone: | ||
| - "git clone https://github.com/stratis-storage/ci --depth=1 ../distro" | ||
| - "git clone https://github.com/mulkieran/ci --branch=issue_stratisd_3976 --depth=1 ../distro" |
There was a problem hiding this comment.
Revert to upstream CI repository before merge.
This references a personal fork (mulkieran/ci) with a feature branch instead of the official stratis-storage/ci repository. This appears to be a temporary change for testing (consistent with the "TEMPORARY" commit message). Ensure this is reverted to the upstream repository before merging to master.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.packit.yaml at line 13, Replace the temporary fork reference in
.packit.yaml: change the git clone URL string "git clone
https://github.com/mulkieran/ci --branch=issue_stratisd_3976 --depth=1
../distro" back to the official upstream repository (e.g., use "git clone
https://github.com/stratis-storage/ci" with the appropriate branch or default)
so the packit configuration points to stratis-storage/ci instead of mulkieran/ci
before merging.
c671b3c to
79bbb64
Compare
|
Build failures look like it's because I'm depending on an enhancement of zbus_names in 4.3.0 that is not available in 4.2.0 which is what there is in Fedora. |
79bbb64 to
794c885
Compare
|
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
a42b02a to
671cf7d
Compare
|
there was a bug in the testing repo test, variable shadowed. should be fixed now. |
671cf7d to
6cdab47
Compare
|
Rebased and removed top-level .isort.cfg. |
b9db70a to
a0ac39c
Compare
|
rebased. |
a0ac39c to
295fb96
Compare
295fb96 to
63424fd
Compare
|
rebased. |
|
This time it must succeed. |
cc5f315 to
a3631bf
Compare
|
rebased. |
a3631bf to
8fa234c
Compare
jbaublitz
left a comment
There was a problem hiding this comment.
Just a couple of comments but otherwise this looks good.
src/bin/utils/decode_dm.rs
Outdated
| const BUS_NAME: &str = "org.storage.stratis3"; | ||
| const TOP_OBJECT: &str = "/org/storage/stratis3"; | ||
|
|
||
| static REVISION: LazyLock<String> = LazyLock::new(|| format!("r{REVISION_NUMBER}")); |
There was a problem hiding this comment.
I think we can remove this altogether by simply changing the format String in POOL_INTERFACE and FILESYSTEM_INTERFACE.
There was a problem hiding this comment.
@coderabbitai, how would I implement the reviewer's suggestion?
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
cat src/bin/utils/decode_dm.rs
Length of output: 7411
@mulkieran, the reviewer's suggestion is to remove the intermediate REVISION static entirely and fold the "r" prefix directly into the two interface format strings. Here's the diff:
-static REVISION: LazyLock<String> = LazyLock::new(|| format!("r{REVISION_NUMBER}"));
static POOL_INTERFACE: LazyLock<String> =
- LazyLock::new(|| format!("{BUS_NAME}.pool.{}", &*REVISION));
+ LazyLock::new(|| format!("{BUS_NAME}.pool.r{REVISION_NUMBER}"));
static FILESYSTEM_INTERFACE: LazyLock<String> =
- LazyLock::new(|| format!("{BUS_NAME}.filesystem.{}", &*REVISION));
+ LazyLock::new(|| format!("{BUS_NAME}.filesystem.r{REVISION_NUMBER}"));REVISION_NUMBER (the const) can stay since it's still a named, self-documenting source for the version string. After this change the full constants block would look like:
const REVISION_NUMBER: &str = env!("CARGO_PKG_VERSION_MINOR");
const BUS_NAME: &str = "org.storage.stratis3";
const TOP_OBJECT: &str = "/org/storage/stratis3";
static POOL_INTERFACE: LazyLock<String> =
LazyLock::new(|| format!("{BUS_NAME}.pool.r{REVISION_NUMBER}"));
static FILESYSTEM_INTERFACE: LazyLock<String> =
LazyLock::new(|| format!("{BUS_NAME}.filesystem.r{REVISION_NUMBER}"));This removes one LazyLock allocation, eliminates the &*REVISION forced deref, and keeps the logic equally readable.
There was a problem hiding this comment.
Ok! That was also copied from the Python script directly, but it's also fine this way, done.
There was a problem hiding this comment.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
|
Sorry for the lack of comment from me lately. I will add a sprint task to review/test this. My time has been under a great deal of pressure recently & this has slipped off the plate a couple times. |
8fa234c to
0feb710
Compare
|
review comments addressed, squashed a bit, rebased. |
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
0feb710 to
02540da
Compare
Closes #3976