Skip to content

Commit

Permalink
Add GCP bucket prefix for names on managed domains
Browse files Browse the repository at this point in the history
  • Loading branch information
dojeda committed Mar 11, 2020
1 parent eb4efa0 commit ac38eec
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ class Config:
'gs://quetzal-dev-data'
QUETZAL_GCP_BACKUP_BUCKET = os.environ.get('QUETZAL_GCP_BACKUP_BUCKET') or \
'gs://quetzal-dev-backups'
QUETZAL_GCP_BUCKET_PREFIX = os.environ.get('QUETZAL_GCP_BUCKET_PREFIX') or \
'quetzal-ws'

# Quetzal-file storage configuration
QUETZAL_FILE_DATA_DIR = os.environ.get('QUETZAL_FILE_DATA_DIR') or '/data'
Expand Down
2 changes: 1 addition & 1 deletion helm/quetzal/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: quetzal
version: 0.1.1 # Chart version
version: 0.1.2 # Chart version
appVersion: 0.5.1 # Quetzal app version
description: A RESTful API designed to store data files and manage their associated metadata.
home: https://quetz.al
Expand Down
2 changes: 2 additions & 0 deletions helm/quetzal/templates/app-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ spec:
value: {{ .Values.general.dataBucket | quote }}
- name: QUETZAL_GCP_BACKUP_BUCKET
value: {{ .Values.general.backupBucket | quote }}
- name: QUETZAL_GCP_BUCKET_PREFIX
value: {{ .Values.general.bucketPrefix | quote }}
- name: QUETZAL_BACKGROUND_JOBS
value: "1"
- name: USE_GUNICORN
Expand Down
2 changes: 2 additions & 0 deletions helm/quetzal/templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ spec:
value: {{ .Values.general.dataBucket | quote }}
- name: QUETZAL_GCP_BACKUP_BUCKET
value: {{ .Values.general.backupBucket | quote }}
- name: QUETZAL_GCP_BUCKET_PREFIX
value: {{ .Values.general.bucketPrefix | quote }}
- name: DB_HOST
value: "db"
- name: DB_PORT
Expand Down
1 change: 1 addition & 0 deletions helm/quetzal/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ general:
credentialsSecret: sandbox-credentials-secrets
dataBucket: gs://quetzal-sandbox-data
backupBucket: gs://quetzal-sandbox-backups
bucketPrefix:

ingress:
tlsSecret: sandbox-tls-secret
Expand Down
4 changes: 3 additions & 1 deletion quetzal/app/api/data/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ def init_data_bucket(wid):
# Do the initialization task
# TODO: manage exceptions/errors
# TODO: manage location and storage class through configuration or workspace options
bucket_name = f'quetzal-ws-{workspace.id}-{workspace.owner.username}-{workspace.name}'
bucket_name = f'{workspace.id}-{workspace.owner.username}-{workspace.name}'

try:
if storage_backend == 'GCP':
prefix = current_app.config['QUETZAL_GCP_BUCKET_PREFIX']
bucket_name = f'{prefix}-{bucket_name}'
data_url = _init_gcp_data_bucket(bucket_name)
elif storage_backend == 'file':
data_url = _init_local_data_bucket(bucket_name)
Expand Down

0 comments on commit ac38eec

Please sign in to comment.