From d6e717f00620b50e4059afa6d3276b24259ed235 Mon Sep 17 00:00:00 2001 From: hijiki51 Date: Sun, 24 Nov 2024 16:51:34 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Qualify->Contest(?= =?UTF-8?q?=E4=B8=80=E9=83=A8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/admin/cloud_formations_controller.rb | 2 +- .../contestant/cloud_formations_controller.rb | 2 +- .../ContestantContestantInstanceList.tsx | 2 +- .../{qualify.yaml.erb => contest.yaml.erb} | 28 +++++++++---------- portal/app/models/cloud_formation.rb | 6 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) rename portal/app/models/cf_templates/{qualify.yaml.erb => contest.yaml.erb} (94%) diff --git a/portal/app/controllers/api/admin/cloud_formations_controller.rb b/portal/app/controllers/api/admin/cloud_formations_controller.rb index 171d2f1..2a4b86b 100644 --- a/portal/app/controllers/api/admin/cloud_formations_controller.rb +++ b/portal/app/controllers/api/admin/cloud_formations_controller.rb @@ -10,7 +10,7 @@ def show when "test" CloudFormation.test_template(team) when "qualify" - CloudFormation.qualify_template(team) + CloudFormation.contest_template(team) else raise "Unexpected type: #{params[:type]}" end diff --git a/portal/app/controllers/api/contestant/cloud_formations_controller.rb b/portal/app/controllers/api/contestant/cloud_formations_controller.rb index 140830d..b37d929 100644 --- a/portal/app/controllers/api/contestant/cloud_formations_controller.rb +++ b/portal/app/controllers/api/contestant/cloud_formations_controller.rb @@ -5,7 +5,7 @@ class Api::Contestant::CloudFormationsController < Api::Contestant::ApplicationC def show raise ActiveRecord::RecordNotFound, "no cloudformation template for final" if Rails.application.config.x.contest.final - template = CloudFormation.qualify_template(current_team) + template = CloudFormation.contest_template(current_team) render protobuf: Isuxportal::Proto::Services::Contestant::GetCloudFormationResponse.new( template: template, diff --git a/portal/app/javascript/contestant/ContestantContestantInstanceList.tsx b/portal/app/javascript/contestant/ContestantContestantInstanceList.tsx index 02f1334..d783066 100644 --- a/portal/app/javascript/contestant/ContestantContestantInstanceList.tsx +++ b/portal/app/javascript/contestant/ContestantContestantInstanceList.tsx @@ -75,7 +75,7 @@ export const ContestantContestantInstanceList: React.FC = ({ session, cli CloudFormation テンプレートをダウンロード diff --git a/portal/app/models/cf_templates/qualify.yaml.erb b/portal/app/models/cf_templates/contest.yaml.erb similarity index 94% rename from portal/app/models/cf_templates/qualify.yaml.erb rename to portal/app/models/cf_templates/contest.yaml.erb index aab8173..799dfbe 100644 --- a/portal/app/models/cf_templates/qualify.yaml.erb +++ b/portal/app/models/cf_templates/contest.yaml.erb @@ -1,6 +1,6 @@ AWSTemplateFormatVersion: 2010-09-09 Description: >- - AWS CloudFormation for ISUCON14 Qualify + AWS CloudFormation for ISUCON14 Resources: GetAvailabilityZoneFunctionExecutionRole: Type: AWS::IAM::Role @@ -95,7 +95,7 @@ Resources: Type: AWS::EC2::SecurityGroup Properties: VpcId: !Ref VPC - GroupDescription: Security Group for ISUCON14 Qualify + GroupDescription: Security Group for ISUCON14 SecurityGroupIngress: - IpProtocol: tcp FromPort: "22" @@ -143,7 +143,7 @@ Resources: Roles: - !Ref InstanceRole - QualifyInstance1: + Instance1: Type: AWS::EC2::Instance Properties: ImageId: <%= ami_id %> @@ -161,7 +161,7 @@ Resources: VolumeType: gp3 Tags: - Key: Name - Value: isucon14-qualify-1 + Value: isucon14-1 UserData: Fn::Base64: | #cloud-config @@ -173,12 +173,12 @@ Resources: content: '<%= portal_credentials %>' runcmd: - 'curl --retry 5 --retry-connrefused --max-time 10 --connect-timeout 5 "https://<%= portal_host %>/api/ssh_public_keys?token=<%= token %>" | sudo -u isucon sh -c "umask 077; cat > /home/isucon/.ssh/authorized_keys"' - QualifyInstanceIP1: + InstanceIP1: Type: AWS::EC2::EIP Properties: Domain: vpc - InstanceId: !Ref QualifyInstance1 - QualifyInstance2: + InstanceId: !Ref Instance1 + Instance2: Type: AWS::EC2::Instance Properties: ImageId: <%= ami_id %> @@ -196,7 +196,7 @@ Resources: VolumeType: gp3 Tags: - Key: Name - Value: isucon14-qualify-2 + Value: isucon14-2 UserData: Fn::Base64: | #cloud-config @@ -208,12 +208,12 @@ Resources: content: '<%= portal_credentials %>' runcmd: - 'curl --retry 5 --retry-connrefused --max-time 10 --connect-timeout 5 "https://<%= portal_host %>/api/ssh_public_keys?token=<%= token %>" | sudo -u isucon sh -c "umask 077; cat > /home/isucon/.ssh/authorized_keys"' - QualifyInstanceIP2: + InstanceIP2: Type: AWS::EC2::EIP Properties: Domain: vpc - InstanceId: !Ref QualifyInstance2 - QualifyInstance3: + InstanceId: !Ref Instance2 + Instance3: Type: AWS::EC2::Instance Properties: ImageId: <%= ami_id %> @@ -231,7 +231,7 @@ Resources: VolumeType: gp3 Tags: - Key: Name - Value: isucon14-qualify-3 + Value: isucon14-3 UserData: Fn::Base64: | #cloud-config @@ -243,8 +243,8 @@ Resources: content: '<%= portal_credentials %>' runcmd: - 'curl --retry 5 --retry-connrefused --max-time 10 --connect-timeout 5 "https://<%= portal_host %>/api/ssh_public_keys?token=<%= token %>" | sudo -u isucon sh -c "umask 077; cat > /home/isucon/.ssh/authorized_keys"' - QualifyInstanceIP3: + InstanceIP3: Type: AWS::EC2::EIP Properties: Domain: vpc - InstanceId: !Ref QualifyInstance3 + InstanceId: !Ref Instance3 diff --git a/portal/app/models/cloud_formation.rb b/portal/app/models/cloud_formation.rb index 338cb64..10cca57 100644 --- a/portal/app/models/cloud_formation.rb +++ b/portal/app/models/cloud_formation.rb @@ -4,7 +4,7 @@ module CloudFormation TEST_ERB = ERB.new(File.read(File.join(File.dirname(__FILE__), './cf_templates/test.yaml.erb'))) - QUALIFY_ERB = ERB.new(File.read(File.join(File.dirname(__FILE__), './cf_templates/qualify.yaml.erb'))) + CONTEST_ERB = ERB.new(File.read(File.join(File.dirname(__FILE__), './cf_templates/contest.yaml.erb'))) def self.template(erb, b) erb.result(b) @@ -30,7 +30,7 @@ def self.test_template(team) end end - def self.qualify_template(team) + def self.contest_template(team) zone_id = team.availability_zone token = create_token( team, @@ -41,7 +41,7 @@ def self.qualify_template(team) ami_id = Rails.application.config.x.qualify_ami_id unless zone_id.nil? - template(QUALIFY_ERB, binding) + template(CONTEST_ERB, binding) else raise "Availability Zone should be set to team" end