Skip to content

Commit

Permalink
feat(eventing): nvme path suspect and fail events
Browse files Browse the repository at this point in the history
Signed-off-by: Vandana Varakantham <[email protected]>
  • Loading branch information
datacore-vvarakantham committed Nov 7, 2023
1 parent 9fc5f84 commit 2b0235e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
12 changes: 12 additions & 0 deletions apis/events/protobuf/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum EventCategory {
Replica = 4;
Node = 5;
HighAvailability = 6;
NvmePath = 7;
}

// Event Action
Expand All @@ -40,6 +41,8 @@ enum EventAction {
SwitchOver = 6;
AddChild = 7;
RemoveChild = 8;
NvmePathSuspect = 9;
NvmePathFail = 10;
}

// Event meta data
Expand Down Expand Up @@ -69,6 +72,7 @@ enum Component {
CoreAgent = 1;
IoEngine = 2;
HaClusterAgent = 3;
HaNodeAgent = 4;
}

// Event message version
Expand All @@ -87,6 +91,8 @@ message EventDetails {
optional SwitchOverEventDetails switch_over_details = 3;
// Nexus child event details
optional NexusChildEventDetails nexus_child_details = 4;
// Nvme path event details
optional NvmePathEventDetails nvme_path_details = 5;
}

// Rebuild event details
Expand Down Expand Up @@ -156,3 +162,9 @@ message NexusChildEventDetails {
// Nexus child uri
string uri = 1;
}

// Nvme path event details
message NvmePathEventDetails {
string nqn = 1;
string path = 2;
}
19 changes: 17 additions & 2 deletions apis/events/src/event_traits.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::event::{
Component, EventDetails, EventMessage, EventMeta, EventSource, NexusChildEventDetails,
RebuildEventDetails, RebuildStatus, ReplicaEventDetails, SwitchOverEventDetails,
SwitchOverStatus, Version,
NvmePathEventDetails, RebuildEventDetails, RebuildStatus, ReplicaEventDetails,
SwitchOverEventDetails, SwitchOverStatus, Version,
};
use chrono::{DateTime, Utc};
use once_cell::sync::OnceCell;
Expand Down Expand Up @@ -124,6 +124,20 @@ impl EventSource {
..self
}
}

/// Add nvme path event specific data to event source.
pub fn with_nvme_path_data(self, nqn: &str, path: &str) -> Self {
EventSource {
event_details: Some(EventDetails {
nvme_path_details: Some(NvmePathEventDetails {
nqn: nqn.to_string(),
path: path.to_string(),
}),
..Default::default()
}),
..self
}
}
}

impl EventMessage {
Expand All @@ -142,6 +156,7 @@ impl FromStr for Component {
"agent-core" => Ok(Self::CoreAgent),
"io-engine" => Ok(Self::IoEngine),
"agent-ha-cluster" => Ok(Self::HaClusterAgent),
"agent-ha-node" => Ok(Self::HaNodeAgent),
_ => Err(format!("Received event from unknown component {c}")),
}
}
Expand Down

0 comments on commit 2b0235e

Please sign in to comment.