mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(codepipeline): guard worker polling intervals (#6274)
This commit is contained in:
1 parent
17c738403c
commit
f6d67461d2
5 files changed
+186
-16
No files matched your search
+15
-11
@@ -126,8 +126,9 @@ public class CodePipelineService {
|
||||
// An execution's status turns Failed as soon as one action fails, while its runner is still waiting
|
||||
// on sibling actions. Retries check this set so they never overlap a runner that has not finished.
|
||||
final Set<String> activeRuns = ConcurrentHashMap.newKeySet();
|
||||
private final long sourcePollIntervalMs;
|
||||
private long workerPollIntervalMs = DEFAULT_WORKER_POLL_INTERVAL_MS;
|
||||
// Package-private so tests can assert the resolved intervals instead of timing schedules and sleeps.
|
||||
final long sourcePollIntervalMs;
|
||||
final long workerPollIntervalMs;
|
||||
// Test hooks, set only through the package-private constructor: a shortened wait, and a probe
|
||||
// for the gap before the override timeout cleanup.
|
||||
private final long runFinishWaitNanos;
|
||||
@@ -149,7 +150,7 @@ public class CodePipelineService {
|
||||
CodeBuildService codeBuildService, CodeDeployService codeDeployService,
|
||||
LambdaService lambdaService, S3Service s3Service) {
|
||||
this(storageFactory, mapper, codeBuildService, codeDeployService, lambdaService, s3Service,
|
||||
detachedEventPublisher(mapper), DEFAULT_SOURCE_POLL_INTERVAL_MS,
|
||||
detachedEventPublisher(mapper), DEFAULT_SOURCE_POLL_INTERVAL_MS, DEFAULT_WORKER_POLL_INTERVAL_MS,
|
||||
DEFAULT_RUN_FINISH_WAIT_NANOS, () -> { });
|
||||
}
|
||||
|
||||
@@ -168,9 +169,9 @@ public class CodePipelineService {
|
||||
EmulatorConfig config, CodePipelineEventPublisher eventPublisher) {
|
||||
this(storageFactory, mapper, codeBuildService, codeDeployService, lambdaService, s3Service,
|
||||
eventPublisher,
|
||||
resolveSourcePollInterval(config.services().codepipeline().sourcePollIntervalMs()),
|
||||
config.services().codepipeline().sourcePollIntervalMs(),
|
||||
config.services().codepipeline().workerPollIntervalMs(),
|
||||
DEFAULT_RUN_FINISH_WAIT_NANOS, () -> { });
|
||||
this.workerPollIntervalMs = config.services().codepipeline().workerPollIntervalMs();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,20 +187,20 @@ public class CodePipelineService {
|
||||
* observer and stop the whole emulator becoming ready. A misconfigured value is not worth
|
||||
* failing every other service for, so it falls back with a warning.
|
||||
*/
|
||||
private static long resolveSourcePollInterval(long configured) {
|
||||
static long resolvePollInterval(String kind, long configured, long fallback) {
|
||||
if (configured > 0) {
|
||||
return configured;
|
||||
}
|
||||
LOG.warnv("Ignoring CodePipeline source poll interval {0}ms: must be a positive number of "
|
||||
+ "milliseconds, falling back to {1}ms", configured, DEFAULT_SOURCE_POLL_INTERVAL_MS);
|
||||
return DEFAULT_SOURCE_POLL_INTERVAL_MS;
|
||||
LOG.warnv("Ignoring CodePipeline {0} poll interval {1}ms: must be a positive number of "
|
||||
+ "milliseconds, falling back to {2}ms", kind, configured, fallback);
|
||||
return fallback;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
CodePipelineService(StorageFactory storageFactory, ObjectMapper mapper,
|
||||
CodeBuildService codeBuildService, CodeDeployService codeDeployService,
|
||||
LambdaService lambdaService, S3Service s3Service,
|
||||
CodePipelineEventPublisher eventPublisher, long sourcePollIntervalMs,
|
||||
CodePipelineEventPublisher eventPublisher, long sourcePollIntervalMs, long workerPollIntervalMs,
|
||||
long runFinishWaitNanos, Runnable beforeOverrideTimeoutCleanup) {
|
||||
this.pipelineStore = storageFactory.create(
|
||||
"codepipeline", "codepipeline-pipelines.json", new TypeReference<Map<String, CodePipelinePipeline>>() {});
|
||||
@@ -213,7 +214,10 @@ public class CodePipelineService {
|
||||
this.lambdaService = lambdaService;
|
||||
this.s3Service = s3Service;
|
||||
this.eventPublisher = eventPublisher;
|
||||
this.sourcePollIntervalMs = sourcePollIntervalMs;
|
||||
this.sourcePollIntervalMs = resolvePollInterval("source", sourcePollIntervalMs,
|
||||
DEFAULT_SOURCE_POLL_INTERVAL_MS);
|
||||
this.workerPollIntervalMs = resolvePollInterval("worker", workerPollIntervalMs,
|
||||
DEFAULT_WORKER_POLL_INTERVAL_MS);
|
||||
this.runFinishWaitNanos = runFinishWaitNanos;
|
||||
this.beforeOverrideTimeoutCleanup = beforeOverrideTimeoutCleanup;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user