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(upgrade): don't use reservations without ha #796

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,10 @@ impl AgentToIoEngine for transport::DestroyPool {
impl AgentToIoEngine for transport::CreateNexus {
type IoEngineMessage = v0::CreateNexusV2Request;
fn to_rpc(&self) -> Self::IoEngineMessage {
let nexus_config = self
.config
.clone()
.unwrap_or_else(|| NexusNvmfConfig::default().with_no_resv());
let nexus_config = match self.config.as_ref() {
Some(config) if config != &NexusNvmfConfig::default().with_no_resv() => config.clone(),
_ => NexusNvmfConfig::default().with_no_resv_v0(),
};
Self::IoEngineMessage {
name: self.name(),
uuid: self.uuid.clone().into(),
Expand Down
9 changes: 7 additions & 2 deletions control-plane/agents/src/bin/core/node/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,13 @@ impl Service {
let node = nodes.write().await.get_mut(&node_state.id).cloned();
let send_event = match node {
None => {
let mut node =
NodeWrapper::new(&node_state, self.deadline, self.comms_timeouts.clone());
let ha_disabled = self.registry.ha_disabled();
let mut node = NodeWrapper::new(
&node_state,
self.deadline,
self.comms_timeouts.clone(),
ha_disabled,
);

// On startup api version is not known, thus probe all apiversions
let result = match startup {
Expand Down
17 changes: 16 additions & 1 deletion control-plane/agents/src/bin/core/node/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ pub(crate) struct NodeWrapper {
states: ResourceStatesLocked,
/// The number of rebuilds in progress on the node.
num_rebuilds: Arc<RwLock<NumRebuilds>>,
/// If HA is disabled, don't use reservations when creating nexuses.
disable_ha: bool,
}

impl NodeWrapper {
Expand All @@ -106,6 +108,7 @@ impl NodeWrapper {
node: &NodeState,
deadline: std::time::Duration,
comms_timeouts: NodeCommsTimeout,
disable_ha: bool,
) -> Self {
tracing::debug!("Creating new node {:?}", node);
Self {
Expand All @@ -116,6 +119,7 @@ impl NodeWrapper {
comms_timeouts,
states: ResourceStatesLocked::new(),
num_rebuilds: Arc::new(RwLock::new(0)),
disable_ha,
}
}

Expand All @@ -134,6 +138,7 @@ impl NodeWrapper {
),
states: ResourceStatesLocked::new(),
num_rebuilds: Arc::new(RwLock::new(0)),
disable_ha: false,
}
}

Expand Down Expand Up @@ -601,6 +606,7 @@ impl NodeWrapper {
tracing::info!(
node.id = %self.id(),
node.endpoint = self.endpoint_str(),
api.versions = ?self.node_state.api_versions,
startup,
"Preloading node"
);
Expand Down Expand Up @@ -1432,7 +1438,16 @@ impl NexusApi<()> for Arc<tokio::sync::RwLock<NodeWrapper>> {
});
}
let dataplane = self.grpc_client_locked(request.id()).await?;
match dataplane.create_nexus(request).await {
let disable_resv = self.read().await.disable_ha;
let result = if disable_resv {
let mut request = request.clone();
request.config = None;
dataplane.create_nexus(&request).await
} else {
dataplane.create_nexus(request).await
};

match result {
Ok(nexus) => {
self.update_nexus_state(Either::Insert(nexus.clone())).await;
Ok(nexus)
Expand Down
7 changes: 7 additions & 0 deletions control-plane/stor-port/src/types/v0/transport/nexus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,13 @@ impl NexusNvmfConfig {
self.reservation_type = NvmeReservation::Reserved;
self
}
/// On v0 reservations are mostly disabled, simply set key to 1 to avoid failure.
pub fn with_no_resv_v0(mut self) -> Self {
self.reservation_key = 1;
self.preempt_policy = NexusNvmePreemption::ArgKey(None);
self.reservation_type = NvmeReservation::Reserved;
self
}
}

impl Default for NexusNvmfConfig {
Expand Down
Loading