Skip to content

Commit

Permalink
Merge #1513
Browse files Browse the repository at this point in the history
1513: feat(eventing): Replica events r=datacore-vvarakantham a=datacore-vvarakantham

Added replica creation and deletion events.
And Replica event specific data(pool name, pool uuid, replica name).

Co-authored-by: Vandana Varakantham <yvandana.varakantham@datacore.com>
  • Loading branch information
mayastor-bors and Vandana Varakantham committed Oct 20, 2023
2 parents b559398 + 838e8ef commit f41ba98
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions io-engine/src/eventing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub(crate) mod nexus_events;
mod pool_events;
mod replica_events;
use events_api::event::{EventAction, EventMessage, EventMeta};

/// Event trait definition for creating events.
Expand Down
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
34 changes: 34 additions & 0 deletions io-engine/src/eventing/replica_events.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use events_api::event::{
EventAction,
EventCategory,
EventMessage,
EventMeta,
EventSource,
};

use crate::{
core::{logical_volume::LogicalVolume, MayastorEnvironment},
eventing::Event,
lvs::lvs_lvol::{Lvol, LvsLvol},
};

// 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,
)
.with_replica_data(
self.lvs().name(),
&self.lvs().uuid(),
&self.name(),
);

EventMessage {
category: EventCategory::Replica as i32,
action: event_action as i32,
target: self.uuid(),
metadata: Some(EventMeta::from_source(event_source)),
}
}
}
4 changes: 4 additions & 0 deletions io-engine/src/lvs/lvs_lvol.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use async_trait::async_trait;
use byte_unit::Byte;
use chrono::Utc;
use events_api::event::EventAction;
use futures::channel::oneshot;
use nix::errno::Errno;
use pin_utils::core_reexport::fmt::Formatter;
Expand Down Expand Up @@ -52,6 +53,7 @@ use crate::{
UntypedBdev,
UpdateProps,
},
eventing::Event,
ffihelper::{
cb_arg,
done_cb,
Expand Down Expand Up @@ -822,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 @@ -858,6 +861,7 @@ impl LvsLvol for Lvol {
}

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

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 @@ -877,6 +877,7 @@ impl Lvs {
}

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

Expand Down
2 changes: 1 addition & 1 deletion utils/io-engine-dependencies

0 comments on commit f41ba98

Please sign in to comment.