Better error handling for DiscoverInventoryAgentIntrepret #128

Open
opened 2025-08-31 22:10:20 +00:00 by letian · 1 comment
Owner

There's an edge case here that might break the DiscoverInventoryAgentInterpret:

discover_agents is awaited, but the spawned task inside the callback are not awaited at all. So in some edge cases, discover_agents might finish executing before the task itself.

And because we don't await for the task inside the callback, error handling is a bit awkward. Currently it says "all good" even though there could be an error:

[INFO ] Getting inventory for host 192.168.5.232 at port 8080

thread 'tokio-runtime-worker' panicked at /home/ian/Projects/nation-tech/harmony/harmony/src/modules/inventory/mod.rs:105:34:
called `Result::unwrap()` on an `Err` value: "Could not build repository : Could not connect to the database: error returned from database: (code: 14) unable to open database file"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[INFO ] ✅ Discovery process completed successfully

Originally posted by @letian in https://git.nationtech.io/NationTech/harmony/pulls/127/files#issuecomment-1987

There's an edge case here that might break the `DiscoverInventoryAgentInterpret`: `discover_agents` is awaited, but the _spawned_ task inside the callback are not awaited at all. So in some edge cases, `discover_agents` might finish executing before the task itself. And because we don't _await_ for the task inside the callback, error handling is a bit awkward. Currently it says "all good" even though there could be an error: ``` [INFO ] Getting inventory for host 192.168.5.232 at port 8080 thread 'tokio-runtime-worker' panicked at /home/ian/Projects/nation-tech/harmony/harmony/src/modules/inventory/mod.rs:105:34: called `Result::unwrap()` on an `Err` value: "Could not build repository : Could not connect to the database: error returned from database: (code: 14) unable to open database file" note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace [INFO ] ✅ Discovery process completed successfully ``` _Originally posted by @letian in https://git.nationtech.io/NationTech/harmony/pulls/127/files#issuecomment-1987_
Owner

Yep I thought about renaming the score to LaunchDiscoveryAgentScore it would make it way more intuitive for the current behavior without having to refactor anything more.

Yep I thought about renaming the score to `LaunchDiscoveryAgentScore` it would make it way more intuitive for the current behavior without having to refactor anything more.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: NationTech/harmony#128
No description provided.