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: invalid fork terraform #5585

Merged
merged 1 commit into from
Apr 5, 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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ jobs:
name: "Deploy mainnet fork"
command: |
should_deploy || exit 0
deploy_terraform_services iac/mainnet-fork
deploy_terraform_services iac/mainnet-fork mainnet-fork mainnet-fork aws_efs_file_system.aztec_mainnet_fork_data_store
- run:
name: "Release canary to NPM: bb.js"
command: |
Expand Down Expand Up @@ -1244,7 +1244,7 @@ jobs:
# Check if l1-contracts have changed
if [ "$CONTRACTS_DEPLOYED" -eq 1 ]; then
echo "Contracts have changed, taint nodes to force redeploy.."
deploy_terraform_services yarn-project/aztec-node aztec aztec-node "aws_ecs_task_definition.aztec-node[0],aws_ecs_task_definition.aztec-node[1]"
deploy_terraform_services yarn-project/aztec-node aztec aztec-node "aws_ecs_task_definition.aztec-node[0],aws_ecs_task_definition.aztec-node[1]" 1
else
deploy_terraform_services yarn-project/aztec-node aztec
fi
Expand Down
5 changes: 4 additions & 1 deletion build-system/scripts/deploy_terraform_services
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ SERVICE_NAMES=${3:-$PROJECT_NAME}
# The terraform resources to taint. Defaults to none.
TO_TAINT=${4:-}

# Flag to force a deployment even if no changes are detected.
FORCE_DEPLOY=${5:-}

cd $PROJECT_DIR

# Bail out if nothing changed.
CONTENT_HASH=$(calculate_content_hash $CHECK_REBUILD_REPOSITORY)
echo "Last successfully deployed commit: $CONTENT_HASH"
if [ -z "$TO_TAINT" ] && check_rebuild cache-$CONTENT_HASH-$DEPLOY_TAG-deployed $CHECK_REBUILD_REPOSITORY; then
if [ -z "$FORCE_DEPLOY" ] && check_rebuild cache-$CONTENT_HASH-$DEPLOY_TAG-deployed $CHECK_REBUILD_REPOSITORY; then
Comment on lines -27 to +30
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we check both TO_TAINT and FORCE_DEPLOY? If a terraform resource was tainted, we shouldn't bail early, right?

Copy link
Member Author

@spypsy spypsy Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't check if something was tainted, we tell the script to taint a specific resource so it cause a redeployment.
So far this was only used to taint nodes when the l1 contracts were re-deployed so they restarted with the updated contract addresses, so every time this was called with TO_TAINT, we skipped check_rebuild.

Now with the mainnet fork though, we only want to deploy and taint the resource if there's been a change

echo "No changes detected, skipping deployment."
exit 0
fi
Expand Down
3 changes: 1 addition & 2 deletions iac/mainnet-fork/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ resource "aws_efs_file_system" "aztec_mainnet_fork_data_store" {
creation_token = "${var.DEPLOY_TAG}-mainnet-fork-data"

tags = {
Name = "${var.DEPLOY_TAG}-mainnet-fork-data"
TaskDefinitionArn = "${aws_ecs_task_definition.aztec_mainnet_fork.arn}" # This line forces recreation on task definition change
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too familiar with how we're using terraform, but why don't we want to keep this line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the line that's causing the error, cyclical reference between the 2 resources (ECS task & EFS storage). There are ways to get around it, like using a hash of the value but I don't want to get too 'hacky' with terraform configs

Name = "${var.DEPLOY_TAG}-mainnet-fork-data"
}

lifecycle_policy {
Expand Down
Loading