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

Deploy benchrunner to AWS #7

Open
wants to merge 13 commits into
base: cinder/3.10
Choose a base branch
from
Open
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
45 changes: 45 additions & 0 deletions .github/workflows/_generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: _generate

"on":
workflow_call:
inputs:
force:
type: boolean
default: false
dry_run:
type: boolean
default: false

workflow_dispatch:
inputs:
force:
description: "Regenerate all of the derived data, even if it already exists"
type: boolean
default: false
dry_run:
description: "Dry run: Do not commit to the repo"
type: boolean
default: false

jobs:
generate-results:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: pip
- name: install dependencies
run:
python -m pip install -r requirements.txt
- name: regenerate
run:
python -m bench_runner.scripts.generate_results ${{ inputs.force == true && '--force' || '' }}
- name: Add to repo
uses: EndBug/add-and-commit@v9
if: ${{ !inputs.dry_run }}
with:
add: "['results', 'README.md', 'RESULTS.md', 'longitudinal.png', 'profiling/profiling.png', 'profiling/profiling.md']"
message: Benchmarking results for @${{ github.actor }}
50 changes: 50 additions & 0 deletions .github/workflows/_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
name: _publish

"on":
workflow_call:
inputs:
force:
type: boolean
default: false
dry_run:
type: boolean
default: false

workflow_dispatch:
inputs:
force:
description: "Regenerate all of the derived data, even if it already exists"
type: boolean
default: false
dry_run:
description: "Dry run: Do not commit to the repo"
type: boolean
default: false

jobs:
mirror:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: private
ref: main
fetch-depth: 0
- uses: actions/checkout@v3
with:
path: public
ref: main
repository: faster-cpython/benchmarking-public
token: ${{ secrets.BENCHMARK_MIRROR }}
- name: Mirror
run: |
cd public
git remote add upstream $PWD/../private
git fetch upstream
git reset --hard upstream/main
- name: Push
if: ${{ !inputs.dry_run }}
run: |
cd public
git push origin main
32 changes: 32 additions & 0 deletions .github/workflows/benchrunner-aws.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Deploy benchrunner to AWS

on:
push:
branches:
- main
workflow_dispatch: {}

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Check out the repository to the runner
uses: actions/checkout@v4

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2

- name: Set Up Terraform
uses: hashicorp/setup-terraform@v2

- name: Start EC2 instance Using Terraform Configuration
run: |
cd terraform
terraform init
terraform apply -auto-approve

17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,20 @@ pyembed_includes
.cache/
build_cinderx_venv/
CinderX/build/

# Ignore Terraform state files, directories, and logs
*.tfstate
*.tfstate.*
*.terraform
*.terraform.*
.terraform/
terraform.log

# Ignore sensitive or auto-generated files
*.pem
*.key
*.tfvars
*.tfvars.*

# Ignore venv directory
venv/
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git+https://github.com/faster-cpython/bench_runner@v0.2.2#egg=bench_runner
3 changes: 3 additions & 0 deletions terraform/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo "This is a test file was created during the instance initialization." > test.txt
94 changes: 94 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16"
}
}

required_version = ">= 1.2.0"
}

provider "aws" {
region = "us-west-2"
}

resource "aws_vpc" "bench_run" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true

tags = {
Name = "bench_run"
}
}

resource "aws_eip" "bench_run_ip" {
instance = aws_instance.bench_runner.id
vpc = true
}

resource "aws_internet_gateway" "bench_run_gw" {
vpc_id = aws_vpc.bench_run.id

tags = {
Name = "bench_run_gw"
}
}

resource "aws_subnet" "subnet1" {
cidr_block = cidrsubnet(aws_vpc.bench_run.cidr_block, 3, 1)
vpc_id = aws_vpc.bench_run.id
availability_zone = "us-west-2a"
}

resource "aws_route_table" "bench_run_route_table" {
vpc_id = aws_vpc.bench_run.id

route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.bench_run_gw.id
}

tags = {
Name = "bench_run_route_table"
}
}

resource "aws_route_table_association" "subnet_association" {
subnet_id = aws_subnet.subnet1.id
route_table_id = aws_route_table.bench_run_route_table.id
}

resource "aws_security_group" "ingress_all" {
name = "allow_all_sg"
vpc_id = aws_vpc.bench_run.id

ingress {
cidr_blocks = ["0.0.0.0/0"]
from_port = 22
to_port = 22
protocol = "tcp"
}

egress {
cidr_blocks = ["0.0.0.0/0"]
from_port = 0
to_port = 0
protocol = "-1"
}
}

resource "aws_instance" "bench_runner" {
ami = "ami-830c94e3"
instance_type = "t2.micro"
key_name = "bench-runner"
vpc_security_group_ids = ["${aws_security_group.ingress_all.id}"]
subnet_id = aws_subnet.subnet1.id
user_data = file("init.sh")

tags = {
Name = "BenchmarkingEC2Runner"
}
}