From 8377857d6b650c23b6927fcb291d843024442d09 Mon Sep 17 00:00:00 2001 From: Marko Malenic Date: Thu, 28 Mar 2024 13:33:45 +1100 Subject: [PATCH] fix(filemanager): add uuid to target directory to avoid concurrency errors --- lib/workload/stateless/filemanager/Cargo.lock | 14 ++++++++------ .../deploy/constructs/functions/function.ts | 13 ++++++------- .../filemanager/filemanager-http-lambda/Cargo.toml | 4 ++-- .../filemanager-ingest-lambda/Cargo.toml | 4 ++-- .../filemanager-migrate-lambda/Cargo.toml | 4 ++-- .../stateless/filemanager/filemanager/Cargo.toml | 4 ++-- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/workload/stateless/filemanager/Cargo.lock b/lib/workload/stateless/filemanager/Cargo.lock index 2a9cff897..36395ce64 100644 --- a/lib/workload/stateless/filemanager/Cargo.lock +++ b/lib/workload/stateless/filemanager/Cargo.lock @@ -1542,9 +1542,9 @@ dependencies = [ [[package]] name = "lambda_http" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef8fafd7a4ce0bc6093cf1bed3dcdfc1239c27df1e79e3f2154f4d3299d4f60e" +checksum = "be43a66db1ccbea4d9d504379ec71826f3ccc2ed1b08b6def62e0dd0448c4a30" dependencies = [ "aws_lambda_events", "base64", @@ -1569,9 +1569,9 @@ dependencies = [ [[package]] name = "lambda_runtime" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2904c10fbeaf07aa317fc96a0e28e89c80ed12f7949ed06afd7869b21fef32" +checksum = "f287564236fa4d86adf18964d3a2784c1cef5aaf38b3386cee62f995c6aceeac" dependencies = [ "async-stream", "base64", @@ -1584,20 +1584,22 @@ dependencies = [ "hyper 1.2.0", "hyper-util", "lambda_runtime_api_client", + "pin-project", "serde", "serde_json", "serde_path_to_error", "tokio", "tokio-stream", "tower", + "tower-layer", "tracing", ] [[package]] name = "lambda_runtime_api_client" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1364cd67281721d2a9a4444ba555cf4d74a195e647061fa4ccac46e6f5c3b0ae" +checksum = "722b02764422524d3f49a934b570f7c567f811eda1f9c4bdebebcfae1bad4f23" dependencies = [ "bytes", "futures-channel", diff --git a/lib/workload/stateless/filemanager/deploy/constructs/functions/function.ts b/lib/workload/stateless/filemanager/deploy/constructs/functions/function.ts index a1611e4de..cc30930d3 100644 --- a/lib/workload/stateless/filemanager/deploy/constructs/functions/function.ts +++ b/lib/workload/stateless/filemanager/deploy/constructs/functions/function.ts @@ -95,19 +95,18 @@ export class Function extends Construct { `/` + `${props.databaseSecret.secretValueFromJson('dbname').unsafeUnwrap()}`; - const workspacePath = path.join(__dirname, '..', '..', '..'); - const manifestPath = path.join(workspacePath, props.package, 'Cargo.toml'); + const manifestPath = path.join(__dirname, '..', '..', '..'); const uuid = randomUUID(); // This starts the container running postgres in order to compile queries using sqlx. // It needs to be executed outside `beforeBundling`, because `beforeBundling` runs inside // the container context, and docker compose needs to run outside of this context. + print(`running filemanager \`make -s docker-run DOCKER_PROJECT_NAME=${uuid}\``); const output = exec( 'make', ['-s', 'docker-run', `DOCKER_PROJECT_NAME=${uuid}`], - { cwd: workspacePath, shell: true } + { cwd: manifestPath, shell: true } ); - print(`running filemanager \`make -s docker-run DOCKER_PROJECT_NAME=${uuid}\``); // Grab the last line only in case there are other outputs. const address = output.stdout.toString().trim().match('.*$')?.pop(); @@ -120,11 +119,11 @@ export class Function extends Construct { bundling: { environment: { ...props.buildEnvironment, - // Avoid permission issues by creating another target directory. - CARGO_TARGET_DIR: "target-cdk-docker-bundling", + // Avoid concurrency errors by creating another target directory. + CARGO_TARGET_DIR: `target-cdk-bundling-${uuid}`, // The bundling container needs to be able to connect to the container running postgres. DATABASE_URL: localDatabaseUrl, - }, + } }, memorySize: 128, timeout: Duration.seconds(28), diff --git a/lib/workload/stateless/filemanager/filemanager-http-lambda/Cargo.toml b/lib/workload/stateless/filemanager/filemanager-http-lambda/Cargo.toml index 2a54a59c2..405bc04ad 100644 --- a/lib/workload/stateless/filemanager/filemanager-http-lambda/Cargo.toml +++ b/lib/workload/stateless/filemanager/filemanager-http-lambda/Cargo.toml @@ -12,7 +12,7 @@ tokio = { version = "1", features = ["macros"] } tracing = { version = "0.1", features = ["log"] } tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] } -lambda_http = "0.10" -lambda_runtime = "0.10" +lambda_http = "0.11" +lambda_runtime = "0.11" filemanager = { path = "../filemanager" } diff --git a/lib/workload/stateless/filemanager/filemanager-ingest-lambda/Cargo.toml b/lib/workload/stateless/filemanager/filemanager-ingest-lambda/Cargo.toml index 584ce1f14..57840a343 100644 --- a/lib/workload/stateless/filemanager/filemanager-ingest-lambda/Cargo.toml +++ b/lib/workload/stateless/filemanager/filemanager-ingest-lambda/Cargo.toml @@ -13,6 +13,6 @@ tracing = { version = "0.1", features = ["log"] } tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] } aws_lambda_events = "0.15" -lambda_runtime = "0.10" +lambda_runtime = "0.11" -filemanager = { path = "../filemanager" } \ No newline at end of file +filemanager = { path = "../filemanager" } diff --git a/lib/workload/stateless/filemanager/filemanager-migrate-lambda/Cargo.toml b/lib/workload/stateless/filemanager/filemanager-migrate-lambda/Cargo.toml index 8fb479560..0c511efa1 100644 --- a/lib/workload/stateless/filemanager/filemanager-migrate-lambda/Cargo.toml +++ b/lib/workload/stateless/filemanager/filemanager-migrate-lambda/Cargo.toml @@ -12,6 +12,6 @@ tracing = { version = "0.1", features = ["log"] } tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt"] } aws_lambda_events = "0.15" -lambda_runtime = "0.10" +lambda_runtime = "0.11" -filemanager = { path = "../filemanager", features = ["migrate"] } \ No newline at end of file +filemanager = { path = "../filemanager", features = ["migrate"] } diff --git a/lib/workload/stateless/filemanager/filemanager/Cargo.toml b/lib/workload/stateless/filemanager/filemanager/Cargo.toml index 543592167..0cc6d304c 100644 --- a/lib/workload/stateless/filemanager/filemanager/Cargo.toml +++ b/lib/workload/stateless/filemanager/filemanager/Cargo.toml @@ -32,7 +32,7 @@ itertools = "0.12" aws-sdk-sqs = "1" aws-config = "1" aws-sdk-s3 = "1" -lambda_runtime = "0.10" +lambda_runtime = "0.11" aws_lambda_events = "0.15" [dev-dependencies] @@ -41,4 +41,4 @@ lazy_static = "1" aws-smithy-runtime-api = "1" # The migrate feature is required to run sqlx tests -filemanager = { path = ".", features = ["migrate"] } \ No newline at end of file +filemanager = { path = ".", features = ["migrate"] }