Skip to content

Commit 2787179

Browse files
committed
fix: Add better error logging for DNS configuration
Add warn! logs when DNS setup fails to help debug why tests get 'Could not resolve host' errors.
1 parent 3308c55 commit 2787179

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

src/jail/linux/mod.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ nameserver {}\n",
453453
);
454454

455455
// Write nameserver directly using sh -c echo
456-
let write_result = netlink::execute_in_netns(
456+
match netlink::execute_in_netns(
457457
&namespace_name,
458458
&[
459459
"sh".to_string(),
@@ -462,12 +462,22 @@ nameserver {}\n",
462462
],
463463
&[],
464464
None,
465-
);
466-
467-
if write_result.is_ok() {
468-
debug!("Successfully configured DNS in namespace");
469-
} else {
470-
debug!("Failed to write resolv.conf, DNS may not work in namespace");
465+
) {
466+
Ok(status) if status.success() => {
467+
debug!("Successfully configured DNS in namespace");
468+
}
469+
Ok(status) => {
470+
warn!(
471+
"Failed to write resolv.conf in namespace (exit: {}), DNS may not work",
472+
status.code().unwrap_or(-1)
473+
);
474+
}
475+
Err(e) => {
476+
warn!(
477+
"Error configuring DNS in namespace: {}. DNS may not work.",
478+
e
479+
);
480+
}
471481
}
472482

473483
Ok(())

0 commit comments

Comments
 (0)