Skip to content

Commit

Permalink
Improve errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Jan 27, 2025
1 parent 68962b1 commit 02ef091
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 38 deletions.
17 changes: 9 additions & 8 deletions crates/remote/src/grpc_remote_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl RemoteClient for GrpcRemoteClient {
hash = &digest.hash,
code = ?code,
"Failed to cache action result: {}",
status.message()
color::muted_light(status.message()),
);

Ok(None)
Expand All @@ -319,7 +319,7 @@ impl RemoteClient for GrpcRemoteClient {
hash = &digest.hash,
code = ?code,
"Remote service is out of storage space: {}",
status.message()
color::muted_light(status.message()),
);

Ok(None)
Expand Down Expand Up @@ -398,11 +398,11 @@ impl RemoteClient for GrpcRemoteClient {
details = ?status.details,
code = ?code,
"Failed to download blob: {}",
if status.message.is_empty() {
color::muted_light(if status.message.is_empty() {
code.to_string()
} else {
status.message
}
}),
);
}
}
Expand Down Expand Up @@ -479,7 +479,7 @@ impl RemoteClient for GrpcRemoteClient {
hash = &digest.hash,
code = ?code,
"Remote service exhausted resource: {}",
status.message()
color::muted_light(status.message()),
);

Ok(vec![])
Expand All @@ -503,11 +503,11 @@ impl RemoteClient for GrpcRemoteClient {
details = ?status.details,
code = ?code,
"Failed to upload blob: {}",
if status.message.is_empty() {
color::muted_light(if status.message.is_empty() {
code.to_string()
} else {
status.message
}
}),
);
}
}
Expand Down Expand Up @@ -575,7 +575,8 @@ impl RemoteClient for GrpcRemoteClient {
warn!(
hash = &digest.hash,
blob_hash = &blob.digest.hash,
"Failed to stream upload blob: {error}",
"Failed to stream upload blob: {}",
color::muted_light(error.to_string()),
);

return Ok(None);
Expand Down
14 changes: 9 additions & 5 deletions crates/remote/src/http_remote_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl RemoteClient for HttpRemoteClient {
hash = &digest.hash,
code = status.as_u16(),
"Failed to cache action result: {}",
status
color::muted_light(status.to_string()),
);

Ok(None)
Expand Down Expand Up @@ -305,14 +305,16 @@ impl RemoteClient for HttpRemoteClient {
warn!(
hash = &action_hash,
blob_hash = &blob_digest.hash,
"Failed to download blob: {status}",
"Failed to download blob: {}",
color::muted_light(status.to_string()),
);
}
Err(error) => {
warn!(
hash = &action_hash,
blob_hash = &blob_digest.hash,
"Failed to download blob: {error}",
"Failed to download blob: {}",
color::muted_light(error.to_string()),
);

if debug_enabled {
Expand Down Expand Up @@ -383,14 +385,16 @@ impl RemoteClient for HttpRemoteClient {
warn!(
hash = &action_hash,
blob_hash = &blob.digest.hash,
"Failed to upload blob: {status}",
"Failed to upload blob: {}",
color::muted_light(status.to_string()),
);
}
Err(error) => {
warn!(
hash = &action_hash,
blob_hash = &blob.digest.hash,
"Failed to upload blob: {error}",
"Failed to upload blob: {}",
color::muted_light(error.to_string()),
);

if debug_enabled {
Expand Down
3 changes: 0 additions & 3 deletions crates/remote/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,4 @@ pub use remote_service::*;

// TODO:
// - Other digest functions besides sha256
// - Proper error handling
// - Directory blob types
// - Write/read bytestream for large blobs
// - TLS/mTLS issues
56 changes: 34 additions & 22 deletions crates/remote/src/remote_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,28 +392,35 @@ async fn batch_upload_blobs(
let client = Arc::clone(&client);
let digest = digest.to_owned();

// Streaming
if group.stream {
set.spawn(async move {
if let Err(error) = client
match client
.stream_update_blob(&digest, group.items.remove(0))
.await
{
warn!(
hash = &digest.hash,
group = group_index + 1,
"Failed to upload blob: {}",
color::muted_light(error.to_string()),
);

return false;
}
Ok(result) => {
if result.is_some() {
return true;
}
}
Err(error) => {
warn!(
hash = &digest.hash,
group = group_index + 1,
"Failed to stream upload blob: {}",
color::muted_light(error.to_string()),
);
}
};

true
false
});

continue;
}

// Not streaming
if group_total > 1 {
trace!(
hash = &digest.hash,
Expand All @@ -427,18 +434,23 @@ async fn batch_upload_blobs(
}

set.spawn(async move {
if let Err(error) = client.batch_update_blobs(&digest, group.items).await {
warn!(
hash = &digest.hash,
group = group_index + 1,
"Failed to upload blobs: {}",
color::muted_light(error.to_string()),
);

return false;
}
match client.batch_update_blobs(&digest, group.items).await {
Ok(result) => {
if result.into_iter().all(|res| res.is_some()) {
return true;
}
}
Err(error) => {
warn!(
hash = &digest.hash,
group = group_index + 1,
"Failed to upload blobs: {}",
color::muted_light(error.to_string()),
);
}
};

true
false
});
}

Expand Down

0 comments on commit 02ef091

Please sign in to comment.