diff --git a/nativelink-error/BUILD.bazel b/nativelink-error/BUILD.bazel index 08d8783de..6f0a05e4a 100644 --- a/nativelink-error/BUILD.bazel +++ b/nativelink-error/BUILD.bazel @@ -15,6 +15,7 @@ rust_library( "//nativelink-metric", "//nativelink-proto", "@crates//:fred", + "@crates//:google-cloud-storage", "@crates//:hex", "@crates//:prost", "@crates//:prost-types", diff --git a/nativelink-error/Cargo.toml b/nativelink-error/Cargo.toml index eeb4e8f1e..15494f6c2 100644 --- a/nativelink-error/Cargo.toml +++ b/nativelink-error/Cargo.toml @@ -19,3 +19,4 @@ prost-types = { version = "0.13.4", default-features = false } serde = { version = "1.0.216", default-features = false } tokio = { version = "1.42.0", features = ["fs", "rt-multi-thread", "signal", "io-util"], default-features = false } tonic = { version = "0.12.3", features = ["transport", "tls"], default-features = false } +google-cloud-storage = "0.23.0" diff --git a/nativelink-error/src/lib.rs b/nativelink-error/src/lib.rs index 30025eca5..6417d6853 100644 --- a/nativelink-error/src/lib.rs +++ b/nativelink-error/src/lib.rs @@ -14,6 +14,7 @@ use std::convert::Into; +pub use google_cloud_storage::http::Error as GcsError; use nativelink_metric::{ MetricFieldData, MetricKind, MetricPublishKnownKindData, MetricsComponent, }; @@ -219,6 +220,36 @@ impl From for Error { } } +impl From for Error { + fn from(err: GcsError) -> Self { + match err { + GcsError::Response(error_response) => { + make_err!( + Code::Unavailable, + "GCS Response Error: {:?}", + error_response + ) + } + GcsError::HttpClient(error) => { + make_err!(Code::Unavailable, "GCS HTTP Client Error: {:?}", error) + } + GcsError::HttpMiddleware(error) => { + make_err!(Code::Unavailable, "GCS HTTP Middleware Error: {:?}", error) + } + GcsError::TokenSource(error) => { + make_err!(Code::Unauthenticated, "GCS Token Source Error: {:?}", error) + } + GcsError::InvalidRangeHeader(header) => { + make_err!( + Code::InvalidArgument, + "GCS Invalid Range Header: {:?}", + header + ) + } + } + } +} + impl From for Error { fn from(error: fred::error::Error) -> Self { use fred::error::ErrorKind::{ diff --git a/nativelink-store/BUILD.bazel b/nativelink-store/BUILD.bazel index afad1f167..efe7b6479 100644 --- a/nativelink-store/BUILD.bazel +++ b/nativelink-store/BUILD.bazel @@ -56,6 +56,7 @@ rust_library( "@crates//:filetime", "@crates//:fred", "@crates//:futures", + "@crates//:google-cloud-storage", "@crates//:hex", "@crates//:http-body", "@crates//:hyper-0.14.31", @@ -63,8 +64,11 @@ rust_library( "@crates//:lz4_flex", "@crates//:parking_lot", "@crates//:patricia_tree", + "@crates//:percent-encoding", "@crates//:prost", "@crates//:rand", + "@crates//:reqwest", + "@crates//:reqwest-middleware", "@crates//:serde", "@crates//:tokio", "@crates//:tokio-stream",