mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
fix(cloudformation): key the Lambda hot-reload identity on the Docker host path (#4275)
LambdaCfnProvisioner.canonicalHotReloadPath spelled the identity with Path.normalize().toString() while LambdaService stores the path through toDockerHostPath (#4080), the POSIX form Docker receives whatever separator the JVM uses. lambdaCodeChanged compares the two, so on a Windows-hosted JVM every stack update looked like a code change and re-mounted the same directory. The provisioner now reuses the Lambda helper, made public for it, so the identity and the stored path cannot drift. Follow-up to #4093.
This commit is contained in:
1 parent
96264cde70
commit
69217dff2a
2 files changed
+13
-7
No files matched your search
+7
-5
@@ -407,14 +407,16 @@ public class LambdaCfnProvisioner implements CfnResourceProvisioner {
|
||||
|
||||
/**
|
||||
* The form LambdaService stores a hot-reload host path in: normalized, so {@code /a/../b/}
|
||||
* and {@code /b} are the same mount. Identities and change detection use it so a redeploy
|
||||
* that only rewrites the path spelling, or a function adopted from a direct CreateFunction,
|
||||
* is not mistaken for a code change. The raw key still goes to Lambda, which validates it and
|
||||
* reports its own error for a path it cannot use.
|
||||
* and {@code /b} are the same mount, and rendered as the POSIX path Docker receives
|
||||
* ({@link LambdaService#toDockerHostPath}), so the identity agrees with
|
||||
* {@code getHotReloadHostPath()} on every host separator. Identities and change detection use
|
||||
* it so a redeploy that only rewrites the path spelling, or a function adopted from a direct
|
||||
* CreateFunction, is not mistaken for a code change. The raw key still goes to Lambda, which
|
||||
* validates it and reports its own error for a path it cannot use.
|
||||
*/
|
||||
private static String canonicalHotReloadPath(String s3Key) {
|
||||
try {
|
||||
return Path.of(s3Key).normalize().toString();
|
||||
return LambdaService.toDockerHostPath(Path.of(s3Key).normalize());
|
||||
} catch (InvalidPathException e) {
|
||||
return s3Key;
|
||||
}
|
||||
|
||||
@@ -3011,8 +3011,12 @@ public class LambdaService implements ResourceProvider {
|
||||
LOG.infov("Hot-reload configured for function {0}: bind-mounting {1}", fn.getFunctionName(), resolvedHostPath);
|
||||
}
|
||||
|
||||
/** Docker on the host expects a POSIX path, whatever separator the JVM running Floci uses. */
|
||||
static String toDockerHostPath(Path normalized) {
|
||||
/**
|
||||
* Docker on the host expects a POSIX path, whatever separator the JVM running Floci uses.
|
||||
* Public because the CloudFormation provisioner keys its hot-reload identity on the same form,
|
||||
* so change detection agrees with what {@link #applyHotReload} stored.
|
||||
*/
|
||||
public static String toDockerHostPath(Path normalized) {
|
||||
StringBuilder path = new StringBuilder();
|
||||
for (Path name : normalized) {
|
||||
path.append('/').append(name);
|
||||
|
||||
Reference in new issue
Block a user