Skip to content

Commit

Permalink
feat(eventing): Replica events
Browse files Browse the repository at this point in the history
Signed-off-by: Vandana Varakantham <[email protected]>
  • Loading branch information
Vandana Varakantham committed Oct 9, 2023
1 parent 36f735a commit 0b55d22
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion io-engine/src/eventing/nexus_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl EventMetaGen for RebuildJob {
let event_source = EventSource::new(
MayastorEnvironment::global_or_default().node_name,
)
.add_rebuild_data(
.with_rebuild_data(
rebuild_status,
self.src_uri(),
self.dst_uri(),
Expand Down
11 changes: 8 additions & 3 deletions io-engine/src/eventing/replica_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ use events_api::event::{
use crate::{
core::{logical_volume::LogicalVolume, MayastorEnvironment},
eventing::Event,
lvs::Lvol,
lvs::lvs_lvol::{Lvol, LvsLvol},
};

// Pool event messages from Lvs data.
// Replica event messages from Lvol data.
impl Event for Lvol {
fn event(&self, event_action: EventAction) -> EventMessage {
let event_source = EventSource::new(
MayastorEnvironment::global_or_default().node_name,
)
.add_replica_data(&self.pool_name());
.with_replica_data(
self.lvs().name(),
&self.lvs().uuid(),
&self.uuid(),
);

EventMessage {
category: EventCategory::Replica as i32,
action: event_action as i32,
Expand Down
4 changes: 0 additions & 4 deletions io-engine/src/grpc/v1/replica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ use crate::{
UntypedBdev,
UpdateProps,
},
eventing::Event,
grpc::{rpc_submit, GrpcClientContext, GrpcResult, Serializer},
lvs::{Error as LvsError, Lvol, LvolSpaceUsage, Lvs, LvsLvol},
};
use ::function_name::named;
use events_api::event::EventAction;
use futures::FutureExt;
use mayastor_api::v1::replica::*;
use nix::errno::Errno;
Expand Down Expand Up @@ -209,7 +207,6 @@ impl ReplicaRpc for ReplicaService {
match Pin::new(&mut lvol).share_nvmf(Some(props)).await {
Ok(s) => {
debug!("created and shared {:?} as {}", lvol, s);
lvol.event(EventAction::Create).generate();
Ok(Replica::from(lvol))
}
Err(e) => {
Expand All @@ -225,7 +222,6 @@ impl ReplicaRpc for ReplicaService {
}
Ok(lvol) => {
debug!("created lvol {:?}", lvol);
lvol.event(EventAction::Create).generate();
Ok(Replica::from(lvol))
}
Err(e) => Err(e),
Expand Down
5 changes: 3 additions & 2 deletions io-engine/src/lvs/lvs_lvol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ impl LvsLvol for Lvol {
}
/// Destroy the lvol.
async fn destroy(mut self) -> Result<String, Error> {
let event = self.event(EventAction::Delete);
extern "C" fn destroy_cb(sender: *mut c_void, errno: i32) {
let sender =
unsafe { Box::from_raw(sender as *mut oneshot::Sender<i32>) };
Expand Down Expand Up @@ -860,6 +861,7 @@ impl LvsLvol for Lvol {
}

info!("destroyed lvol {}", name);
event.generate();
Ok(name)
}

Expand Down Expand Up @@ -1009,8 +1011,7 @@ impl LvsLvol for Lvol {
async fn destroy_replica(mut self) -> Result<String, Error> {
let snapshot_lvol = self.is_snapshot_clone();
let name = self.name();
self.clone().destroy().await?;
self.event(EventAction::Delete).generate();
self.destroy().await?;

// If destroy replica is a snapshot clone and it is the last
// clone from the snapshot, destroy the snapshot
Expand Down
1 change: 1 addition & 0 deletions io-engine/src/lvs/lvs_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ impl Lvs {
}

info!("{:?}: created", lvol);
lvol.event(EventAction::Create).generate();
Ok(lvol)
}

Expand Down

0 comments on commit 0b55d22

Please sign in to comment.