Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(filemanager): add uuid to target directory to avoid concurrency errors #189

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/workload/stateless/filemanager/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
filemanager = { path = "../filemanager" }
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
filemanager = { path = "../filemanager", features = ["migrate"] }
4 changes: 2 additions & 2 deletions lib/workload/stateless/filemanager/filemanager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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"] }
filemanager = { path = ".", features = ["migrate"] }
Loading