Browse Source

Don't error on invalid `node_id` on `NodeConfig` request

Instead, send the error back as reply.
tags/v0.3.6
Philipp Oppermann 1 year ago
parent
commit
d76f08afbd
Failed to extract signature
1 changed files with 14 additions and 19 deletions
  1. +14
    -19
      binaries/daemon/src/lib.rs

+ 14
- 19
binaries/daemon/src/lib.rs View File

@@ -724,16 +724,11 @@ impl Daemon {
.count();

let node_config = match number_node_id {
2.. => {
let _ = reply_tx.send(Some(DaemonReply::NodeConfig {
result: Err(format!(
"multiple dataflows contains dynamic node id {}. Please only have one running dataflow with the specified node id if you want to use dynamic node",
node_id
)
.to_string()),
}));
return Ok(());
}
2.. => Err(format!(
"multiple dataflows contains dynamic node id {node_id}. \
Please only have one running dataflow with the specified \
node id if you want to use dynamic node",
)),
1 => self
.running
.iter()
@@ -751,18 +746,18 @@ impl Daemon {
Ok(node_config)
})
.next()
.context("no node with ID `{node_id}`")?
.context("failed to get dynamic node config within given dataflow")?,
0 => {
let _ = reply_tx.send(Some(DaemonReply::NodeConfig {
result: Err("no node with ID `{node_id}`".to_string()),
}));
return Ok(());
}
.ok_or_else(|| eyre!("no node with ID `{node_id}`"))
.and_then(|r| r)
.map_err(|err| {
format!(
"failed to get dynamic node config within given dataflow: {err}"
)
}),
0 => Err("no node with ID `{node_id}`".to_string()),
};

let reply = DaemonReply::NodeConfig {
result: Ok(node_config),
result: node_config,
};
let _ = reply_tx.send(Some(reply)).map_err(|_| {
error!("could not send node info reply from daemon to coordinator")


Loading…
Cancel
Save