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(storage-manager): do not start when 'timestamping' is disabled #1219

Merged
merged 1 commit into from
Jul 7, 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
17 changes: 17 additions & 0 deletions plugins/zenoh-plugin-storage-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 12 additions & 0 deletions plugins/zenoh-plugin-storage-manager/tests/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 12 additions & 0 deletions plugins/zenoh-plugin-storage-manager/tests/wildcard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down