From 675e517c5100a6b2905f9edb287758f325e572dd Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Sat, 22 Jul 2023 22:02:46 +0530 Subject: [PATCH] cloud: Add storage_bucket to cloud functions env --- cloud | 14 ++++++++++---- main.py | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cloud b/cloud index bdab5f19..27a158fd 100755 --- a/cloud +++ b/cloud @@ -1323,6 +1323,7 @@ function cloud_functions_env() { smtp_to_addrs smtp_password_secret \ smtp_topic smtp_subscription \ pgpass_secret \ + cache_bucket_name \ database \ clean_test_databases \ empty_test_databases \ @@ -1353,6 +1354,9 @@ function cloud_functions_env() { if [ -n "$extra_cc" ]; then env[KCIDB_EXTRA_CC]="$extra_cc" fi + if [ -n "$cache_bucket_name" ]; then + env[KCIDB_CACHE_BUCKET_NAME]="$cache_bucket_name" + fi if [ -n "$smtp_to_addrs" ]; then env[KCIDB_SMTP_TO_ADDRS]="$smtp_to_addrs" fi @@ -1764,7 +1768,7 @@ function execute_command() { eval "declare -a argv=($argv)" declare -r load_queue_trigger_topic="${prefix}load_queue_trigger" - declare -r storage_bucket="${project}_${prefix}cache" + declare -r cache_bucket_name="${project}_${prefix}cache" declare -r pick_notifications_trigger_topic="${prefix}pick_notifications_trigger" declare -r updated_urls_topic="${prefix}updated_urls" declare -r new_topic="${prefix}new" @@ -1891,6 +1895,7 @@ function execute_command() { declare -r -a env_args=( --log-level="$log_level" + --cache-bucket-name="$cache_bucket_name" --optimize="$optimize" --heavy-asserts="$heavy_asserts" --new-topic="$new_topic" @@ -1953,7 +1958,7 @@ function execute_command() { --smtp-topic="$smtp_topic" \ --smtp-subscription="$smtp_subscription" sections_run "$sections" firestore_deploy "$project" - sections_run "$sections" storage_deploy "$project" "$storage_bucket" + sections_run "$sections" storage_deploy "$project" "$cache_bucket_name" sections_run "$sections" cloud_functions_deploy \ --project="$project" \ --prefix="$prefix" \ @@ -1985,7 +1990,7 @@ function execute_command() { "$project" "$new_topic" "${submitters[@]}" sections_run "$sections" scheduler_withdraw "$project" "$prefix" sections_run "$sections" cloud_functions_withdraw "$project" "$prefix" - sections_run "$sections" storage_withdraw "$storage_bucket" + sections_run "$sections" storage_withdraw "$cache_bucket_name" sections_run "$sections" firestore_withdraw \ "$project" "$spool_collection_path" sections_run "$sections" pubsub_withdraw \ @@ -2267,7 +2272,7 @@ function execute() { fi if [[ $command == @(deploy|env|shell) ]]; then getopt_longopts+=",extra-cc:,smtp-to-addrs:" - getopt_longopts+=",log-level:,optimize:,heavy-asserts,mute-updates" + getopt_longopts+=",log-level:,optimize:,cache-bucket-name:,heavy-asserts,mute-updates" if [[ $command == env ]]; then getopt_longopts+=",format:" fi @@ -2299,6 +2304,7 @@ function execute() { declare test="false" declare log_level="INFO" declare optimize="" + declare cache_bucket_name="" declare heavy_asserts="false" declare updated_publish="true" declare -a submitters=() diff --git a/main.py b/main.py index 319d01f8..f98d636f 100644 --- a/main.py +++ b/main.py @@ -71,6 +71,8 @@ # The publisher object for the queue with patterns matching objects updated by # loading submissions. _UPDATED_QUEUE_PUBLISHER = None +# KCIDB cache storage bucket name +CACHE_BUCKET_NAME = os.environ.get("KCIDB_CACHE_BUCKET_NAME") def get_smtp_publisher(): @@ -356,7 +358,7 @@ def get_cache_client(): global _CACHE_CLIENT if _CACHE_CLIENT is None: _CACHE_CLIENT = kcidb.cache.Client( - "cache_file_storage", 5 * 1024 * 1024 + CACHE_BUCKET_NAME, 5 * 1024 * 1024 ) return _CACHE_CLIENT