Skip to content

Commit

Permalink
ci: Add bigtable cleanup script
Browse files Browse the repository at this point in the history
Signed-off-by: Danny C <[email protected]>
  • Loading branch information
adchia authored and EXPEbdodla committed Jun 11, 2024
1 parent 1c571a4 commit be3281e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 25 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/nightly-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
cleanup_dynamo_tables:
if: github.repository == 'feast-dev/feast'
runs-on: ubuntu-latest
name: Cleanup dynamo tables which can fail to cleanup
name: Cleanup Bigtable / Dynamo tables which can fail to cleanup
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -47,9 +47,20 @@ jobs:
- name: Install Python dependencies
run: |
pip install boto3
pip install google-cloud-bigtable
pip install tqdm
- name: Run DynamoDB cleanup script
run: python infra/scripts/cleanup_dynamo_ci.py
- name: Authenticate to Google Cloud
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Set up gcloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Use gcloud CLI
run: gcloud info
- name: Run DynamoDB / Bigtable cleanup script
run: python infra/scripts/cleanup_ci.py
build-docker-image:
if: github.repository == 'feast-dev/feast'
needs: [check_date]
Expand Down
50 changes: 50 additions & 0 deletions infra/scripts/cleanup_ci.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from time import sleep
import boto3
from tqdm import tqdm
from google.cloud import bigtable
from google.cloud.bigtable import enums


def cleanup_dynamo_ci():
db = boto3.resource("dynamodb")

num_to_delete = 0
all_tables = db.tables.all()
for table in all_tables:
if "integration_test" in table.name:
num_to_delete += 1
with tqdm(total=num_to_delete) as progress:
for table in all_tables:
if "integration_test" in table.name:
table.delete()
progress.update()
print(f"Deleted {num_to_delete} CI DynamoDB tables")


def cleanup_bigtable_ci():
client = bigtable.Client(project="kf-feast", admin=True)
instance = client.instance("feast-integration-tests")
if instance.exists():
print(f"Deleted Bigtable CI instance")
instance.delete()

location_id = "us-central1-f"
serve_nodes = 1
storage_type = enums.StorageType.SSD
cluster = instance.cluster(
"feast-integration-tests-c1",
location_id=location_id,
serve_nodes=serve_nodes,
default_storage_type=storage_type,
)
instance.create(clusters=[cluster])
print(f"Created new Bigtable CI tables")


def main() -> None:
cleanup_dynamo_ci()
cleanup_bigtable_ci()


if __name__ == "__main__":
main()
22 changes: 0 additions & 22 deletions infra/scripts/cleanup_dynamo_ci.py

This file was deleted.

0 comments on commit be3281e

Please sign in to comment.