chore(lambda): bound the warm pool to 128 idle containers by default (#9173)

This commit is contained in:
Hector Ventura authored and GitHub committed 2026-11-22 00:47:29 -04:00
1 parent c4238de1c1
commit b3374d073a
8 files changed
+63 -19

No files matched your search

@@ -246,4 +246,22 @@ class ApplicationDefaultsTest {
assertEquals("0", EmulatorConfig.DockerConfig.class.getMethod("maxConcurrentLaunches")
.getAnnotation(WithDefault.class).value(), "the @WithDefault must match application.yml");
}
// Catches: warm-pool-max-total shipped unbounded again, so a stack of many functions keeps one
// warm container per function touched, or a yml value that disagrees with the @WithDefault.
@Test
void productionConfigBoundsTheLambdaWarmPoolTotalByDefault() throws IOException, NoSuchMethodException {
JsonNode maxTotal = productionConfig()
.path("floci").path("services").path("lambda").path("warm-pool-max-total");
assertFalse(maxTotal.isMissingNode(), "warm-pool-max-total should be declared in application.yml");
assertEquals(128, maxTotal.asInt());
WithDefault fallback = EmulatorConfig.LambdaServiceConfig.class
.getMethod("warmPoolMaxTotal")
.getAnnotation(WithDefault.class);
assertNotNull(fallback, "warmPoolMaxTotal should declare a fallback default");
assertEquals("128", fallback.value(),
"the @WithDefault must match application.yml, which wins over it");
}
}
@@ -1,5 +1,6 @@
package io.floci.aws.services.lambda;
import com.fasterxml.jackson.core.type.TypeReference;
import io.floci.aws.config.EmulatorConfig;
import io.floci.aws.core.common.AwsArnUtils;
import io.floci.aws.core.common.AwsException;
@@ -438,6 +439,24 @@ class ProvisionedConcurrencyPoolTest {
assertEquals(1, first.stops.get());
}
// Catches: the idle warm-pool total (128 by default) capping provisioned concurrency again, which
// AWS bounds only by reserved and regional concurrency.
@Test
@SuppressWarnings("unchecked")
void theWarmPoolTotalDoesNotBoundProvisionedConcurrency() {
EmulatorConfig config = mock(EmulatorConfig.class, RETURNS_DEEP_STUBS);
when(config.services().lambda().warmPoolMaxTotal()).thenReturn(1);
when(config.services().lambda().warmPoolMaxPerFunction()).thenReturn(Optional.of(4));
when(config.services().lambda().containerDrainTimeoutSeconds()).thenReturn(15);
StorageFactory storageFactory = mock(StorageFactory.class);
when(storageFactory.create(eq("lambda"), eq("lambda-provisioned-concurrency.json"), any(TypeReference.class)))
.thenReturn(storage);
pool.shutdown();
pool = new ProvisionedConcurrencyPool(launcher, functions, aliases, storageFactory, config, Clock.systemUTC());
assertEquals(2, put(2).requested());
}
@ParameterizedTest
@CsvSource({"1,0,false", "4,1,false", "4,1,true"})
void retiredLeasesStillCountAgainstContainerCeilings(int perFunction, int total,