mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
refactor(redshift): deduplicate RedshiftContainerManager startup and adoption sequence (#3679)
* refactor(redshift): deduplicate RedshiftContainerManager startup and adoption sequence Extract the shared post-acquisition initialization and registration sequence into a private helper method used by both start() and adoptOrStart(). Add unit test coverage verifying log streamer attachment and failure tolerance across both container startup paths. Closes #3653 * test(redshift): use static Mockito answer import
This commit is contained in:
1 parent
144b90e6fa
commit
631d98be64
2 files changed
+69
-18
No files matched your search
+18
-18
@@ -87,22 +87,7 @@ public class RedshiftContainerManager {
|
||||
|
||||
ContainerSpec spec = specBuilder.build();
|
||||
ContainerInfo info = lifecycleManager.createAndStart(spec);
|
||||
EndpointInfo endpoint = info.getEndpoint(enginePort);
|
||||
|
||||
RedshiftContainerHandle handle = new RedshiftContainerHandle(
|
||||
info.containerId(), clusterIdentifier, endpoint.host(), endpoint.port());
|
||||
|
||||
try {
|
||||
Closeable stream = logStreamer.attach(info.containerId(), "/floci/redshift", clusterIdentifier, "us-east-1", "redshift:" + clusterIdentifier);
|
||||
handle.setLogStream(stream);
|
||||
} catch (Exception e) {
|
||||
LOG.warnv("Failed to stream logs for {0}", containerName);
|
||||
}
|
||||
|
||||
waitForReady(containerName, info.containerId(), masterUsername, "dev");
|
||||
|
||||
containers.put(containerKey(accountId, clusterIdentifier), handle);
|
||||
return handle;
|
||||
return initializeAndRegisterHandle(info, accountId, clusterIdentifier, masterUsername, containerName, enginePort);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,12 +113,27 @@ public class RedshiftContainerManager {
|
||||
containerName, clusterIdentifier);
|
||||
int enginePort = 5432;
|
||||
ContainerInfo info = lifecycleManager.adopt(existing.get().getId(), List.of(enginePort));
|
||||
EndpointInfo endpoint = info.getEndpoint(enginePort);
|
||||
return initializeAndRegisterHandle(info, accountId, clusterIdentifier, masterUsername, containerName, enginePort);
|
||||
}
|
||||
|
||||
private RedshiftContainerHandle initializeAndRegisterHandle(
|
||||
ContainerInfo info,
|
||||
String accountId,
|
||||
String clusterIdentifier,
|
||||
String masterUsername,
|
||||
String containerName,
|
||||
int enginePort) {
|
||||
EndpointInfo endpoint = info.getEndpoint(enginePort);
|
||||
RedshiftContainerHandle handle = new RedshiftContainerHandle(
|
||||
info.containerId(), clusterIdentifier, endpoint.host(), endpoint.port());
|
||||
|
||||
try {
|
||||
Closeable stream = logStreamer.attach(info.containerId(), "/floci/redshift", clusterIdentifier, "us-east-1", "redshift:" + clusterIdentifier);
|
||||
Closeable stream = logStreamer.attach(
|
||||
info.containerId(),
|
||||
"/floci/redshift",
|
||||
clusterIdentifier,
|
||||
"us-east-1",
|
||||
"redshift:" + clusterIdentifier);
|
||||
handle.setLogStream(stream);
|
||||
} catch (Exception e) {
|
||||
LOG.warnv("Failed to stream logs for {0}", containerName);
|
||||
|
||||
Reference in new issue
Block a user