mirror of
https://github.com/floci-io/floci.git
synced 2026-12-02 09:47:56 -05:00
fix(docker): preserve explicitly configured DNS resolvers (#5727)
* fix(docker): preserve explicitly configured DNS resolvers Honor explicit --dns entries before injecting the embedded resolver and public fallbacks. Keep automatic DNS for containers without configured resolvers, and verify the shared builder and Lambda launcher preserve the requested list. Signed-off-by: Andre Kurait <akurait@amazon.com> * fix(lambda): keep AWS endpoints reachable with explicit DNS Signed-off-by: Andre Kurait <akurait@amazon.com> --------- Signed-off-by: Andre Kurait <akurait@amazon.com>
This commit is contained in:
1 parent
84e5bed623
commit
f1e00eff5c
9 files changed
+73
-8
No files matched your search
@@ -642,13 +642,17 @@ public class ContainerBuilder {
|
||||
/**
|
||||
* Injects Floci's embedded DNS server into the container so virtual-hosted
|
||||
* S3 hostnames (my-bucket.localhost.floci.io) resolve to Floci's Docker
|
||||
* network IP. No-op when the embedded DNS server is not running.
|
||||
* network IP. No-op when explicit resolvers were already supplied or the embedded
|
||||
* DNS server is not running.
|
||||
*
|
||||
* <p>When {@code floci.dns.container-fallback-enabled} is set, the configured public
|
||||
* fallback resolvers are appended after Floci's IP so the container's own resolver can
|
||||
* fall through for public hostnames if Floci's embedded forwarder cannot answer.
|
||||
*/
|
||||
public Builder withEmbeddedDns() {
|
||||
if (!dnsServers.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
embeddedDnsServer.getServerIp().ifPresent(flociIp -> {
|
||||
dnsServers.add(flociIp);
|
||||
if (config.dns().containerFallbackEnabled()) {
|
||||
|
||||
+6
-1
@@ -57,7 +57,12 @@ public class ContainerReachableEndpoint {
|
||||
* listener is {@code TlsProxyServer} on {@code floci.port}.
|
||||
*/
|
||||
public String baseUrl() {
|
||||
String flociHostname = embeddedDnsServer.getServerIp().isPresent()
|
||||
return baseUrl(true);
|
||||
}
|
||||
|
||||
/** Uses the Docker host when the container does not receive Floci's DNS resolver. */
|
||||
public String baseUrl(boolean useEmbeddedDns) {
|
||||
String flociHostname = useEmbeddedDns && embeddedDnsServer.getServerIp().isPresent()
|
||||
? config.hostname().orElse(EmbeddedDnsServer.DEFAULT_SUFFIX)
|
||||
: dockerHostResolver.resolve();
|
||||
return "http://" + flociHostname + ":" + port();
|
||||
|
||||
+6
-1
@@ -69,7 +69,12 @@ public class LaunchedContainerAwsEnv {
|
||||
* the container reaches Floci.
|
||||
*/
|
||||
public String flociEndpoint() {
|
||||
return reachableEndpoint.baseUrl();
|
||||
return flociEndpoint(true);
|
||||
}
|
||||
|
||||
/** Selects an endpoint compatible with the container's DNS configuration. */
|
||||
public String flociEndpoint(boolean useEmbeddedDns) {
|
||||
return reachableEndpoint.baseUrl(useEmbeddedDns);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -217,6 +217,7 @@ public class ContainerLauncher implements LambdaRuntimeLauncher {
|
||||
String cwLogStream = LOG_STREAM_DATE_FMT.format(LocalDate.now()) + "/[$LATEST]" + shortId;
|
||||
String lambdaRegion = extractRegionFromArn(fn.getFunctionArn(), config.defaultRegion());
|
||||
String lambdaAccountId = AwsArnUtils.accountOrDefault(fn.getFunctionArn(), config.defaultAccountId());
|
||||
LambdaDockerFlags dockerFlags = configuredDockerFlags();
|
||||
|
||||
// Build env vars
|
||||
List<String> env = new ArrayList<>();
|
||||
@@ -239,7 +240,7 @@ public class ContainerLauncher implements LambdaRuntimeLauncher {
|
||||
}
|
||||
env.addAll(awsEnv.sdkBaselineEnv(lambdaRegion,
|
||||
awsConfigPath.isPresent() ? Optional.of("/opt/aws-config") : Optional.empty(),
|
||||
roleCredentials, lambdaAccountId));
|
||||
awsEnv.flociEndpoint(dockerFlags.dnsServers().isEmpty()), roleCredentials, lambdaAccountId));
|
||||
if (fn.getEnvironment() != null) {
|
||||
boolean hasExecutionRoleCredentials = roleCredentials.isPresent();
|
||||
boolean userDefinesFullCredentialTriad = definesFullCredentialTriad(fn.getEnvironment());
|
||||
@@ -273,7 +274,6 @@ public class ContainerLauncher implements LambdaRuntimeLauncher {
|
||||
.withLabels(ContainerStorageHelper.resourceIdentityLabels(
|
||||
"lambda", fn.getFunctionName(), lambdaAccountId, lambdaRegion));
|
||||
|
||||
LambdaDockerFlags dockerFlags = configuredDockerFlags();
|
||||
applyDockerFlags(specBuilder, dockerFlags);
|
||||
|
||||
specBuilder.withEmbeddedDns();
|
||||
|
||||
Reference in new issue
Block a user