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

fix(core/ha): re-share the nexus on republish #728

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions control-plane/agents/src/bin/core/nexus/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,8 @@ impl OperationGuardArc<NexusSpec> {
return Err(SvcError::NoOnlineReplicas { id: nexus.name });
}

match node.create_nexus(&CreateNexus::from(&nexus)).await {
Ok(nexus_state) if nexus_state.io_online() => {
nexus.info_span(|| tracing::info!("Nexus successfully recreated"));
Ok(())
}
let nexus_state = match node.create_nexus(&CreateNexus::from(&nexus)).await {
Ok(nexus_state) if nexus_state.io_online() => Ok(nexus_state),
Ok(nexus_state) => {
nexus.warn_span(|| {
tracing::warn!(
Expand All @@ -521,6 +518,15 @@ impl OperationGuardArc<NexusSpec> {
nexus.error_span(|| tracing::error!(error=%error, "Failed to recreate the nexus"));
Err(error)
}
}?;

self.info_span(|| tracing::info!("Nexus successfully recreated"));
// todo: would be good if nexus create also supported publish..
if nexus_state.share != nexus.share {
node.share_nexus(&ShareNexus::from(&nexus)).await?;
self.info_span(|| tracing::info!("Nexus protocol changed successfully"));
}

Ok(())
}
}
16 changes: 13 additions & 3 deletions control-plane/stor-port/src/types/v0/store/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ use crate::types::v0::{
transport::{
self, ChildState, ChildStateReason, ChildUri, CreateNexus, DestroyNexus, HostNqn, NexusId,
NexusNvmfConfig, NexusOwners, NexusShareProtocol, NexusStatus, NodeId, Protocol, ReplicaId,
VolumeId,
ShareNexus, VolumeId,
},
};
use pstor::ApiVersion;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;

/// Nexus information.
#[derive(Serialize, Deserialize, Debug, PartialEq)]
Expand Down Expand Up @@ -182,6 +181,17 @@ impl From<&NexusSpec> for CreateNexus {
)
}
}
impl From<&NexusSpec> for ShareNexus {
fn from(from: &NexusSpec) -> Self {
Self {
node: from.node.clone(),
uuid: from.uuid.clone(),
key: None,
protocol: from.share.try_into().unwrap_or_default(),
allowed_hosts: from.allowed_hosts.clone(),
}
}
}

impl AsOperationSequencer for NexusSpec {
fn as_ref(&self) -> &OperationSequence {
Expand All @@ -202,7 +212,7 @@ impl From<NexusSpec> for models::NexusSpec {
src.share,
src.size,
src.spec_status,
openapi::apis::Uuid::try_from(src.uuid).unwrap(),
src.uuid,
)
}
}
Expand Down
Loading