Skip to content

Commit 991dc8d

Browse files
fix(logs): without logs it was impossible to understand why a agent was not starting (#1445)
1 parent 4cc2b94 commit 991dc8d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

agent-control/src/sub_agent.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,22 +182,24 @@ where
182182
self.maybe_opamp_client.as_ref().inspect(|c| {
183183
let _ = c
184184
.update_effective_config()
185-
.inspect_err(|e| error!("Effective config update failed: {e}"));
185+
.inspect_err(|e| error!("Failed to update effective config: {e}"));
186186
});
187187
return None;
188188
};
189189

190190
let effective_agent = self
191191
.effective_agent(config.get_yaml_config().clone())
192-
.map_err(SupervisorCreationError::from);
192+
.map_err(SupervisorCreationError::from)
193+
.inspect_err(|e| error!("Failed to create effective agent: {e}"));
193194

194195
let not_started_supervisor = effective_agent.and_then(|effective_agent| {
195196
self.supervisor_builder
196197
.build_supervisor(effective_agent)
197198
.map_err(SupervisorCreationError::from)
199+
.inspect_err(|e| error!("Failed to create supervisor: {e}"))
198200
});
199201

200-
if not_started_supervisor.is_ok() {
202+
let started_supervisor = not_started_supervisor.and_then(|stopped_supervisor| {
201203
// Communicate the config that we will be using
202204
// FIXME: only if we successfully build a supervisor?
203205
// What if we fail and we don't have a supervisor? Should we report?
@@ -210,13 +212,12 @@ where
210212
self.maybe_opamp_client.as_ref().inspect(|c| {
211213
let _ = c
212214
.update_effective_config()
213-
.inspect_err(|e| error!("Effective config update failed: {e}"));
215+
.inspect_err(|e| error!("Failed to update effective config: {e}"));
214216
});
215-
}
216217

217-
let started_supervisor = not_started_supervisor.and_then(|stopped_supervisor| {
218218
self.start_supervisor(stopped_supervisor)
219219
.map_err(SupervisorCreationError::from)
220+
.inspect_err(|e| error!("Failed to start supervisor: {e}"))
220221
});
221222

222223
// After all operations, set the hash to a final state
@@ -253,6 +254,12 @@ where
253254

254255
let mut supervisor = self.init_supervisor();
255256

257+
if supervisor.is_none() {
258+
debug!(
259+
"No supervisor found, but the runtime will continue to run waiting for remote configs"
260+
);
261+
}
262+
256263
// Stores the current health state for logging purposes.
257264
let mut previous_health = None;
258265

0 commit comments

Comments
 (0)