Skip to content

Commit

Permalink
feat: handle non-matching transport path removal
Browse files Browse the repository at this point in the history
Signed-off-by: Diwakar Sharma <[email protected]>
  • Loading branch information
dsharma-dc committed Sep 18, 2024
1 parent e407f51 commit bf605f5
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions control-plane/agents/src/bin/ha/node/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,31 @@ impl NodeAgentSvc {

tracing::info!(new_path, "Connecting to NVMe target");

// Check to ensure Nqn is already connected
if Subsystem::try_from_nqn(&nqn).is_err() {
return Err(SvcError::ReplaceNqnNotFound { nqn });
// Check to ensure Nqn is already connected.
// Additionally, if a path is found for this nqn where the transport is
// not the same as current parsed_uri's transport, we disconnect that path.
// Such a path could be to the same host as parsed_uri host or possibly a
// different host perhaps, but it is fairly safe to disconnect it. This should
// also take care of the fact that - even when the nexus/subsystem is rehosted on
// same node/host, the traddr might be different because with rdma the interface
// name of RNIC is explicitly set and that could be different than default MY_POD_IP.
let paths_for_nqn = Subsystem::try_from_nqn(&nqn)
.map_err(|_| SvcError::ReplaceNqnNotFound { nqn: nqn.clone() })?;

for path in paths_for_nqn {
let path_transport = TrType::try_from(path.clone().transport)
.map_err(|_| SvcError::InvalidArguments {})?;
if parsed_uri.transport().ne(&path_transport) {
let p_disconn = path.clone();
tokio::task::block_in_place(move || {
// Remove the subsystem.
if let Err(error) = p_disconn.disconnect() {
tracing::error!(?p_disconn, ?error, "Failed to disconnect stale NVMe path");
} else {
tracing::info!(?p_disconn, "Stale NVMe path successfully disconnected");
}
});
}
}

// Check if the NVMe subsystem already exists to not
Expand Down

0 comments on commit bf605f5

Please sign in to comment.