From 1e731f8449325e96c173a39e2c0cd305256f49f3 Mon Sep 17 00:00:00 2001 From: Nikolai Kondrashov Date: Mon, 15 Jan 2024 20:19:21 +0200 Subject: [PATCH] cloud: Expose operational and archive databases Introduce the concepts of "operational database" and "archive database". The "operational database" is the one where most operations are done, and which has recent data only, as opposed to "archive database", which keeps all the data, but is either slow or expensive to query. In our case the former is PostgreSQL and the latter is BigQuery. Export the operational database specification to Cloud Functions as "KCIDB_OPERATIONAL_DATABASE", and the archive database as "KCIDB_ARCHIVE_DATABASE". --- cloud | 2 ++ kcidb/cloud/cloud_functions.sh | 6 ++++++ main.py | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/cloud b/cloud index 523af36a..ba1a4f2b 100755 --- a/cloud +++ b/cloud @@ -263,6 +263,8 @@ function execute_command() { --smtp-topic="$smtp_topic" --smtp-subscription="$smtp_subscription" --pgpass-secret="$psql_pgpass_secret" + --op-database="$psql_kcidb_db" + --ar-database="$bigquery_kcidb_db" --database="$database" --clean-test-databases="$clean_test_databases" --empty-test-databases="$empty_test_databases" diff --git a/kcidb/cloud/cloud_functions.sh b/kcidb/cloud/cloud_functions.sh index 391de67f..a2dfe3dc 100644 --- a/kcidb/cloud/cloud_functions.sh +++ b/kcidb/cloud/cloud_functions.sh @@ -24,6 +24,8 @@ declare _CLOUD_FUNCTIONS_SH= # --smtp-to-addrs=ADDRS --smtp-password-secret=NAME # --smtp-topic=NAME --smtp-subscription=NAME # --pgpass-secret=NAME +# --op-database=SPEC +# --ar-database=SPEC # --database=SPEC # --clean-test-databases=SPEC_LIST # --empty-test-databases=SPEC_LIST @@ -44,6 +46,8 @@ function cloud_functions_env() { pgpass_secret \ cache_bucket_name \ cache_redirector_url \ + op_database \ + ar_database \ database \ clean_test_databases \ empty_test_databases \ @@ -59,6 +63,8 @@ function cloud_functions_env() { [KCIDB_LOAD_QUEUE_OBJ_MAX]="8192" [KCIDB_LOAD_QUEUE_TIMEOUT_SEC]="30" [KCIDB_PGPASS_SECRET]="$pgpass_secret" + [KCIDB_OPERATIONAL_DATABASE]="$op_database" + [KCIDB_ARCHIVE_DATABASE]="$ar_database" [KCIDB_DATABASE]="$database" [KCIDB_DATABASE_LOAD_PERIOD_SEC]="180" [KCIDB_CLEAN_TEST_DATABASES]="$clean_test_databases" diff --git a/main.py b/main.py index 78512cda..6ce83f73 100644 --- a/main.py +++ b/main.py @@ -28,6 +28,12 @@ # Maximum time for pulling maximum amount of submissions from the queue LOAD_QUEUE_TIMEOUT_SEC = float(os.environ["KCIDB_LOAD_QUEUE_TIMEOUT_SEC"]) +# The specification for the operational database (a part of DATABASE spec) +OPERATIONAL_DATABASE = os.environ["KCIDB_OPERATIONAL_DATABASE"] + +# The specification for the archive database (a part of DATABASE spec) +ARCHIVE_DATABASE = os.environ["KCIDB_ARCHIVE_DATABASE"] + # The specification for the database submissions should be loaded into DATABASE = os.environ["KCIDB_DATABASE"]