Skip to content

Commit

Permalink
buck2: OSS: RE GRPC: check errors in blob downloads
Browse files Browse the repository at this point in the history
Summary: Like it says in the title.

Reviewed By: ndmitchell

Differential Revision: D43310306

fbshipit-source-id: 085599fee3bebf3dfe2ce6ffbe70240c52001307
  • Loading branch information
krallin authored and facebook-github-bot committed Feb 20, 2023
1 parent 9c5c517 commit e582b75
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions remote_execution/oss/re_grpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use re_grpc_proto::build::bazel::remote::execution::v2::ExecuteResponse as GExec
use re_grpc_proto::build::bazel::remote::execution::v2::ResultsCachePolicy;
use re_grpc_proto::google::longrunning::operation::Result as OpResult;
use re_grpc_proto::google::rpc::Code;
use re_grpc_proto::google::rpc::Status;
use slog::Logger;
use tokio::fs::OpenOptions;
use tokio::io::AsyncWriteExt;
Expand Down Expand Up @@ -73,6 +74,17 @@ fn tstatus_ok() -> TStatus {
}
}

fn check_status(status: Status) -> Result<(), REClientError> {
if status.code == 0 {
return Ok(());
}

Err(REClientError {
code: TCode(status.code),
message: status.message,
})
}

fn ttimestamp_from(ts: Option<::prost_types::Timestamp>) -> TTimestamp {
match ts {
Some(timestamp) => TTimestamp {
Expand Down Expand Up @@ -212,6 +224,7 @@ impl REClient {
let mut result = None;

while let Some(operation) = stream.message().await? {
// TODO
if operation.done {
result = operation.result;
}
Expand Down Expand Up @@ -322,7 +335,7 @@ impl REClient {
error: REError {
code: TCode::OK,
message: execute_response_grpc.message,
error_location: ErrorLocation(0),
..Default::default()
},
cached_result: execute_response_grpc.cached_result,
action_digest: action_tdigest.clone(),
Expand Down Expand Up @@ -504,7 +517,7 @@ where
.responses
.into_iter()
.map(|r| {
// TODO(aloiscochard): Here we should check if r.status is ok!
check_status(r.status.unwrap_or_default())?;
let digest = tdigest_from(r.digest.context("Response digest not found.")?);
anyhow::Ok((digest, r.data))
})
Expand Down

0 comments on commit e582b75

Please sign in to comment.