Conversation
|
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. |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@mulkieran This is still happening on a new PR. |
WalkthroughMassive migration from Changes
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Specific areas requiring close attention:
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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: 5
🧹 Nitpick comments (12)
src/dbus/manager/manager_3_8/methods.rs (1)
180-192: Complex nested option handling for unlock method.The double
tuple_to_optionpattern on line 187 handles the nested(bool, (bool, u32))structure. This is correct but could be clarified with a comment explaining the unwrapping levels.🔎 Suggested documentation improvement
let key_fd_option = tuple_to_option(key_fd); match handle_action!( engine .start_pool( id, + // Unwrap outer option (is unlock_method present?) then inner option (specific method) TokenUnlockMethod::from_options( tuple_to_option(unlock_method_tuple).map(tuple_to_option) ), key_fd_option.as_ref().map(|fd| fd.as_raw_fd()), false ) .await )src/dbus/pool/shared.rs (1)
33-51:pool_propandtry_pool_prophave identical implementations.These two functions (lines 33-41 and 43-51) are currently identical. If they are intended to have different semantics (e.g.,
try_pool_propmight wrap certain fallible operations differently), consider differentiating them. Otherwise, one could be an alias to the other to avoid duplication.If this is intentional scaffolding for future divergence, a brief comment explaining the intended difference would help maintainability.
🔎 If no difference is intended, consider consolidating
pub async fn pool_prop<R>( engine: &Arc<dyn Engine>, uuid: PoolUuid, f: impl Fn(SomeLockReadGuard<PoolUuid, dyn Pool>) -> R, ) -> Result<R, Error> { let guard = get_pool(engine, uuid).await?; Ok(f(guard)) } -pub async fn try_pool_prop<R>( - engine: &Arc<dyn Engine>, - uuid: PoolUuid, - f: impl Fn(SomeLockReadGuard<PoolUuid, dyn Pool>) -> R, -) -> Result<R, Error> { - let guard = get_pool(engine, uuid).await?; - - Ok(f(guard)) -} +// Alias for pool_prop - currently identical, kept for API symmetry +pub use pool_prop as try_pool_prop;src/dbus/pool/pool_3_8/methods.rs (1)
251-260: Consider extracting duplicated signal condition logic.The signal emission condition
token_slot.is_none() || (token_slot.is_some() && token_slot == low_ts) || is_rightappears in multiple methods. This could be extracted into a helper function for consistency and maintainability.🔎 Example helper function
fn should_emit_primary_signal(token_slot: Option<u32>, low_ts: Option<u32>, is_right: bool) -> bool { token_slot.is_none() || (token_slot.is_some() && token_slot == low_ts) || is_right }Also applies to: 326-336, 408-418, 485-495
src/dbus/udev.rs (1)
62-72: RedundantOk(())return after?operator.The
register_poolfunction call with?already returns()on success. The explicitOk(())at line 71 is redundant.🔎 Simplified implementation
pub async fn register_pool(&self, pool_uuid: PoolUuid) -> StratisResult<()> { register_pool( &self.engine, &self.connection, &self.manager, &self.counter, pool_uuid, ) - .await?; - Ok(()) + .await }src/dbus/manager/manager_3_2/methods.rs (1)
179-179: Clarify the unreachable case comment.The comment
"!has_partially_constructed above"may be misleading since there's no explicithas_partially_constructedcheck in this function. TheCleanedUpvariant is indeed unreachable here because this method operates on pools that have an ObjectPath (i.e., fully started pools), andCleanedUponly applies to partially constructed pools that were never started. Consider updating the comment to clarify this reasoning.Suggested comment improvement
- Ok(StopAction::CleanedUp(_)) => unreachable!("!has_partially_constructed above"), + Ok(StopAction::CleanedUp(_)) => unreachable!("CleanedUp only applies to partially constructed pools; this method operates on fully started pools with an ObjectPath"),src/dbus/pool/mod.rs (1)
57-176: Consider: Repetitive registration pattern could be macro-ified.The 10 near-identical
if let Errblocks for registering PoolR{0..9} interfaces could be consolidated using a macro. However, this is a large migration PR, and the current explicit approach is clear and works correctly. This refactor can be deferred to a follow-up.src/dbus/manager/mod.rs (2)
45-142: The add_ methods handle edge cases correctly but have significant duplication.*The logic for
add_pool,add_filesystem, andadd_blockdevis nearly identical, differing only in the HashMap types and error messages. While the defensive programming pattern is sound (handling idempotent adds and detecting inconsistent state), this could be abstracted into a generic helper.🔎 Consider a generic helper to reduce duplication
fn add_entry<K, V>( path_to_uuid: &mut HashMap<OwnedObjectPath, V>, uuid_to_path: &mut HashMap<V, OwnedObjectPath>, path: &ObjectPath<'_>, uuid: V, entity_type: &str, ) -> StratisResult<()> where V: Eq + std::hash::Hash + Copy + std::fmt::Display, { match (path_to_uuid.get(path), uuid_to_path.get(&uuid)) { (Some(u), Some(p)) => { if uuid == *u && path == &p.as_ref() { Ok(()) } else { Err(StratisError::Msg(format!( "Attempted to add {entity_type} path {path}, UUID {uuid} but entry path {p}, UUID {u} already exists" ))) } } // ... rest of pattern } }
190-233: Graceful degradation pattern is appropriate, but consider using a loop.The continue-on-failure pattern is correct for graceful degradation. However, the repetitive registration calls could be condensed.
🔎 Consider using a macro or array of registration functions
pub async fn register_manager( connection: &Arc<Connection>, engine: &Arc<dyn Engine>, manager: &Lockable<Arc<RwLock<Manager>>>, counter: &Arc<AtomicU64>, ) { let registrations: [(fn(...) -> _, &str); 10] = [ (ManagerR0::register, "Manager.r0"), (ManagerR1::register, "Manager.r1"), // ... etc ]; for (register_fn, name) in registrations { if let Err(e) = register_fn(engine, connection, manager, counter).await { warn!("Failed to register interface {name}: {e}"); } } if let Err(e) = connection .object_server() .at(STRATIS_BASE_PATH, ObjectManager) .await { warn!("Failed to register ObjectManager at {STRATIS_BASE_PATH}: {e}"); } }Note: This would require the register functions to have identical signatures, which they should given the relevant code snippets showing all versions have the same signature.
src/engine/types/keys.rs (1)
470-494: Prefer implementingFrominstead ofInto.Rust conventions prefer implementing
From<&EncryptionInfo> for serde_json::Valuerather thanInto<serde_json::Value> for &EncryptionInfo. TheIntotrait is automatically derived whenFromis implemented, andFromis more idiomatic.🔎 Suggested refactor
-impl Into<serde_json::Value> for &EncryptionInfo { - fn into(self) -> serde_json::Value { +impl From<&EncryptionInfo> for serde_json::Value { + fn from(info: &EncryptionInfo) -> Self { - let json = self + let json = info .encryption_infos .iter() .map(|(token_slot, mech)| { ( token_slot.to_string(), match mech { UnlockMechanism::KeyDesc(kd) => { serde_json::Value::from(kd.as_application_str()) } UnlockMechanism::ClevisInfo((pin, config)) => { serde_json::Value::from(vec![ serde_json::Value::from(pin.to_owned()), config.to_owned(), ]) } }, ) }) .collect::<Map<_, _>>(); serde_json::Value::from(json) } }src/stratis/ipc_support/dbus_support.rs (1)
45-50: Single-branchselect!could be simplified.The
select!macro with a single branch is functionally equivalent to just awaiting the handle directly. Unless additional branches are planned for future expansion, consider simplifying.🔎 Optional simplification
- select! { - res = &mut udev_handle => { - error!("The udev processing thread exited..."); - res.map_err(StratisError::from) - } + let res = udev_handle.await; + error!("The udev processing thread exited..."); + res.map_err(StratisError::from) - }If additional event sources are expected to be added later (e.g., signal handlers, other IPC channels), keeping the
select!structure would be appropriate.src/dbus/pool/pool_3_0/methods.rs (1)
296-365: Acknowledge TODO: Blockdev registration and object path return pending.Multiple TODO comments indicate that blockdev registration and returning actual blockdev object paths are not yet implemented. The function currently returns
default_returneven on success.Would you like me to open an issue to track the blockdev registration implementation for
add_data_devs_method?src/dbus/util.rs (1)
108-204: Consider reducing repetitive signal dispatch code.The signal dispatch functions repeat nearly identical
send_signal!calls for each pool version (R0–R9). While functional, this pattern is error-prone (as shown by the bug on line 820) and adds significant code volume.A more maintainable approach could use a helper macro or loop construct, though this would require careful design given the different type parameters. This is optional and could be deferred.
8d3b3b4 to
625dda5
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
899c4a0 to
c16eb43
Compare
c16eb43 to
123ca04
Compare
|
Current testing repo outcomes: FAILED (failures=7, errors=2). stratis-storage/testing#333 should reduce failures by 1. It did. |
|
bingo. Fixing the |
089adf1 to
1740204
Compare
342fd97 to
279135f
Compare
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
129942f to
558feaf
Compare
For consistency's sake. Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
|
Builds are succeeding everywhere, but tests are failing on rawhide, which is kind of normal. |
Related to #2574
Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.