From 231655b70a29475dd0f0835d3eb897b8548b404d Mon Sep 17 00:00:00 2001 From: Michal Schreiber <73832189+ck-michals@users.noreply.github.com> Date: Thu, 1 Oct 2026 04:53:52 +0200 Subject: [PATCH] fix(ecr): answer GetAuthorizationToken without the backing registry (#4635) GetAuthorizationToken is an authentication call. The token is a constant and proxyEndpoint is computed from configuration, so neither value involves the registry:2 container, and EcrRegistryManager already documents its URI methods as not requiring Docker. Gating the call on requireRegistry() returned a retryable 500 whenever no Docker daemon was reachable from Floci, which SDK and IaC clients retried with backoff before touching any repository, while CreateRepository and DescribeRepositories answered 200 in the same state. The four image operations keep the gate: they do need the container. Closes #4634 --- .../floci/services/ecr/EcrService.java | 4 +++- .../floci/services/ecr/EcrServiceTest.java | 20 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java b/src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java index 3694451955..05e90626c5 100644 --- a/src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java +++ b/src/main/java/io/github/hectorvent/floci/services/ecr/EcrService.java @@ -428,7 +428,9 @@ public class EcrService implements ResourceProvider { // ============================================================ public AuthorizationData getAuthorizationToken() { - requireRegistry(); + // Deliberately not gated on the backing registry: AWS answers this call from the + // control plane, and both values here are computed without Docker. Gating it made + // every SDK client retry a 500 before its first repository call. String token = Base64.getEncoder() .encodeToString("AWS:floci".getBytes(StandardCharsets.UTF_8)); Instant expires = Instant.now().plusSeconds(12 * 60 * 60); diff --git a/src/test/java/io/github/hectorvent/floci/services/ecr/EcrServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/ecr/EcrServiceTest.java index 255e4e3c9e..ff3a8d4c89 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ecr/EcrServiceTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ecr/EcrServiceTest.java @@ -375,11 +375,6 @@ class EcrServiceTest { service.createRepository(REPO, null, null, null, null, null, null, REGION); when(registryManager.tryEnsureStarted()).thenReturn(false); - AwsException auth = assertThrows(AwsException.class, () -> service.getAuthorizationToken()); - assertEquals("ServerException", auth.getErrorCode()); - assertEquals(500, auth.getHttpStatus()); - assertTrue(auth.getMessage().contains("Docker"), auth.getMessage()); - assertEquals("ServerException", assertThrows(AwsException.class, () -> service.listImages(REPO, null, REGION)).getErrorCode()); assertEquals("ServerException", @@ -393,6 +388,19 @@ class EcrServiceTest { () -> service.batchDeleteImage(REPO, List.of(), null, REGION)).getErrorCode()); } + @Test + void getAuthorizationToken_succeedsWhenRegistryIsUnavailable() { + when(registryManager.tryEnsureStarted()).thenReturn(false); + + AuthorizationData data = service.getAuthorizationToken(); + + String decoded = new String(Base64.getDecoder().decode(data.getAuthorizationToken())); + assertTrue(decoded.startsWith("AWS:"), "decoded token should start with AWS: but was: " + decoded); + assertEquals("http://localhost:4566", data.getProxyEndpoint()); + assertNotNull(data.getExpiresAt()); + verify(registryManager, never()).tryEnsureStarted(); + } + // ------------------------------------------------------------ // DescribeRepositories // ------------------------------------------------------------ @@ -567,7 +575,7 @@ class EcrServiceTest { assertNotNull(data.getExpiresAt()); String decoded = new String(Base64.getDecoder().decode(data.getAuthorizationToken())); assertTrue(decoded.startsWith("AWS:"), "decoded token should start with AWS: but was: " + decoded); - Mockito.verify(registryManager).tryEnsureStarted(); + verify(registryManager, never()).tryEnsureStarted(); } @Test