Retry registry authentication outages and jitter executor reconnects (#50465)

## Why

Remote executors need to recover from confirmed authentication-service outages and spread reconnect attempts after a shared outage. Registration retries must remain limited to confirmed failures before a write, since replaying an ambiguous request can replace a newer registration.

## What changed

- Retry registry responses with HTTP 502 and `authentication_service_unavailable`, alongside the existing HTTP 503 `registration_conflict` retries.
- Accept structured registry errors in `detail`, keeping the canonical `error` authoritative when both are present.
- Randomize reconnect delays between half and all of the current exponential backoff, retaining the 30-second cap.

## Testing

Add coverage for reconnect jitter bounds, authentication-outage retry cancellation, error-envelope precedence, and preservation of Noise identity and initialized sessions across retries. Make the HTTP-header helper cleanup test wait for the helper PID before cancellation and verify process termination when the provider is dropped.

GitOrigin-RevId: 35fdb57732d17b0bbfeca8a4dc557a0988e29a31
This commit is contained in:
Anton Panasenko
2026-10-02 23:54:32 +00:00
committed by copyberry
parent a0bfaac70c
commit ef8cfe5e96
7 changed files with 156 additions and 24 deletions
@@ -1,4 +1,4 @@
//! Confirmed registration conflicts retry without replacing the Noise identity or session handler.
//! Pre-write registration failures retry without replacing the Noise identity or session handler.
use std::time::Duration;
@@ -43,6 +43,10 @@ impl RegistryFixture {
"security_profile": "noise_hybrid_ik_v1",
"executor_registration_id": format!("registration-{attempt}"),
}));
} else if status == 502 {
response = response.set_body_json(serde_json::json!({
"detail": {"code": "authentication_service_unavailable", "message": "Authentication service unavailable"},
}));
} else {
response = response.set_body_json(serde_json::json!({
"error": {"code": "registration_conflict", "message": "registration conflicted"},
@@ -139,9 +143,17 @@ impl RegistryFixture {
}
}
#[test_case::test_case(503; "registration_conflict")]
#[test_case::test_case(502; "authentication_service_unavailable")]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn registration_retries_preserve_noise_identity_and_initialized_session() -> Result<()> {
let fixture = RegistryFixture::new(vec![503, 200, 503, 503, 200], Duration::ZERO).await?;
async fn registration_retries_preserve_noise_identity_and_initialized_session(
retry_status: u16,
) -> Result<()> {
let fixture = RegistryFixture::new(
vec![retry_status, 200, retry_status, retry_status, 200],
Duration::ZERO,
)
.await?;
let (shutdown, remote) = fixture.start()?;
let harness_identity = NoiseChannelIdentity::generate()?;
let (client, first_relay) = fixture