-
Notifications
You must be signed in to change notification settings - Fork 62
c8y-configuration-plugin panics when required folder/s are missing #1963
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ repository = { workspace = true } | |
|
||
[dependencies] | ||
async-trait = "0.1" | ||
log = "0.4" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In most of the other crates, we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I heard from @didier-wenzek is that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also agree that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a point we need to discuss. I have a preference for |
||
tedge_actors = { path = "../../core/tedge_actors" } | ||
tedge_utils = { path = "../../common/tedge_utils", features = ["fs-notify"] } | ||
tokio = { version = "1.23", features = ["macros"] } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
use async_trait::async_trait; | ||
use log::error; | ||
use std::path::PathBuf; | ||
use tedge_actors::futures::channel::mpsc; | ||
use tedge_actors::futures::StreamExt; | ||
|
@@ -121,9 +122,14 @@ impl Actor for FsWatchActor { | |
} | ||
|
||
async fn run(&mut self) -> Result<(), RuntimeError> { | ||
let mut fs_notify = NotifyStream::try_default().unwrap(); | ||
let mut fs_notify = NotifyStream::try_default().map_err(Box::new)?; | ||
for (watch_path, _) in self.messages.get_watch_dirs().iter() { | ||
fs_notify.add_watcher(watch_path).unwrap(); | ||
if let Err(err) = fs_notify.add_watcher(watch_path) { | ||
error!( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Although this approach is less invasive I'm starting to doubt if this is the right thing to do. The issue with it is that, we let the system continue in a broken state by silently logging the issue, which users may not notice immediately. If this actor fails to watch a directly that another actor has requested for, it is a fatal failure, in my opinion. So crashing the daemon is probably the better option I feel, so that the user immediately notices that something is wrong. Ideally, we should have a mechanism in the actor framework where this actor can communicate this failure to the requesting actor via an error and let that actor itself decide whether to crash or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are doing the validation up-front during build time and hence this error path is less likely to happen (unless someone deletes the dirs during runtime), this is okay for now. But, we'd still need to explore a better build time error exchange mechanism between actors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. |
||
"Failed to add file watcher to the {} due to: {err}", | ||
watch_path.display() | ||
); | ||
} | ||
} | ||
|
||
loop { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this error variant is generic enough, it's okay.
A better option to avoid "corrupting"
TEdgeConfigError
would have been to add a similar variant toConfigManagementError
andLogRetrievalError
enums respectively and have theConfigManagerConfig::from_tedge_config()
andLogManagerConfig::from_tedge_config()
functions return these specific errors instead ofTEdgeConfigError
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this error case is really not ideal, as it depends on
tedge_utils::paths::PathsError
.Albin's suggestion would avoid that.