Skip to content

Commit 90258e9

Browse files
committed
ddm-admin-client: avoid duplicate error logging from DdmError
As described in docs/error-types-and-logging.adoc, recursing into a source's Display implementation can result in duplicated error text in log output, so this commit updates the error attributes on DdmError's variants to stop doing this. Unfortunately, this type of change is breaking, in terms of how callers must log an error, but the difference isn't visible to the type system, and therefore won't result in compilation errors. Accordingly, this commit also updates any callers that were previously relying on the old Display implementation, so they walk the error chain instead.
1 parent 5552f18 commit 90258e9

File tree

7 files changed

+11
-8
lines changed

7 files changed

+11
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/ddm-admin-client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ sled-hardware-types.workspace = true
2121
omicron-workspace-hack.workspace = true
2222
ddm-admin-client.workspace = true
2323
uuid.workspace = true
24+
slog-error-chain.workspace = true

clients/ddm-admin-client/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use sled_hardware_types::underlay::BOOTSTRAP_MASK;
1818
use sled_hardware_types::underlay::BOOTSTRAP_PREFIX;
1919
use sled_hardware_types::underlay::BootstrapInterface;
2020
use slog::Logger;
21+
use slog_error_chain::SlogInlineError;
2122
use std::net::Ipv6Addr;
2223
use std::net::SocketAddr;
2324
use std::net::SocketAddrV6;
@@ -28,12 +29,12 @@ use crate::types::EnableStatsRequest;
2829
// TODO-cleanup Is it okay to hardcode this port number here?
2930
const DDMD_PORT: u16 = 8000;
3031

31-
#[derive(Debug, Error)]
32+
#[derive(Debug, Error, SlogInlineError)]
3233
pub enum DdmError {
33-
#[error("Failed to construct an HTTP client: {0}")]
34+
#[error("Failed to construct an HTTP client")]
3435
HttpClient(#[from] reqwest::Error),
3536

36-
#[error("Failed making HTTP request to ddmd: {0}")]
37+
#[error("Failed making HTTP request to ddmd")]
3738
DdmdApi(#[from] Error<types::Error>),
3839
}
3940

sled-agent/src/bootstrap/bootstore_setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub async fn poll_ddmd_for_bootstore_and_tq_peer_update(
144144
Err(err) => {
145145
warn!(
146146
log, "Failed to get prefixes from ddmd";
147-
"err" => #%err,
147+
&err,
148148
);
149149
break;
150150
}

sled-agent/src/bootstrap/early_networking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub enum EarlyNetworkSetupError {
6262
#[error("Bad configuration for setting up rack: {0}")]
6363
BadConfig(String),
6464

65-
#[error("Error contacting ddmd: {0}")]
65+
#[error("Error contacting ddmd")]
6666
DdmError(#[from] DdmError),
6767

6868
#[error("Error during request to MGS: {0}")]

sled-agent/src/services.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ pub enum Error {
194194
#[error(transparent)]
195195
ZoneInstall(#[from] illumos_utils::running_zone::InstallZoneError),
196196

197-
#[error("Error contacting ddmd: {0}")]
197+
#[error("Error contacting ddmd")]
198198
DdmError(#[from] DdmError),
199199

200200
#[error("Failed to access underlay device: {0}")]

wicketd/src/bootstrap_addrs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ async fn possible_sled_agent_addrs(
145145
Err(err) => {
146146
warn!(
147147
log, "Failed to get prefixes from ddm";
148-
"err" => #%err,
148+
&err,
149149
);
150150
tokio::time::sleep(RETRY).await;
151151
}
@@ -164,7 +164,7 @@ async fn make_ddm_admin_client(log: &Logger) -> DdmAdminClient {
164164
Err(err) => {
165165
warn!(
166166
log, "Failed to construct DdmAdminClient";
167-
"err" => #%err,
167+
&err,
168168
);
169169
tokio::time::sleep(DDM_CONSTRUCT_RETRY).await;
170170
}

0 commit comments

Comments
 (0)