From a3e82a48f6972b8c01e90f63644b61d2aa4d31b5 Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Fri, 11 Oct 2024 11:18:00 -0400 Subject: [PATCH 01/13] Create Shoryuken config --- Dockerfile | 6 ++++++ Gemfile | 1 + app/jobs/add_registration_job.rb | 1 + bin/docker-entrypoint-shoryuken | 2 ++ config/shoryuken.yml | 4 ++++ env_config.rb | 2 ++ 6 files changed, 16 insertions(+) create mode 100755 bin/docker-entrypoint-shoryuken create mode 100644 config/shoryuken.yml diff --git a/Dockerfile b/Dockerfile index 6cd6d04326..03ecf64aa6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -87,6 +87,12 @@ RUN gem install mailcatcher ENTRYPOINT ["/rails/bin/docker-entrypoint-sidekiq"] +FROM runtime AS shoryuken + +USER rails:rails + +ENTRYPOINT ["/rails/bin/docker-entrypoint-shoryuken"] + FROM runtime AS monolith EXPOSE 3000 diff --git a/Gemfile b/Gemfile index d65fdb3172..1acd90a4ba 100644 --- a/Gemfile +++ b/Gemfile @@ -162,4 +162,5 @@ group :production do gem 'rack' gem 'newrelic_rpm' gem 'wkhtmltopdf-binary-ng' + gem 'shoryuken' end diff --git a/app/jobs/add_registration_job.rb b/app/jobs/add_registration_job.rb index cf0990c942..c531252a5e 100644 --- a/app/jobs/add_registration_job.rb +++ b/app/jobs/add_registration_job.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true class AddRegistrationJob < ApplicationJob + self.queue_adapter = :shoryuken unless Rails.env.local? def perform(lane_name, competition_id, user_id, lane_params) lane_model_name = lane_name.upcase_first diff --git a/bin/docker-entrypoint-shoryuken b/bin/docker-entrypoint-shoryuken new file mode 100755 index 0000000000..1b8a5102eb --- /dev/null +++ b/bin/docker-entrypoint-shoryuken @@ -0,0 +1,2 @@ +#!/bin/bash -e +bundle exec shoryuken -R -C config/shoryuken.yml diff --git a/config/shoryuken.yml b/config/shoryuken.yml new file mode 100644 index 0000000000..91a32b9f12 --- /dev/null +++ b/config/shoryuken.yml @@ -0,0 +1,4 @@ +queues: + - <%= EnvConfig.REGISTRATION_QUEUE %> +delay: 1 +concurrency: 2 diff --git a/env_config.rb b/env_config.rb index 5d13471d29..190e1cc546 100644 --- a/env_config.rb +++ b/env_config.rb @@ -30,6 +30,7 @@ mandatory :WCA_REGISTRATIONS_POLL_URL, :string mandatory :ASSET_HOST, :string mandatory :CDN_ASSETS_DISTRIBUTION_ID, :string + mandatory :REGISTRATION_QUEUE, :string else optional :READ_REPLICA_HOST, :string, '' optional :CACHE_REDIS_URL, :string, '' @@ -47,6 +48,7 @@ optional :WCA_REGISTRATIONS_POLL_URL, :string, '' optional :PAYPAL_BASE_URL, :string, '' optional :WRC_WEBHOOK_URL, :string, '' + optional :REGISTRATION_QUEUE, :string, '' # Local-specific stuff optional :DISABLE_BULLET, :bool, false From a0a0588fa9a7d0e5bdf2f2424121ee9e3433800e Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Fri, 11 Oct 2024 11:27:56 -0400 Subject: [PATCH 02/13] example infra --- infra/wca_on_rails/production/rails.tf | 11 +++++++++++ infra/wca_on_rails/production/sqs.tf | 15 +++++++++++++++ infra/wca_on_rails/staging/rails.tf | 11 +++++++++++ infra/wca_on_rails/staging/sqs.tf | 15 +++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 infra/wca_on_rails/production/sqs.tf create mode 100644 infra/wca_on_rails/staging/sqs.tf diff --git a/infra/wca_on_rails/production/rails.tf b/infra/wca_on_rails/production/rails.tf index 10f13ad0df..2a3ad54bf7 100644 --- a/infra/wca_on_rails/production/rails.tf +++ b/infra/wca_on_rails/production/rails.tf @@ -191,6 +191,17 @@ data "aws_iam_policy_document" "task_policy" { ] resources = ["arn:aws:rds-db:${var.region}:${var.shared.account_id}:dbuser:${var.rds_iam_identifier}/${var.DATABASE_WRT_USER}"] } + statement { + effect = "Allow" + actions = [ + "sqs:SendMessage", + "sqs:ReceiveMessage", + "sqs:DeleteMessage", + "sqs:GetQueueAttributes", + "sqs:GetQueueUrl" + ] + resources = [aws_sqs_queue.this.arn] + } } resource "aws_iam_role_policy" "task_policy" { diff --git a/infra/wca_on_rails/production/sqs.tf b/infra/wca_on_rails/production/sqs.tf new file mode 100644 index 0000000000..c19f718033 --- /dev/null +++ b/infra/wca_on_rails/production/sqs.tf @@ -0,0 +1,15 @@ +# Define the SQS FIFO queue +resource "aws_sqs_queue" "this" { + name = "registrations-monolith.fifo" + fifo_queue = true + content_based_deduplication = true + deduplication_scope = "queue" + delay_seconds = 0 + max_message_size = 262144 + message_retention_seconds = 345600 + receive_wait_time_seconds = 0 + visibility_timeout_seconds = 60 + tags = { + Env = "staging" + } +} diff --git a/infra/wca_on_rails/staging/rails.tf b/infra/wca_on_rails/staging/rails.tf index 43594b5e82..888dc07399 100644 --- a/infra/wca_on_rails/staging/rails.tf +++ b/infra/wca_on_rails/staging/rails.tf @@ -184,6 +184,17 @@ data "aws_iam_policy_document" "task_policy" { ] resources = ["arn:aws:rds-db:${var.region}:${var.shared.account_id}:dbuser:${var.rds_iam_identifier}/${var.DATABASE_WRT_USER}"] } + statement { + effect = "Allow" + actions = [ + "sqs:SendMessage", + "sqs:ReceiveMessage", + "sqs:DeleteMessage", + "sqs:GetQueueAttributes", + "sqs:GetQueueUrl" + ] + resources = [aws_sqs_queue.this.arn] + } } resource "aws_iam_role_policy" "task_policy" { diff --git a/infra/wca_on_rails/staging/sqs.tf b/infra/wca_on_rails/staging/sqs.tf new file mode 100644 index 0000000000..c95b2e10e7 --- /dev/null +++ b/infra/wca_on_rails/staging/sqs.tf @@ -0,0 +1,15 @@ +# Define the SQS FIFO queue +resource "aws_sqs_queue" "this" { + name = "registrations-monolith-staging.fifo" + fifo_queue = true + content_based_deduplication = true + deduplication_scope = "queue" + delay_seconds = 0 + max_message_size = 262144 + message_retention_seconds = 345600 + receive_wait_time_seconds = 0 + visibility_timeout_seconds = 60 + tags = { + Env = "staging" + } +} From 3df21725abe9760c797928a66e53ce6c03332674 Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Fri, 11 Oct 2024 11:31:58 -0400 Subject: [PATCH 03/13] add queue URL to env variables --- infra/wca_on_rails/production/rails.tf | 4 ++++ infra/wca_on_rails/staging/rails.tf | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/infra/wca_on_rails/production/rails.tf b/infra/wca_on_rails/production/rails.tf index 2a3ad54bf7..67a59e52a0 100644 --- a/infra/wca_on_rails/production/rails.tf +++ b/infra/wca_on_rails/production/rails.tf @@ -104,6 +104,10 @@ locals { name = "VAULT_ADDR" value = var.VAULT_ADDR }, + { + name = "REGISTRATION_QUEUE" + value = aws_sqs_queue.this.url + }, { name = "VAULT_APPLICATION" value = var.VAULT_APPLICATION diff --git a/infra/wca_on_rails/staging/rails.tf b/infra/wca_on_rails/staging/rails.tf index 888dc07399..271cbbadac 100644 --- a/infra/wca_on_rails/staging/rails.tf +++ b/infra/wca_on_rails/staging/rails.tf @@ -52,6 +52,10 @@ locals { name = "STORAGE_AWS_BUCKET" value = aws_s3_bucket.storage-bucket.id }, + { + name = "REGISTRATION_QUEUE" + value = aws_sqs_queue.this.url + }, { name = "STORAGE_AWS_REGION" value = var.region From 0ed68f0d700f7d40119de54e97d88895db882664 Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Fri, 11 Oct 2024 11:39:16 -0400 Subject: [PATCH 04/13] update gemfile.lock --- Gemfile.lock | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index c65c87b70a..31b19109ae 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -709,6 +709,10 @@ GEM railties (>= 5.2) semantic_range (>= 2.3.0) shellany (0.0.1) + shoryuken (6.2.1) + aws-sdk-core (>= 2) + concurrent-ruby + thor sidekiq (7.3.2) concurrent-ruby (< 2) connection_pool (>= 2.3.0) @@ -923,6 +927,7 @@ DEPENDENCIES seedbank selectize-rails! shakapacker (= 8.0.2) + shoryuken sidekiq sidekiq-cron simple_form From 1d1c3b6aef832262e95e81725746ca51dd0417a4 Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Tue, 15 Oct 2024 14:07:09 -0400 Subject: [PATCH 05/13] add sqs worker service --- infra/wca_on_rails/production/worker.tf | 103 ++++++++++++++++++++++++ infra/wca_on_rails/staging/worker.tf | 103 ++++++++++++++++++++++++ 2 files changed, 206 insertions(+) create mode 100644 infra/wca_on_rails/production/worker.tf create mode 100644 infra/wca_on_rails/staging/worker.tf diff --git a/infra/wca_on_rails/production/worker.tf b/infra/wca_on_rails/production/worker.tf new file mode 100644 index 0000000000..e071be9174 --- /dev/null +++ b/infra/wca_on_rails/production/worker.tf @@ -0,0 +1,103 @@ +resource "aws_cloudwatch_log_group" "worker" { + name = "${var.name_prefix}-sqs-worker" +} + +resource "aws_ecs_task_definition" "worker" { + family = "${var.name_prefix}-sqs-worker" + + network_mode = "awsvpc" + requires_compatibilities = ["EC2"] + + # We configure the roles to allow `aws ecs execute-command` into a task, + # as in https://aws.amazon.com/blogs/containers/new-using-amazon-ecs-exec-access-your-containers-fargate-ec2 + execution_role_arn = aws_iam_role.task_execution_role.arn + task_role_arn = aws_iam_role.task_role.arn + + cpu = "256" + memory = "256" + + container_definitions = jsonencode([ + + { + name = "sqs-worker-staging" + image = "${var.shared.ecr_repository.repository_url}:sqs-worker-production" + cpu = 256 + memory = 256 + portMappings = [] + logConfiguration = { + logDriver = "awslogs" + options = { + awslogs-group = aws_cloudwatch_log_group.this.name + awslogs-region = var.region + awslogs-stream-prefix = var.name_prefix + } + } + environment = local.rails_environment + healthCheck = { + command = ["CMD-SHELL", "pgrep ruby || exit 1"] + interval = 30 + retries = 3 + startPeriod = 60 + timeout = 5 + } + }, + ]) + + tags = { + Name = var.name_prefix + } +} + +data "aws_ecs_task_definition" "worker" { + task_definition = aws_ecs_task_definition.auxiliary.family +} + +resource "aws_ecs_service" "worker" { + name = "${var.name_prefix}-sqs-worker" + cluster = var.shared.ecs_cluster.id + # During deployment a new task revision is created with modified + # container image, so we want use data.aws_ecs_task_definition to + # always point to the active task definition + task_definition = data.aws_ecs_task_definition.auxiliary.arn + desired_count = 1 + scheduling_strategy = "REPLICA" + deployment_maximum_percent = 200 + deployment_minimum_healthy_percent = 50 + health_check_grace_period_seconds = 0 + + capacity_provider_strategy { + capacity_provider = var.shared.t3_capacity_provider.name + weight = 1 + } + + enable_execute_command = true + + deployment_circuit_breaker { + enable = true + rollback = false + } + + ordered_placement_strategy { + type = "spread" + field = "attribute:ecs.availability-zone" + } + + ordered_placement_strategy { + type = "spread" + field = "instanceId" + } + + network_configuration { + security_groups = [var.shared.cluster_security.id] + subnets = var.shared.private_subnets[*].id + } + + deployment_controller { + type = "ECS" + } + + tags = { + Name = var.name_prefix + } + +} diff --git a/infra/wca_on_rails/staging/worker.tf b/infra/wca_on_rails/staging/worker.tf new file mode 100644 index 0000000000..1e769cb34f --- /dev/null +++ b/infra/wca_on_rails/staging/worker.tf @@ -0,0 +1,103 @@ +resource "aws_cloudwatch_log_group" "worker" { + name = "${var.name_prefix}-sqs-worker" +} + +resource "aws_ecs_task_definition" "worker" { + family = "${var.name_prefix}-sqs-worker" + + network_mode = "awsvpc" + requires_compatibilities = ["EC2"] + + # We configure the roles to allow `aws ecs execute-command` into a task, + # as in https://aws.amazon.com/blogs/containers/new-using-amazon-ecs-exec-access-your-containers-fargate-ec2 + execution_role_arn = aws_iam_role.task_execution_role.arn + task_role_arn = aws_iam_role.task_role.arn + + cpu = "256" + memory = "256" + + container_definitions = jsonencode([ + + { + name = "sqs-worker-staging" + image = "${var.shared.ecr_repository.repository_url}:sqs-worker-staging" + cpu = 256 + memory = 256 + portMappings = [] + logConfiguration = { + logDriver = "awslogs" + options = { + awslogs-group = aws_cloudwatch_log_group.this.name + awslogs-region = var.region + awslogs-stream-prefix = var.name_prefix + } + } + environment = local.rails_environment + healthCheck = { + command = ["CMD-SHELL", "pgrep ruby || exit 1"] + interval = 30 + retries = 3 + startPeriod = 60 + timeout = 5 + } + }, + ]) + + tags = { + Name = var.name_prefix + } +} + +data "aws_ecs_task_definition" "worker" { + task_definition = aws_ecs_task_definition.auxiliary.family +} + +resource "aws_ecs_service" "worker" { + name = "${var.name_prefix}-sqs-worker" + cluster = var.shared.ecs_cluster.id + # During deployment a new task revision is created with modified + # container image, so we want use data.aws_ecs_task_definition to + # always point to the active task definition + task_definition = data.aws_ecs_task_definition.auxiliary.arn + desired_count = 1 + scheduling_strategy = "REPLICA" + deployment_maximum_percent = 200 + deployment_minimum_healthy_percent = 50 + health_check_grace_period_seconds = 0 + + capacity_provider_strategy { + capacity_provider = var.shared.t3_capacity_provider.name + weight = 1 + } + + enable_execute_command = true + + deployment_circuit_breaker { + enable = true + rollback = false + } + + ordered_placement_strategy { + type = "spread" + field = "attribute:ecs.availability-zone" + } + + ordered_placement_strategy { + type = "spread" + field = "instanceId" + } + + network_configuration { + security_groups = [var.shared.cluster_security.id] + subnets = var.shared.private_subnets[*].id + } + + deployment_controller { + type = "ECS" + } + + tags = { + Name = var.name_prefix + } + +} From d0a35ca8b03eba931638bd1a07a186ae3918a0dd Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Tue, 15 Oct 2024 14:32:19 -0400 Subject: [PATCH 06/13] add building the sqs image to github action --- .github/actions/build-environment/action.yaml | 8 ++++++++ infra/wca_on_rails/production/worker.tf | 2 +- infra/wca_on_rails/staging/worker.tf | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/actions/build-environment/action.yaml b/.github/actions/build-environment/action.yaml index 3554678023..8b34aa4360 100644 --- a/.github/actions/build-environment/action.yaml +++ b/.github/actions/build-environment/action.yaml @@ -47,6 +47,14 @@ runs: tag: ${{inputs.environment}}-api build_tag: ${{ inputs.build_tag }} environment: ${{ inputs.environment }} + - name: Build and push SQS Worker + uses: ./.github/actions/build-image + with: + target: shoryuken + registry: ${{ inputs.registry }} + tag: ${{inputs.environment}}-sqs-worker + build_tag: ${{ inputs.build_tag }} + environment: ${{ inputs.environment }} - name: Build and push Image uses: ./.github/actions/build-image with: diff --git a/infra/wca_on_rails/production/worker.tf b/infra/wca_on_rails/production/worker.tf index e071be9174..9a07637ecb 100644 --- a/infra/wca_on_rails/production/worker.tf +++ b/infra/wca_on_rails/production/worker.tf @@ -20,7 +20,7 @@ resource "aws_ecs_task_definition" "worker" { { name = "sqs-worker-staging" - image = "${var.shared.ecr_repository.repository_url}:sqs-worker-production" + image = "${var.shared.ecr_repository.repository_url}:production-sqs-worker" cpu = 256 memory = 256 portMappings = [] diff --git a/infra/wca_on_rails/staging/worker.tf b/infra/wca_on_rails/staging/worker.tf index 1e769cb34f..4920e5c2e9 100644 --- a/infra/wca_on_rails/staging/worker.tf +++ b/infra/wca_on_rails/staging/worker.tf @@ -20,7 +20,7 @@ resource "aws_ecs_task_definition" "worker" { { name = "sqs-worker-staging" - image = "${var.shared.ecr_repository.repository_url}:sqs-worker-staging" + image = "${var.shared.ecr_repository.repository_url}:staging-sqs-worker" cpu = 256 memory = 256 portMappings = [] From bac8f84cf763f4da63184c55db9c7cc94003d597 Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Wed, 16 Oct 2024 13:42:54 -0400 Subject: [PATCH 07/13] set desired count to 0 for prod --- infra/wca_on_rails/production/sqs.tf | 2 +- infra/wca_on_rails/production/worker.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/wca_on_rails/production/sqs.tf b/infra/wca_on_rails/production/sqs.tf index c19f718033..288467cc71 100644 --- a/infra/wca_on_rails/production/sqs.tf +++ b/infra/wca_on_rails/production/sqs.tf @@ -10,6 +10,6 @@ resource "aws_sqs_queue" "this" { receive_wait_time_seconds = 0 visibility_timeout_seconds = 60 tags = { - Env = "staging" + Env = "Production" } } diff --git a/infra/wca_on_rails/production/worker.tf b/infra/wca_on_rails/production/worker.tf index 9a07637ecb..eed7a052f5 100644 --- a/infra/wca_on_rails/production/worker.tf +++ b/infra/wca_on_rails/production/worker.tf @@ -59,7 +59,7 @@ resource "aws_ecs_service" "worker" { # container image, so we want use data.aws_ecs_task_definition to # always point to the active task definition task_definition = data.aws_ecs_task_definition.auxiliary.arn - desired_count = 1 + desired_count = 0 scheduling_strategy = "REPLICA" deployment_maximum_percent = 200 deployment_minimum_healthy_percent = 50 From c140db4268b6acc155174cadb4ccfa333bcaa460 Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Thu, 17 Oct 2024 12:05:47 -0400 Subject: [PATCH 08/13] monkeypatch enqueue_after_transaction_commit? for ShoryukenAdapter --- config/initializers/monkey_patches.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/config/initializers/monkey_patches.rb b/config/initializers/monkey_patches.rb index 1e91f85705..bef6ffedef 100644 --- a/config/initializers/monkey_patches.rb +++ b/config/initializers/monkey_patches.rb @@ -102,4 +102,13 @@ def self.migration_table_name end end end + # Temporary fix until https://github.com/ruby-shoryuken/shoryuken/pull/777 or + # https://github.com/rails/rails/pull/53336 is merged + if Rails.env.production? + ShoryukenAdapter.class_eval do + def enqueue_after_transaction_commit? + true + end + end + end end From 728b3bc8b2247894b789d0f9c5b888b7ee8e31ba Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Tue, 29 Oct 2024 16:42:21 +0100 Subject: [PATCH 09/13] also install aws-sdk-sqs --- Gemfile | 1 + Gemfile.lock | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index 2147ad65e1..896fe36786 100644 --- a/Gemfile +++ b/Gemfile @@ -65,6 +65,7 @@ gem 'ostruct' gem 'selectize-rails', github: 'jfly/selectize-rails' gem 'aws-sdk-s3' +gem 'aws-sdk-sqs' gem 'aws-sdk-rds' gem 'aws-sdk-cloudfront' diff --git a/Gemfile.lock b/Gemfile.lock index 460aa76462..90839df6e1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -166,6 +166,9 @@ GEM aws-sdk-core (~> 3, >= 3.210.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.5) + aws-sdk-sqs (1.87.0) + aws-sdk-core (~> 3, >= 3.210.0) + aws-sigv4 (~> 1.5) aws-sigv4 (1.10.1) aws-eventstream (~> 1, >= 1.0.2) babel-source (5.8.35) @@ -819,6 +822,7 @@ DEPENDENCIES aws-sdk-cloudfront aws-sdk-rds aws-sdk-s3 + aws-sdk-sqs better_errors binding_of_caller blocks From 0044de72d1e94d9c047b379cb6ce740b48d4d7c1 Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Tue, 29 Oct 2024 17:02:47 +0100 Subject: [PATCH 10/13] correct monkey_patches.rb --- config/initializers/monkey_patches.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/monkey_patches.rb b/config/initializers/monkey_patches.rb index bef6ffedef..b0ec1cd5b4 100644 --- a/config/initializers/monkey_patches.rb +++ b/config/initializers/monkey_patches.rb @@ -105,7 +105,7 @@ def self.migration_table_name # Temporary fix until https://github.com/ruby-shoryuken/shoryuken/pull/777 or # https://github.com/rails/rails/pull/53336 is merged if Rails.env.production? - ShoryukenAdapter.class_eval do + ActiveJob::QueueAdapters::ShoryukenAdapter.class_eval do def enqueue_after_transaction_commit? true end From b89098ff001464fd47a6756ee0161b4216034bab Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Tue, 29 Oct 2024 17:25:38 +0100 Subject: [PATCH 11/13] fix worker using the wrong task definition --- infra/wca_on_rails/production/worker.tf | 2 +- infra/wca_on_rails/staging/worker.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/wca_on_rails/production/worker.tf b/infra/wca_on_rails/production/worker.tf index eed7a052f5..0e5928a960 100644 --- a/infra/wca_on_rails/production/worker.tf +++ b/infra/wca_on_rails/production/worker.tf @@ -49,7 +49,7 @@ resource "aws_ecs_task_definition" "worker" { } data "aws_ecs_task_definition" "worker" { - task_definition = aws_ecs_task_definition.auxiliary.family + task_definition = aws_ecs_task_definition.worker.family } resource "aws_ecs_service" "worker" { diff --git a/infra/wca_on_rails/staging/worker.tf b/infra/wca_on_rails/staging/worker.tf index 4920e5c2e9..e295482911 100644 --- a/infra/wca_on_rails/staging/worker.tf +++ b/infra/wca_on_rails/staging/worker.tf @@ -49,7 +49,7 @@ resource "aws_ecs_task_definition" "worker" { } data "aws_ecs_task_definition" "worker" { - task_definition = aws_ecs_task_definition.auxiliary.family + task_definition = aws_ecs_task_definition.worker.family } resource "aws_ecs_service" "worker" { From 1c4954408eb22652b5d91a4ece0fa5a6994638da Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Tue, 29 Oct 2024 17:54:16 +0100 Subject: [PATCH 12/13] add init script to set region --- config/initializers/shoryuken.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 config/initializers/shoryuken.rb diff --git a/config/initializers/shoryuken.rb b/config/initializers/shoryuken.rb new file mode 100644 index 0000000000..c677046af1 --- /dev/null +++ b/config/initializers/shoryuken.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +if Rails.env.production? + Shoryuken.configure_client do |config| + config.sqs_client = Aws::SQS::Client.new( + region: EnvConfig.DATABASE_AWS_REGION, + credentials: Aws::ECSCredentials.new, + ) + end + + Shoryuken.configure_server do |config| + config.sqs_client = Aws::SQS::Client.new( + region: EnvConfig.DATABASE_AWS_REGION, + credentials: Aws::ECSCredentials.new, + ) + end +end From c42abf91bf1b9629a211ff1550d83d57dd2f3705 Mon Sep 17 00:00:00 2001 From: FinnIckler Date: Wed, 6 Nov 2024 10:39:21 +0100 Subject: [PATCH 13/13] fix whitespace --- app/jobs/add_registration_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/jobs/add_registration_job.rb b/app/jobs/add_registration_job.rb index 3362ea81d1..49a3fe6c31 100644 --- a/app/jobs/add_registration_job.rb +++ b/app/jobs/add_registration_job.rb @@ -2,7 +2,7 @@ class AddRegistrationJob < ApplicationJob self.queue_adapter = :shoryuken unless Rails.env.local? - + before_enqueue do |job| _, competition_id, user_id = job.arguments Rails.cache.write(CacheAccess.registration_processing_cache_key(competition_id, user_id), true)