From 70ec1850f61d1c4a46448f80b4fb4b730390ee68 Mon Sep 17 00:00:00 2001 From: Preslav Le Date: Wed, 20 Mar 2024 15:47:44 -0700 Subject: [PATCH] Use custom error code when rejecting requests in Funrun (#23542) This will allow us to retry actions that were immediately rejected due to server overload safely. GitOrigin-RevId: 2636064e7f1ffcc24d91f24992bdd03095bc07cc --- crates/function_runner/src/server.rs | 4 ++-- crates/isolate/src/client.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/function_runner/src/server.rs b/crates/function_runner/src/server.rs index 27e0053e..917da26f 100644 --- a/crates/function_runner/src/server.rs +++ b/crates/function_runner/src/server.rs @@ -588,7 +588,7 @@ mod tests { let response = FunctionRunnerCore::>::receive_response(rx2).await?; let err = response.unwrap_err(); - assert!(err.is_overloaded()); + assert!(err.is_rejected_before_execution()); assert!(err.to_string().contains(NO_AVAILABLE_WORKERS)); Ok(()) } @@ -639,7 +639,7 @@ mod tests { let response = FunctionRunnerCore::>::receive_response(rx2).await?; let err = response.unwrap_err(); - assert!(err.is_overloaded()); + assert!(err.is_rejected_before_execution()); assert!(err.to_string().contains(NO_AVAILABLE_WORKERS)); Ok(()) } diff --git a/crates/isolate/src/client.rs b/crates/isolate/src/client.rs index 7ebbc9fa..b4ebe88d 100644 --- a/crates/isolate/src/client.rs +++ b/crates/isolate/src/client.rs @@ -451,9 +451,9 @@ impl Request { } fn reject(self) { - // TODO: Create a concrete error type for this so FunRun knows when to respond - // with a gRPC RESOURCE_EXHAUSTED code. - let error = ErrorMetadata::overloaded("WorkerOverloaded", NO_AVAILABLE_WORKERS).into(); + let error = + ErrorMetadata::rejected_before_execution("WorkerOverloaded", NO_AVAILABLE_WORKERS) + .into(); match self.inner { RequestType::Udf { response, .. } => { let _ = response.send(Err(error));