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
This commit is contained in:
Michal Schreiber authored and GitHub committed 2026-09-30 21:53:52 -05:00
1 parent a66e2a131d
commit 231655b70a
2 files changed
+17 -7

No files matched your search

@@ -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);
@@ -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