mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(ssm): run direct executions on virtual threads (#4689)
* fix(ssm): bound direct-execution threads for SendCommand Each SendCommand target backed by a Floci EC2 container ran on a cached thread pool, so a command with many targets started one thread per target, each held for the whole container exec (up to TimeoutSeconds). Use a fixed pool of max(4, availableProcessors) daemon threads instead; extra targets wait in the executor queue and still complete. * fix(ssm): run direct executions on virtual threads * fix(ssm): keep a cancelled invocation cancelled when its exec finishes
This commit is contained in:
1 parent
6ca104042b
commit
6df2a6cfc2
2 files changed
+141
-5
No files matched your search
@@ -73,11 +73,10 @@ public class SsmCommandService implements Resettable {
|
||||
this.objectMapper = objectMapper;
|
||||
this.regionResolver = regionResolver;
|
||||
this.directCommandExecutor = directCommandExecutor;
|
||||
this.directExecutionExecutor = Executors.newCachedThreadPool(runnable -> {
|
||||
Thread thread = new Thread(runnable, "floci-ssm-direct-execution");
|
||||
thread.setDaemon(true);
|
||||
return thread;
|
||||
});
|
||||
// Each direct execution blocks for the whole container exec, up to TimeoutSeconds, so every
|
||||
// target gets its own virtual thread instead of a platform thread.
|
||||
this.directExecutionExecutor = Executors.newThreadPerTaskExecutor(
|
||||
Thread.ofVirtual().name("floci-ssm-direct-execution").factory());
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
@@ -566,6 +565,9 @@ public class SsmCommandService implements Resettable {
|
||||
.orElse(null);
|
||||
if (result == null) {
|
||||
synchronized (invocation) {
|
||||
if (!"InProgress".equals(invocation.getStatus())) {
|
||||
return;
|
||||
}
|
||||
invocation.setStatus("Pending");
|
||||
invocation.setStatusDetails(statusDetails("Pending"));
|
||||
invocationStore.put(invKey, invocation);
|
||||
@@ -575,6 +577,9 @@ public class SsmCommandService implements Resettable {
|
||||
return;
|
||||
}
|
||||
synchronized (invocation) {
|
||||
if (!"InProgress".equals(invocation.getStatus())) {
|
||||
return;
|
||||
}
|
||||
applyDirectResult(invocation, result);
|
||||
invocationStore.put(invKey, invocation);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user