diff --git a/plugins/zenoh-plugin-storage-manager/src/lib.rs b/plugins/zenoh-plugin-storage-manager/src/lib.rs index c916b649d9..7399d3e507 100644 --- a/plugins/zenoh-plugin-storage-manager/src/lib.rs +++ b/plugins/zenoh-plugin-storage-manager/src/lib.rs @@ -31,6 +31,7 @@ use memory_backend::MemoryBackend; use storages_mgt::StorageMessage; use zenoh::{ internal::{ + bail, plugins::{Response, RunningPlugin, RunningPluginTrait, ZenohPlugin}, runtime::Runtime, zlock, LibLoader, @@ -120,6 +121,22 @@ impl StorageRuntimeInner { let session = Arc::new(zenoh::session::init(runtime.clone()).wait()?); + // NOTE: All storage **must** have a timestamp associated with a Sample. Considering that it is possible to make + // a publication without associating a timestamp, that means that the node managing the storage (be it a + // Zenoh client / peer / router) has to add it. + // + // If the `timestamping` configuration setting is disabled then there is no HLC associated with the + // Session. That eventually means that no timestamp can be generated which goes against the previous + // requirement. + // + // Hence, in that scenario, we refuse to start the storage manager and any storage. + if session.hlc().is_none() { + tracing::error!( + "Cannot start storage manager (and thus any storage) without the 'timestamping' setting enabled in the Zenoh configuration" + ); + bail!("Cannot start storage manager, 'timestamping' is disabled in the configuration"); + } + // After this moment result should be only Ok. Failure of loading of one voulme or storage should not affect others. let mut new_self = StorageRuntimeInner { diff --git a/plugins/zenoh-plugin-storage-manager/tests/operations.rs b/plugins/zenoh-plugin-storage-manager/tests/operations.rs index c1ed09b1a7..d8ada83e4c 100644 --- a/plugins/zenoh-plugin-storage-manager/tests/operations.rs +++ b/plugins/zenoh-plugin-storage-manager/tests/operations.rs @@ -70,6 +70,18 @@ async fn test_updates_in_order() { }"#, ) .unwrap(); + config + .insert_json5( + "timestamping", + r#"{ + enabled: { + router: true, + peer: true, + client: true + } + }"#, + ) + .unwrap(); let runtime = zenoh::internal::runtime::RuntimeBuilder::new(config) .build() diff --git a/plugins/zenoh-plugin-storage-manager/tests/wildcard.rs b/plugins/zenoh-plugin-storage-manager/tests/wildcard.rs index d6e94ecb1f..d1633a28d4 100644 --- a/plugins/zenoh-plugin-storage-manager/tests/wildcard.rs +++ b/plugins/zenoh-plugin-storage-manager/tests/wildcard.rs @@ -71,6 +71,18 @@ async fn test_wild_card_in_order() { }"#, ) .unwrap(); + config + .insert_json5( + "timestamping", + r#"{ + enabled: { + router: true, + peer: true, + client: true + } + }"#, + ) + .unwrap(); let runtime = zenoh::internal::runtime::RuntimeBuilder::new(config) .build()