Skip to content

Commit d372a09

Browse files
committed
ci: Add bigtable cleanup script
Signed-off-by: Danny C <[email protected]>
1 parent c474ccd commit d372a09

File tree

3 files changed

+64
-25
lines changed

3 files changed

+64
-25
lines changed

.github/workflows/nightly-ci.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
cleanup_dynamo_tables:
2828
if: github.repository == 'feast-dev/feast'
2929
runs-on: ubuntu-latest
30-
name: Cleanup dynamo tables which can fail to cleanup
30+
name: Cleanup Bigtable / Dynamo tables which can fail to cleanup
3131
steps:
3232
- uses: actions/checkout@v2
3333
with:
@@ -47,9 +47,20 @@ jobs:
4747
- name: Install Python dependencies
4848
run: |
4949
pip install boto3
50+
pip install google-cloud-bigtable
5051
pip install tqdm
51-
- name: Run DynamoDB cleanup script
52-
run: python infra/scripts/cleanup_dynamo_ci.py
52+
- name: Authenticate to Google Cloud
53+
uses: 'google-github-actions/auth@v1'
54+
with:
55+
credentials_json: '${{ secrets.GCP_SA_KEY }}'
56+
- name: Set up gcloud SDK
57+
uses: google-github-actions/setup-gcloud@v1
58+
with:
59+
project_id: ${{ secrets.GCP_PROJECT_ID }}
60+
- name: Use gcloud CLI
61+
run: gcloud info
62+
- name: Run DynamoDB / Bigtable cleanup script
63+
run: python infra/scripts/cleanup_ci.py
5364
build-docker-image:
5465
if: github.repository == 'feast-dev/feast'
5566
needs: [check_date]

infra/scripts/cleanup_ci.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from time import sleep
2+
import boto3
3+
from tqdm import tqdm
4+
from google.cloud import bigtable
5+
from google.cloud.bigtable import enums
6+
7+
8+
def cleanup_dynamo_ci():
9+
db = boto3.resource("dynamodb")
10+
11+
num_to_delete = 0
12+
all_tables = db.tables.all()
13+
for table in all_tables:
14+
if "integration_test" in table.name:
15+
num_to_delete += 1
16+
with tqdm(total=num_to_delete) as progress:
17+
for table in all_tables:
18+
if "integration_test" in table.name:
19+
table.delete()
20+
progress.update()
21+
print(f"Deleted {num_to_delete} CI DynamoDB tables")
22+
23+
24+
def cleanup_bigtable_ci():
25+
client = bigtable.Client(project="kf-feast", admin=True)
26+
instance = client.instance("feast-integration-tests")
27+
if instance.exists():
28+
print(f"Deleted Bigtable CI instance")
29+
instance.delete()
30+
31+
location_id = "us-central1-f"
32+
serve_nodes = 1
33+
storage_type = enums.StorageType.SSD
34+
cluster = instance.cluster(
35+
"feast-integration-tests-c1",
36+
location_id=location_id,
37+
serve_nodes=serve_nodes,
38+
default_storage_type=storage_type,
39+
)
40+
instance.create(clusters=[cluster])
41+
print(f"Created new Bigtable CI tables")
42+
43+
44+
def main() -> None:
45+
cleanup_dynamo_ci()
46+
cleanup_bigtable_ci()
47+
48+
49+
if __name__ == "__main__":
50+
main()

infra/scripts/cleanup_dynamo_ci.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)