fix(docker): isolate managed resource containers (#1703)

* fix(docker): namespace managed resource containers

* fix(rds): avoid containerized host path creation

* fix(docker): isolate child container names

* fix(opensearch): preserve legacy domain container names
This commit is contained in:
Jason van Zyl authored and GitHub committed 2026-07-06 21:01:26 -05:00
1 parent ab32758cfe
commit 073e653d35
27 files changed
+330 -43

No files matched your search

@@ -1476,6 +1476,12 @@ public interface EmulatorConfig {
@WithDefault("unix:///var/run/docker.sock")
String dockerHost();
/**
* Optional namespace inserted into Floci-managed child container and volume names.
* Useful when multiple Floci processes share one Docker daemon.
*/
Optional<String> resourceNamespace();
/**
* Optional registry/repository base for every Docker image Floci launches.
* When set, images such as {@code postgres:16-alpine} and
@@ -30,7 +30,52 @@ public final class ContainerStorageHelper {
* this change.
*/
public static String resourceName(String service, String volumeId, String fallbackId) {
return "floci-" + service + "-" + (volumeId != null ? volumeId : fallbackId);
return resourceName(null, service, volumeId, fallbackId);
}
public static String resourceName(EmulatorConfig config, String service, String volumeId, String fallbackId) {
return dockerName(config, "floci-" + service + "-" + (volumeId != null ? volumeId : fallbackId));
}
public static String dockerName(EmulatorConfig config, String baseName) {
String namespace = resourceNamespace(config);
if (namespace.isBlank()) {
return baseName;
}
if (baseName.startsWith("floci-")) {
return "floci-" + namespace + "-" + baseName.substring("floci-".length());
}
return "floci-" + namespace + "-" + baseName;
}
public static Path hostResourcePath(EmulatorConfig config, String service, String resourceId) {
String namespace = resourceNamespace(config);
Path base = Path.of(config.storage().hostPersistentPath());
if (namespace.isBlank()) {
return base.resolve(service).resolve(resourceId);
}
return base.resolve(namespace).resolve(service).resolve(resourceId);
}
private static String resourceNamespace(EmulatorConfig config) {
if (config == null || config.docker() == null || config.docker().resourceNamespace() == null) {
return "";
}
return sanitizeNamePart(config.docker().resourceNamespace().orElse(""));
}
private static String sanitizeNamePart(String value) {
String cleaned = value.trim().replaceAll("[^A-Za-z0-9_.-]+", "-");
while (cleaned.startsWith("-")) {
cleaned = cleaned.substring(1);
}
while (cleaned.endsWith("-")) {
cleaned = cleaned.substring(0, cleaned.length() - 1);
}
if (cleaned.equals(".") || cleaned.equals("..")) {
return "";
}
return cleaned;
}
/**
@@ -51,11 +96,12 @@ public final class ContainerStorageHelper {
public static void applyStorage(
ContainerBuilder.Builder builder,
ContainerLifecycleManager lifecycleManager,
EmulatorConfig config,
String service,
String volumeId,
String fallbackId,
String internalMount) {
String volumeName = resourceName(service, volumeId, fallbackId);
String volumeName = resourceName(config, service, volumeId, fallbackId);
lifecycleManager.ensureVolume(volumeName);
builder.withNamedVolume(volumeName, internalMount);
}
@@ -74,7 +120,7 @@ public final class ContainerStorageHelper {
String service,
String volumeId,
String fallbackId) {
String volumeName = resourceName(service, volumeId, fallbackId);
String volumeName = resourceName(config, service, volumeId, fallbackId);
boolean isMemory = "memory".equals(config.storage().mode());
if (isMemory || config.storage().pruneVolumesOnDelete()) {
lifecycleManager.removeVolume(volumeName);
@@ -20,7 +20,6 @@ import org.jboss.logging.Logger;
import java.io.Closeable;
import java.net.HttpURLConnection;
import java.net.URI;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -111,13 +110,15 @@ public class RabbitMqManager {
}
if (ContainerStorageHelper.isNamedVolumeMode(config)) {
ContainerStorageHelper.applyStorage(specBuilder, lifecycleManager,
ContainerStorageHelper.applyStorage(specBuilder, lifecycleManager, config,
"amazonmq", broker.getVolumeId(), broker.getBrokerId(),
"/var/lib/rabbitmq");
} else {
String hostDataPath = Path.of(config.storage().hostPersistentPath(), "amazonmq", broker.getBrokerId())
String hostDataPath = ContainerStorageHelper.hostResourcePath(config, "amazonmq", broker.getBrokerId())
.toAbsolutePath().toString();
ContainerStorageHelper.ensureHostDir(hostDataPath);
if (!containerDetector.isRunningInContainer()) {
ContainerStorageHelper.ensureHostDir(hostDataPath);
}
specBuilder.withBind(hostDataPath, "/var/lib/rabbitmq");
}
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.core.common.docker.ContainerDetector;
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager;
import io.github.hectorvent.floci.core.common.docker.ContainerLogStreamer;
import io.github.hectorvent.floci.core.common.docker.ContainerSpec;
import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper;
import io.github.hectorvent.floci.services.batch.model.BatchJob;
import io.github.hectorvent.floci.services.batch.model.BatchKeyValue;
import io.github.hectorvent.floci.services.batch.model.BatchResourceRequirement;
@@ -51,7 +52,7 @@ public class BatchDockerRunner {
long startedAt = System.currentTimeMillis();
String logStreamName = logStreamer.generateLogStreamName(
job.getJobDefinitionName() + "/default/" + job.getJobId());
String containerName = "floci-batch-" + job.getJobId() + "-" + attemptNumber;
String containerName = ContainerStorageHelper.dockerName(config, "floci-batch-" + job.getJobId() + "-" + attemptNumber);
Closeable logHandle = null;
String containerId = null;
@@ -10,6 +10,7 @@ import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.C
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.EndpointInfo;
import io.github.hectorvent.floci.core.common.docker.ContainerLogStreamer;
import io.github.hectorvent.floci.core.common.docker.ContainerSpec;
import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
@@ -58,7 +59,7 @@ public class DocDbContainerManager {
public DocDbContainerHandle start(String clusterId, String image, String masterUsername, String masterPassword) {
LOG.infov("Starting DocumentDB container for cluster: {0}", clusterId);
String containerName = "floci-docdb-" + clusterId;
String containerName = ContainerStorageHelper.resourceName(config, "docdb", null, clusterId);
lifecycleManager.removeIfExists(containerName);
List<String> envVars = List.of(
@@ -6,6 +6,7 @@ import io.github.hectorvent.floci.core.common.docker.ContainerDetector;
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager;
import io.github.hectorvent.floci.core.common.docker.ContainerLogStreamer;
import io.github.hectorvent.floci.core.common.docker.ContainerSpec;
import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper;
import io.github.hectorvent.floci.core.common.docker.DockerHostResolver;
import io.github.hectorvent.floci.core.common.docker.PortAllocator;
import io.github.hectorvent.floci.services.ec2.model.Instance;
@@ -123,7 +124,7 @@ public class Ec2ContainerManager {
executor.submit(() -> {
try {
String instanceId = instance.getInstanceId();
String containerName = "floci-ec2-" + instanceId;
String containerName = ContainerStorageHelper.resourceName(config, "ec2", null, instanceId);
// Allocate SSH host port
int sshHostPort = portAllocator.allocate(
@@ -112,8 +112,7 @@ public class EcrRegistryManager {
/** Returns a {@link RegistryHttpClient} bound to the current registry endpoint. */
public RegistryHttpClient httpClient() {
if (containerDetector.isRunningInContainer()) {
return new RegistryHttpClient("http://" + config.services().ecr().registryContainerName()
+ ":" + CONTAINER_INTERNAL_PORT);
return new RegistryHttpClient("http://" + registryContainerName() + ":" + CONTAINER_INTERNAL_PORT);
}
return new RegistryHttpClient("http://localhost:" + effectivePort());
}
@@ -135,7 +134,7 @@ public class EcrRegistryManager {
if (started) {
return;
}
String name = config.services().ecr().registryContainerName();
String name = registryContainerName();
// Check for existing container to adopt
var existing = lifecycleManager.findByName(name);
@@ -192,10 +191,15 @@ public class EcrRegistryManager {
runReconcileOnce();
}
private String registryContainerName() {
return ContainerStorageHelper.dockerName(config, config.services().ecr().registryContainerName());
}
private void addPersistenceMounts(ContainerBuilder.Builder specBuilder, List<String> env) {
if (ContainerStorageHelper.isNamedVolumeMode(config)) {
lifecycleManager.ensureVolume(NAMED_VOLUME);
specBuilder.withNamedVolume(NAMED_VOLUME, "/var/lib/registry");
String volumeName = ContainerStorageHelper.dockerName(config, NAMED_VOLUME);
lifecycleManager.ensureVolume(volumeName);
specBuilder.withNamedVolume(volumeName, "/var/lib/registry");
return;
}
@@ -8,6 +8,7 @@ import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager;
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.ContainerInfo;
import io.github.hectorvent.floci.core.common.docker.ContainerLogStreamer;
import io.github.hectorvent.floci.core.common.docker.ContainerSpec;
import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper;
import io.github.hectorvent.floci.services.ecs.model.Container;
import io.github.hectorvent.floci.services.ecs.model.ContainerDefinition;
import io.github.hectorvent.floci.services.ecs.model.ContainerOverride;
@@ -94,7 +95,7 @@ public class EcsContainerManager {
}
for (ContainerDefinition def : taskDef.getContainerDefinitions()) {
String containerName = "floci-ecs-" + taskId + "-" + def.getName();
String containerName = ContainerStorageHelper.dockerName(config, "floci-ecs-" + taskId + "-" + def.getName());
// RunTask containerOverrides matched by container name: command replaces
// the task-def command; environment is merged over the task-def environment.
@@ -6,6 +6,7 @@ import io.github.hectorvent.floci.core.common.docker.ContainerDetector;
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager;
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.ContainerInfo;
import io.github.hectorvent.floci.core.common.docker.ContainerSpec;
import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper;
import io.github.hectorvent.floci.core.common.docker.DockerHostResolver;
import io.github.hectorvent.floci.core.common.docker.PortAllocator;
import io.github.hectorvent.floci.services.eks.model.CertificateAuthority;
@@ -72,7 +73,7 @@ public class EksClusterManager {
*/
public void startCluster(Cluster cluster) {
String image = config.services().eks().defaultImage();
String containerName = "floci-eks-" + cluster.getName();
String containerName = ContainerStorageHelper.resourceName(config, "eks", null, cluster.getName());
LOG.infov("Starting k3s container for EKS cluster: {0} using image {1}",
cluster.getName(), image);
@@ -96,7 +97,7 @@ public class EksClusterManager {
// socket (kine.sock) on macOS APFS, which returns EINVAL on chmod — crashing
// k3s before it can start. Named volumes live in the Docker VM's Linux
// filesystem, so chmod works correctly and data persists across container restarts.
String volumeName = "floci-eks-" + cluster.getName();
String volumeName = ContainerStorageHelper.resourceName(config, "eks", null, cluster.getName());
List<String> serverArgs = new ArrayList<>(List.of("server",
"--disable=traefik",
@@ -230,7 +231,7 @@ public class EksClusterManager {
return;
}
lifecycleManager.stopAndRemove(cluster.getContainerId(), null);
lifecycleManager.removeVolume("floci-eks-" + cluster.getName());
lifecycleManager.removeVolume(ContainerStorageHelper.resourceName(config, "eks", null, cluster.getName()));
LOG.infov("Stopped k3s container for cluster {0}", cluster.getName());
}
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.C
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.EndpointInfo;
import io.github.hectorvent.floci.core.common.docker.ContainerLogStreamer;
import io.github.hectorvent.floci.core.common.docker.ContainerSpec;
import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
@@ -71,7 +72,7 @@ public class ElastiCacheContainerManager {
public ElastiCacheContainerHandle start(String groupId, String image) {
LOG.infov("Starting ElastiCache backend container for group: {0}", groupId);
String containerName = "floci-valkey-" + groupId;
String containerName = ContainerStorageHelper.resourceName(config, "valkey", null, groupId);
// Remove any stale container with the same name
lifecycleManager.removeIfExists(containerName);
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.C
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.EndpointInfo;
import io.github.hectorvent.floci.core.common.docker.ContainerLogStreamer;
import io.github.hectorvent.floci.core.common.docker.ContainerSpec;
import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
@@ -67,7 +68,7 @@ public class ElastiCacheMemcachedContainerManager {
public ElastiCacheContainerHandle start(String clusterId, String image) {
LOG.infov("Starting Memcached container for cluster: {0}", clusterId);
String containerName = "floci-memcached-" + clusterId;
String containerName = ContainerStorageHelper.resourceName(config, "memcached", null, clusterId);
lifecycleManager.removeIfExists(containerName);
ContainerBuilder.Builder specBuilder = containerBuilder.newContainer(image)
@@ -7,6 +7,7 @@ import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager;
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.ContainerInfo;
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.EndpointInfo;
import io.github.hectorvent.floci.core.common.docker.ContainerSpec;
import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper;
import io.quarkus.runtime.ShutdownEvent;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
@@ -110,14 +111,15 @@ public class FlociDuckManager {
String image = config.services().duck().defaultImage();
LOG.infov("Starting floci-duck container using image {0}", image);
lifecycleManager.removeIfExists(CONTAINER_NAME);
String containerName = ContainerStorageHelper.dockerName(config, CONTAINER_NAME);
lifecycleManager.removeIfExists(containerName);
ContainerSpec spec = containerBuilder.newContainer(image)
.withName(CONTAINER_NAME)
.withName(containerName)
.withEnv("FLOCI_DUCK_S3_ACCESS_KEY", "test")
.withEnv("FLOCI_DUCK_S3_SECRET_KEY", "test")
.withEnv("FLOCI_DUCK_S3_REGION", config.defaultRegion())
.withPortBinding(DUCK_PORT, DUCK_PORT)
.withDynamicPort(DUCK_PORT)
.withDockerNetwork(config.services().dockerNetwork())
.withEmbeddedDns()
.withLogRotation()
@@ -19,6 +19,7 @@ import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.C
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.EndpointInfo;
import io.github.hectorvent.floci.core.common.docker.ContainerLogStreamer;
import io.github.hectorvent.floci.core.common.docker.ContainerSpec;
import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper;
import io.github.hectorvent.floci.core.common.docker.CurrentContainerNetworkResolver;
import io.github.hectorvent.floci.core.common.docker.DockerHostResolver;
import com.github.dockerjava.api.exception.DockerClientException;
@@ -111,7 +112,7 @@ public class FlociUiManager {
// Clear any error from a prior failed attempt so status() reports this retry
// as in-progress rather than surfacing the stale failure.
this.lastError = null;
String name = config.services().ui().containerName();
String name = ContainerStorageHelper.dockerName(config, config.services().ui().containerName());
Optional<Container> existing = lifecycleManager.findByName(name);
if (existing.isPresent()) {
@@ -6,6 +6,7 @@ import io.github.hectorvent.floci.core.common.docker.ContainerReachableEndpoint;
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager;
import io.github.hectorvent.floci.core.common.docker.ContainerLogStreamer;
import io.github.hectorvent.floci.core.common.docker.ContainerSpec;
import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper;
import io.github.hectorvent.floci.core.common.docker.DockerHostResolver;
import io.github.hectorvent.floci.services.ecr.registry.EcrRegistryManager;
import io.github.hectorvent.floci.services.lambda.LambdaLayerService;
@@ -169,7 +170,7 @@ public class ContainerLauncher {
// Give the container a human-readable name (needed for log stream name below)
String shortId = java.util.UUID.randomUUID().toString().replace("-", "").substring(0, 8);
String containerName = "floci-" + fn.getFunctionName() + "-" + shortId;
String containerName = ContainerStorageHelper.dockerName(config, "floci-" + fn.getFunctionName() + "-" + shortId);
// CloudWatch log coordinates — computed here so they can be injected as env vars
String cwLogGroup = "/aws/lambda/" + fn.getFunctionName();
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.C
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.EndpointInfo;
import io.github.hectorvent.floci.core.common.docker.ContainerLogStreamer;
import io.github.hectorvent.floci.core.common.docker.ContainerSpec;
import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import org.jboss.logging.Logger;
@@ -67,7 +68,7 @@ public class MemoryDbContainerManager {
public MemoryDbContainerHandle start(String clusterName, String image) {
LOG.infov("Starting MemoryDB backend container for cluster: {0}", clusterName);
String containerName = "floci-memorydb-" + clusterName;
String containerName = ContainerStorageHelper.resourceName(config, "memorydb", null, clusterName);
lifecycleManager.removeIfExists(containerName);
@@ -65,7 +65,7 @@ public class RedpandaManager {
String image = config.services().msk().defaultImage();
LOG.infov("Starting Redpanda container for MSK cluster: {0} using image {1}", cluster.getClusterName(), image);
String containerName = "floci-msk-" + cluster.getClusterName();
String containerName = ContainerStorageHelper.resourceName(config, "msk", cluster.getVolumeId(), cluster.getClusterName());
// Cleanup stale container
lifecycleManager.removeIfExists(containerName);
@@ -113,14 +113,16 @@ public class RedpandaManager {
// Handle persistence mounting
if (ContainerStorageHelper.isNamedVolumeMode(config)) {
ContainerStorageHelper.applyStorage(specBuilder, lifecycleManager,
ContainerStorageHelper.applyStorage(specBuilder, lifecycleManager, config,
"msk", cluster.getVolumeId(), cluster.getClusterName(),
"/var/lib/redpanda/data");
} else {
// Legacy host-path mode: host-persistent-path is an absolute path
String hostDataPath = Path.of(config.storage().hostPersistentPath(), "msk", cluster.getClusterName())
String hostDataPath = ContainerStorageHelper.hostResourcePath(config, "msk", cluster.getClusterName())
.toAbsolutePath().toString();
ContainerStorageHelper.ensureHostDir(hostDataPath);
if (!containerDetector.isRunningInContainer()) {
ContainerStorageHelper.ensureHostDir(hostDataPath);
}
specBuilder.withBind(hostDataPath, "/var/lib/redpanda/data");
}
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.C
import io.github.hectorvent.floci.core.common.docker.ContainerLifecycleManager.EndpointInfo;
import io.github.hectorvent.floci.core.common.docker.ContainerLogStreamer;
import io.github.hectorvent.floci.core.common.docker.ContainerSpec;
import io.github.hectorvent.floci.core.common.docker.ContainerStorageHelper;
import io.github.hectorvent.floci.services.neptune.model.NeptuneDbType;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
@@ -65,7 +66,7 @@ public class NeptuneContainerManager {
LOG.infov("Starting Neptune backend container ({0}) for cluster: {1}", dbType, clusterId);
int backendPort = dbType.backendPort();
String containerName = "floci-neptune-" + clusterId;
String containerName = ContainerStorageHelper.resourceName(config, "neptune", null, clusterId);
lifecycleManager.removeIfExists(containerName);
ContainerBuilder.Builder specBuilder = containerBuilder.newContainer(image)
@@ -48,7 +48,7 @@ public class OpenSearchDomainManager {
public void startDomain(Domain domain) {
String image = resolveImage(domain.getEngineVersion());
String containerName = "floci-opensearch-" + domain.getDomainName();
String containerName = containerName(domain);
LOG.infov("Starting OpenSearch container for domain: {0} (version={1}, image={2})",
domain.getDomainName(), domain.getEngineVersion(), image);
@@ -69,13 +69,15 @@ public class OpenSearchDomainManager {
applyEngineEnv(specBuilder, domain.getEngineVersion());
if (ContainerStorageHelper.isNamedVolumeMode(config)) {
ContainerStorageHelper.applyStorage(specBuilder, lifecycleManager,
ContainerStorageHelper.applyStorage(specBuilder, lifecycleManager, config,
"opensearch", domain.getVolumeId(), domain.getDomainName(),
"/usr/share/opensearch/data");
} else {
// Legacy host-path mode: host-persistent-path is an absolute path
Path dataPath = Path.of(config.services().opensearch().dataPath(), domain.getDomainName());
ContainerStorageHelper.ensureHostDir(dataPath.toString());
Path dataPath = ContainerStorageHelper.hostResourcePath(config, "opensearch", domain.getDomainName());
if (!containerDetector.isRunningInContainer()) {
ContainerStorageHelper.ensureHostDir(dataPath.toString());
}
String dataPathStr = dataPath.toAbsolutePath().normalize().toString();
String persistentPathStr = Path.of(config.storage().persistentPath()).toAbsolutePath().normalize().toString();
String hostDataPath = dataPathStr.replace(persistentPathStr, config.storage().hostPersistentPath());
@@ -98,7 +100,7 @@ public class OpenSearchDomainManager {
}
public boolean isReady(Domain domain) {
String containerName = "floci-opensearch-" + domain.getDomainName();
String containerName = containerName(domain);
String url = "http://" + containerName + ":" + OPENSEARCH_PORT + "/_cluster/health";
try {
HttpURLConnection conn = (HttpURLConnection) URI.create(url).toURL().openConnection();
@@ -142,6 +144,10 @@ public class OpenSearchDomainManager {
config.services().opensearch().defaultImage(), engineVersion);
}
private String containerName(Domain domain) {
return ContainerStorageHelper.resourceName(config, "opensearch", null, domain.getDomainName());
}
/**
* Engine env that differs between OpenSearch lines and Elasticsearch. Both
* the security-plugin disable flag and the v2.12+ initial admin password
@@ -1231,7 +1231,7 @@ public class RdsService implements Resettable {
}
private String volumeName(String volumeId, String fallbackId) {
return ContainerStorageHelper.resourceName("rds", volumeId, fallbackId);
return ContainerStorageHelper.resourceName(config, "rds", volumeId, fallbackId);
}
private RdsContainerHandle buildHandle(DbInstance instance) {
@@ -71,7 +71,7 @@ public class RdsContainerManager {
LOG.infov("Starting RDS backend container for instance: {0} engine={1}", instanceId, engine);
int enginePort = engine.defaultPort();
String containerName = "floci-rds-" + instanceId;
String containerName = ContainerStorageHelper.resourceName(config, "rds", volumeId, instanceId);
// Remove any stale container with the same name
lifecycleManager.removeIfExists(containerName);
@@ -153,14 +153,16 @@ public class RdsContainerManager {
String volumeId, DatabaseEngine engine, String image) {
if (ContainerStorageHelper.isNamedVolumeMode(config)) {
ContainerStorageHelper.applyStorage(
specBuilder, lifecycleManager, "rds", volumeId, instanceId,
specBuilder, lifecycleManager, config, "rds", volumeId, instanceId,
engineDefaultDataPath(engine, image));
return;
}
// Legacy host-path mode: host-persistent-path is an absolute path
String hostDataPath = Path.of(config.storage().hostPersistentPath(), "rds", instanceId).toString();
ContainerStorageHelper.ensureHostDir(hostDataPath);
String hostDataPath = ContainerStorageHelper.hostResourcePath(config, "rds", instanceId).toString();
if (!containerDetector.isRunningInContainer()) {
ContainerStorageHelper.ensureHostDir(hostDataPath);
}
specBuilder.withBind(hostDataPath, engineDefaultDataPath(engine, image));
}