Skip to content

Commit

Permalink
fix: missed renames from name to id in plugins (#1079)
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriele Baldoni <[email protected]>
  • Loading branch information
gabrik authored Jun 3, 2024
1 parent 16f1c43 commit d574654
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
8 changes: 4 additions & 4 deletions plugins/zenoh-plugin-trait/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,21 +322,21 @@ impl<StartArgs: PluginStartArgs + 'static, Instance: PluginInstance + 'static> P
);
let mut plugins = Vec::new();
for plugin in self.declared_plugins_iter() {
let name = unsafe { keyexpr::from_str_unchecked(plugin.name()) };
if names.includes(name) {
let id = unsafe { keyexpr::from_str_unchecked(plugin.id()) };
if names.includes(id) {
let status = PluginStatusRec::new(plugin.as_status());
plugins.push(status);
}
// for running plugins append their subplugins prepended with the running plugin name
if let Some(plugin) = plugin.loaded() {
if let Some(plugin) = plugin.started() {
if let [names, ..] = names.strip_prefix(name)[..] {
if let [names, ..] = names.strip_prefix(id)[..] {
plugins.append(
&mut plugin
.instance()
.plugins_status(names)
.into_iter()
.map(|s| s.prepend_name(name))
.map(|s| s.prepend_name(id))
.collect(),
);
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/zenoh-plugin-trait/src/manager/static_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ where
}
fn start(&mut self, args: &StartArgs) -> ZResult<&mut dyn StartedPlugin<StartArgs, Instance>> {
if self.instance.is_none() {
tracing::debug!("Plugin `{}` started", self.name());
tracing::debug!("Plugin `{}` started", self.id());
self.instance = Some(P::start(self.id(), args)?);
} else {
tracing::warn!("Plugin `{}` already started", self.name());
tracing::warn!("Plugin `{}` already started", self.id());
}
Ok(self)
}
Expand Down
23 changes: 12 additions & 11 deletions zenoh/src/net/runtime/adminspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,21 @@ impl AdminSpace {
start_args: &Runtime,
required: bool,
) -> ZResult<()> {
let id = &config.id;
let name = &config.name;
let declared = if let Some(declared) = plugin_mgr.plugin_mut(name) {
tracing::warn!("Plugin `{}` was already declared", declared.name());
let declared = if let Some(declared) = plugin_mgr.plugin_mut(id) {
tracing::warn!("Plugin `{}` was already declared", declared.id());
declared
} else if let Some(paths) = &config.paths {
plugin_mgr.declare_dynamic_plugin_by_paths(name, name, paths, required)?
plugin_mgr.declare_dynamic_plugin_by_paths(id, name, paths, required)?
} else {
plugin_mgr.declare_dynamic_plugin_by_name(name, name, required)?
plugin_mgr.declare_dynamic_plugin_by_name(id, name, required)?
};

let loaded = if let Some(loaded) = declared.loaded_mut() {
tracing::warn!(
"Plugin `{}` was already loaded from {}",
loaded.name(),
loaded.id(),
loaded.path()
);
loaded
Expand All @@ -125,12 +126,12 @@ impl AdminSpace {
};

if let Some(started) = loaded.started_mut() {
tracing::warn!("Plugin `{}` was already started", started.name());
tracing::warn!("Plugin `{}` was already started", started.id());
} else {
let started = loaded.start(start_args)?;
tracing::info!(
"Successfully started plugin `{}` from {}",
started.name(),
started.id(),
started.path()
);
};
Expand Down Expand Up @@ -768,7 +769,7 @@ fn plugins_data(context: &AdminContext, query: Query) {
let statuses = guard.plugins_status(names);
for status in statuses {
tracing::debug!("plugin status: {:?}", status);
let key = root_key.join(status.name()).unwrap();
let key = root_key.join(status.id()).unwrap();
let status = serde_json::to_value(status).unwrap();
if let Err(e) = query.reply(Ok(Sample::new(key, Value::from(status)))).res() {
tracing::error!("Error sending AdminSpace reply: {:?}", e);
Expand Down Expand Up @@ -834,15 +835,15 @@ fn plugins_status(context: &AdminContext, query: Query) {
}
}
Ok(Err(e)) => {
tracing::error!("Plugin {} bailed from responding to {}: {}", plugin.name(), query.key_expr(), e)
tracing::error!("Plugin {} bailed from responding to {}: {}", plugin.id(), query.key_expr(), e)
}
Err(e) => match e
.downcast_ref::<String>()
.map(|s| s.as_str())
.or_else(|| e.downcast_ref::<&str>().copied())
{
Some(e) => tracing::error!("Plugin {} panicked while responding to {}: {}", plugin.name(), query.key_expr(), e),
None => tracing::error!("Plugin {} panicked while responding to {}. The panic message couldn't be recovered.", plugin.name(), query.key_expr()),
Some(e) => tracing::error!("Plugin {} panicked while responding to {}: {}", plugin.id(), query.key_expr(), e),
None => tracing::error!("Plugin {} panicked while responding to {}. The panic message couldn't be recovered.", plugin.id(), query.key_expr()),
},
}
});
Expand Down
12 changes: 6 additions & 6 deletions zenoh/src/plugins/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) fn load_plugin(
required: bool,
) -> ZResult<()> {
let declared = if let Some(declared) = plugin_mgr.plugin_mut(name) {
tracing::warn!("Plugin `{}` was already declared", declared.name());
tracing::warn!("Plugin `{}` was already declared", declared.id());
declared
} else if let Some(paths) = paths {
plugin_mgr.declare_dynamic_plugin_by_paths(name, id, paths, required)?
Expand All @@ -35,7 +35,7 @@ pub(crate) fn load_plugin(
if let Some(loaded) = declared.loaded_mut() {
tracing::warn!(
"Plugin `{}` was already loaded from {}",
loaded.name(),
loaded.id(),
loaded.path()
);
} else {
Expand Down Expand Up @@ -76,13 +76,13 @@ pub(crate) fn start_plugins(runtime: &Runtime) {
tracing::info!(
"Starting {req} plugin \"{name}\"",
req = if required { "required" } else { "" },
name = plugin.name()
name = plugin.id()
);
match plugin.start(runtime) {
Ok(_) => {
tracing::info!(
"Successfully started plugin {} from {:?}",
plugin.name(),
plugin.id(),
plugin.path()
);
}
Expand All @@ -94,7 +94,7 @@ pub(crate) fn start_plugins(runtime: &Runtime) {
if required {
panic!(
"Plugin \"{}\" failed to start: {}",
plugin.name(),
plugin.id(),
if report.is_empty() {
"no details provided"
} else {
Expand All @@ -104,7 +104,7 @@ pub(crate) fn start_plugins(runtime: &Runtime) {
} else {
tracing::error!(
"Required plugin \"{}\" failed to start: {}",
plugin.name(),
plugin.id(),
if report.is_empty() {
"no details provided"
} else {
Expand Down

0 comments on commit d574654

Please sign in to comment.