mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(elbv2): move persisted-listener restore out of @PostConstruct (#2015)
* fix(elbv2): move persisted-listener restore out of @PostConstruct ElbV2Service called back into itself through its own CDI client proxy while it was still being constructed. rebuildIndexes(), reached from the @PostConstruct initializeStorage(), called dataPlane.startListener() for every restored listener; ElbV2DataPlane.binding() then called elbV2Service.getLoadBalancer(), and because Arc had not yet registered the instance in the ApplicationScoped context the proxy started another bean creation. That recursed until the process died. Only reproducible after a restart with persistent storage: on a fresh boot the listener map is empty, so rebuildIndexes() never reaches startListener and the callback never happens. rebuildIndexes() now only builds the in-memory indexes. Starting the data plane and the health checks moved to restorePersistedRuntime(), invoked from EmulatorLifecycle after storageFactory.loadAll() alongside the four services that already restore persisted runtime there. With the bean fully constructed before any listener starts, the callback resolves normally. The blast radius was wider than the issue title: the bean is created lazily on first use, so after a restart every ELBv2 operation failed, not just DeleteStack. DescribeLoadBalancers and DescribeTargetGroups both returned 500. Note the symptom changed with #1931: the storage dedupe removed the per-level allocation, so current main raises StackOverflowError where 1.5.32 exhausted the heap and was OOM-killed. Closes #1913 * test(elbv2): cover the enabled and disabled lifecycle restore paths elbv2 was stubbed disabled in setup, so nothing exercised the new EmulatorLifecycle call: dropping it entirely would have left the suite green. Pin both halves of the gate — restore runs after loadAll when elbv2 is enabled, and does not run when it is disabled. Verified the ordering assertion fails with 'Wanted but not invoked' when the lifecycle call is removed. Refs #1913
This commit is contained in:
1 parent
836c162136
commit
468e943c83
4 files changed
+108
-8
No files matched your search
@@ -22,6 +22,7 @@ import io.github.hectorvent.floci.services.neptune.container.NeptuneContainerMan
|
||||
import io.github.hectorvent.floci.services.neptune.proxy.NeptuneProxyManager;
|
||||
import io.github.hectorvent.floci.services.pipes.PipesService;
|
||||
import io.github.hectorvent.floci.services.appsync.graphql.SchemaCreationWorker;
|
||||
import io.github.hectorvent.floci.services.elbv2.ElbV2Service;
|
||||
import io.github.hectorvent.floci.services.rds.RdsService;
|
||||
import io.github.hectorvent.floci.services.memorydb.container.MemoryDbContainerManager;
|
||||
import io.github.hectorvent.floci.services.memorydb.proxy.MemoryDbProxyManager;
|
||||
@@ -75,6 +76,7 @@ public class EmulatorLifecycle {
|
||||
private final NeptuneProxyManager neptuneProxyManager;
|
||||
private final RabbitMqManager rabbitMqManager;
|
||||
private final RdsService rdsService;
|
||||
private final ElbV2Service elbV2Service;
|
||||
private final InitializationHooksRunner initializationHooksRunner;
|
||||
private final SqsEventSourcePoller sqsPoller;
|
||||
private final KinesisEventSourcePoller kinesisPoller;
|
||||
@@ -103,6 +105,7 @@ public class EmulatorLifecycle {
|
||||
NeptuneProxyManager neptuneProxyManager,
|
||||
RabbitMqManager rabbitMqManager,
|
||||
RdsService rdsService,
|
||||
ElbV2Service elbV2Service,
|
||||
InitializationHooksRunner initializationHooksRunner,
|
||||
SqsEventSourcePoller sqsPoller,
|
||||
KinesisEventSourcePoller kinesisPoller,
|
||||
@@ -130,6 +133,7 @@ public class EmulatorLifecycle {
|
||||
this.neptuneProxyManager = neptuneProxyManager;
|
||||
this.rabbitMqManager = rabbitMqManager;
|
||||
this.rdsService = rdsService;
|
||||
this.elbV2Service = elbV2Service;
|
||||
this.initializationHooksRunner = initializationHooksRunner;
|
||||
this.sqsPoller = sqsPoller;
|
||||
this.kinesisPoller = kinesisPoller;
|
||||
@@ -173,6 +177,9 @@ public class EmulatorLifecycle {
|
||||
dynamodbStreamsPoller.startPersistedPollers();
|
||||
pipesService.startPersistedPollers();
|
||||
rdsService.restorePersistedRuntime();
|
||||
if (config.services().elbv2().enabled()) {
|
||||
elbV2Service.restorePersistedRuntime();
|
||||
}
|
||||
|
||||
if (config.services().ec2().enabled() && !config.services().ec2().mock()) {
|
||||
ec2MetadataServer.start().exceptionally(ex -> {
|
||||
|
||||
@@ -101,6 +101,13 @@ public class ElbV2Service {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the in-memory indexes from the storage-backed maps. Pure and in-process on purpose:
|
||||
* nothing reachable from {@link #initializeStorage()} may call an injected collaborator, because
|
||||
* {@link ElbV2DataPlane} calls back into this service and CDI has not registered the instance in
|
||||
* the ApplicationScoped context yet — re-entering bean creation instead (issue #1913). Runtime
|
||||
* side effects belong in {@link #restorePersistedRuntime()}.
|
||||
*/
|
||||
private void rebuildIndexes()
|
||||
{
|
||||
lbToListeners.clear();
|
||||
@@ -123,7 +130,20 @@ public class ElbV2Service {
|
||||
for (TargetGroup targetGroup : regionEntry.getValue().values()) {
|
||||
tgToLbs.computeIfAbsent(targetGroup.getTargetGroupArn(), k -> ConcurrentHashMap.newKeySet())
|
||||
.addAll(targetGroup.getLoadBalancerArns());
|
||||
if (healthChecker != null) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Brings the data plane and health checks back up for state restored from disk. Invoked from
|
||||
* {@code EmulatorLifecycle} once the bean is fully constructed, alongside the other services that
|
||||
* restore persisted runtime after {@code storageFactory.loadAll()}.
|
||||
*/
|
||||
public void restorePersistedRuntime()
|
||||
{
|
||||
if (healthChecker != null) {
|
||||
for (Map<String, TargetGroup> regionTargetGroups : targetGroups.values()) {
|
||||
for (TargetGroup targetGroup : regionTargetGroups.values()) {
|
||||
healthChecker.startMonitoring(targetGroup);
|
||||
if (!targetGroup.getTargets().isEmpty()) {
|
||||
healthChecker.addTargets(targetGroup.getTargetGroupArn(), targetGroup.getTargets(), targetGroup);
|
||||
@@ -131,10 +151,10 @@ public class ElbV2Service {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Map<String, Listener>> regionEntry : listeners.entrySet()) {
|
||||
String region = regionEntry.getKey();
|
||||
for (Listener listener : regionEntry.getValue().values()) {
|
||||
if (dataPlane != null) {
|
||||
if (dataPlane != null) {
|
||||
for (Map.Entry<String, Map<String, Listener>> regionEntry : listeners.entrySet()) {
|
||||
String region = regionEntry.getKey();
|
||||
for (Listener listener : regionEntry.getValue().values()) {
|
||||
dataPlane.startListener(listener, region, getListenerRules(region, listener.getListenerArn()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user