Skip to content

Commit

Permalink
Version 0.13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronKutch committed Jun 17, 2024
1 parent 8e8dbf4 commit 5d06f47
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.13.1] - 2024-06-17
### Fixes
- `ContainerNetwork` error compilations now use the stderr, and fallback to stdout

## [0.13.0] - 2024-06-06
### Fixes
- Large container networks with common build definitions are dramatically faster to start
Expand Down
48 changes: 37 additions & 11 deletions src/docker_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@ impl ContainerNetwork {
}

/// Looks through the results and includes the last "Error: Error { stack:
/// [" or " panicked at " parts of stdouts. Omits stacks that have
/// "ProbablyNotRootCauseError".
/// [" or " panicked at " parts. Checks stderr first and falls back to
/// stdout. Omits stacks that have "ProbablyNotRootCauseError".
fn error_compilation(&mut self) -> Result<()> {
let not_root_cause = "ProbablyNotRootCauseError";
let error_stack = "Error { stack: [";
Expand All @@ -734,27 +734,53 @@ impl ContainerNetwork {
Ok(comres) => {
if !comres.successful() {
let mut encountered = false;
let stdout = comres.stdout_as_utf8_lossy();
if let Some(start) = stdout.rfind(error_stack) {
if !stdout.contains(not_root_cause) {

// check stderr
let stderr = comres.stderr_as_utf8_lossy();
if let Some(start) = stderr.rfind(error_stack) {
if !stderr.contains(not_root_cause) {
encountered = true;
res = res.add_kind_locationless(format!(
"Error stack from container \"{name}\":\n{}\n",
&stdout[start..]
"Error stack from container \"{name}\" stderr:\n{}\n",
&stderr[start..]
));
}
}

if let Some(i) = stdout.rfind(panicked_at) {
if let Some(i) = stdout[0..i].rfind("thread") {
if let Some(i) = stderr.rfind(panicked_at) {
if let Some(i) = stderr[0..i].rfind("thread") {
encountered = true;
res = res.add_kind_locationless(format!(
"Panic message from container \"{name}\":\n{}\n",
&stdout[i..]
"Panic message from container \"{name}\" stderr:\n{}\n",
&stderr[i..]
));
}
}

// check stdout only if stderr had nothing
if !encountered {
let stdout = comres.stdout_as_utf8_lossy();
if let Some(start) = stdout.rfind(error_stack) {
if !stdout.contains(not_root_cause) {
encountered = true;
res = res.add_kind_locationless(format!(
"Error stack from container \"{name}\" stdout:\n{}\n",
&stdout[start..]
));
}
}

if let Some(i) = stdout.rfind(panicked_at) {
if let Some(i) = stdout[0..i].rfind("thread") {
encountered = true;
res = res.add_kind_locationless(format!(
"Panic message from container \"{name}\" stdout:\n{}\n",
&stdout[i..]
));
}
}
}

if (!encountered) && (!comres.successful_or_terminated()) {
res = res.add_kind_locationless(format!(
"Error: Container \"{name}\" was unsuccessful but does not \
Expand Down
2 changes: 2 additions & 0 deletions src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pub fn ctrlc_issued_reset() -> bool {
pub fn type_hash<T: ?Sized>() -> [u8; 16] {
// we can't make this `const` currently because of `type_name`, however it
// should compile down to the result in practice, at least on release mode

// TODO `type_name` should be const soon
use sha3::{Digest, Sha3_256};
let name = type_name::<T>();
let mut hasher = Sha3_256::new();
Expand Down
2 changes: 1 addition & 1 deletion src/net_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl NetMessenger {
/// specified type, you should always use the turbofish to specify `T`,
/// because it is otherwise possible to get an unexpected type because
/// of `Deref` coercion.
pub async fn recv<T: ?Sized + DeserializeOwned>(&mut self) -> Result<T> {
pub async fn recv<T: DeserializeOwned>(&mut self) -> Result<T> {
// TODO handle timeouts
let expected_id = type_hash::<T>();
let mut actual_id = [0u8; 16];
Expand Down

0 comments on commit 5d06f47

Please sign in to comment.