Skip to content

Commit 6769077

Browse files
feat/improve agent type not found log (#1019)
* feat: improve agent type not found log
1 parent 43177aa commit 6769077

File tree

6 files changed

+8
-9
lines changed

6 files changed

+8
-9
lines changed

agent-control/src/agent_type/agent_type_registry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use super::definition::AgentTypeDefinition;
55

66
#[derive(Error, Debug)]
77
pub enum AgentRepositoryError {
8-
#[error("agent not found")]
9-
NotFound,
8+
#[error("agent type `{0}` not found")]
9+
NotFound(String),
1010
#[error("agent `{0}` already exists")]
1111
AlreadyExists(String),
1212
#[error("`{0}`")]
@@ -48,7 +48,7 @@ pub mod tests {
4848
self.expect_get()
4949
.with(predicate::eq(name.clone()))
5050
.once()
51-
.returning(move |_| Err(AgentRepositoryError::NotFound));
51+
.returning(move |_| Err(AgentRepositoryError::NotFound(name.clone())));
5252
}
5353
}
5454
}

agent-control/src/agent_type/embedded_registry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl AgentRegistry for EmbeddedRegistry {
4141
self.0
4242
.get(name)
4343
.cloned()
44-
.ok_or(AgentRepositoryError::NotFound)
44+
.ok_or(AgentRepositoryError::NotFound(name.to_string()))
4545
}
4646
}
4747

@@ -149,7 +149,7 @@ pub mod tests {
149149
assert_eq!(definitions[1], agent_2);
150150

151151
let err = registry.get("not-existent").unwrap_err();
152-
assert_matches!(err, AgentRepositoryError::NotFound);
152+
assert_matches!(err, AgentRepositoryError::NotFound(_));
153153
}
154154

155155
#[test]

agent-control/src/sub_agent/effective_agents_assembler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ pub(crate) mod tests {
383383

384384
assert!(result.is_err());
385385
assert_eq!(
386-
"error assembling agents: `agent not found`",
386+
"error assembling agents: `agent type `namespace/some_fqn:0.0.1` not found`",
387387
result.unwrap_err().to_string()
388388
);
389389
}

agent-control/src/sub_agent/sub_agent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ where
259259
.supervisor_assembler
260260
.assemble_supervisor(&self.maybe_opamp_client)
261261
.inspect_err(
262-
|e| error!(agent_id = %self.agent_id, error = %e,"cannot assemble supervisor"),
262+
|e| error!(agent_id = %self.agent_id, agent_type=%self.agent_cfg.agent_type, error = %e,"cannot assemble supervisor"),
263263
)
264264
.ok();
265265

agent-control/src/sub_agent/supervisor/assembler.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ where
9696
|e| error!(%self.agent_id, %e, "error reporting remote config status"),
9797
);
9898
}
99-
error!(agent_id=%self.agent_id, err = %e, "Error building the supervisor");
10099
Err(SupervisorAssemblerError::AgentAssembleError(e.to_string()))
101100
}
102101
Ok(effective_agent) => {

test/e2e/ansible/agent_control_invalid_remote_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161

162162
- name: get latest logs from the Agent Control
163163
# We were expecting this error:
164-
# "Error applying Agent Control remote config: .config assembler error: .error assembling agents: .agent not found..."'
164+
# "Error applying Agent Control remote config: .config assembler error: .error assembling agents: .agent type `{agent type}` not found..."'
165165
# But OpAMP call fails because now on the server they return a 500 when an agent_type doesn't exist,
166166
# so the builder throws the opamp error instead:
167167
shell: 'journalctl -u newrelic-agent-control --since "1min ago" | grep -E "Error applying Agent Control remote config: .OpAMP client error"'

0 commit comments

Comments
 (0)