Skip to content

Commit

Permalink
Fix domain for GCP bucket, should be domain not prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
dojeda committed Mar 11, 2020
1 parent ac38eec commit d4fca1d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
3 changes: 1 addition & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ 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_GCP_BUCKET_DOMAIN = os.environ.get('QUETZAL_GCP_BUCKET_DOMAIN', None)

# 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.2 # Chart version
version: 0.1.3 # 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
4 changes: 2 additions & 2 deletions helm/quetzal/templates/app-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +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_GCP_BUCKET_DOMAIN
value: {{ .Values.general.bucketDomain | quote }}
- name: QUETZAL_BACKGROUND_JOBS
value: "1"
- name: USE_GUNICORN
Expand Down
4 changes: 2 additions & 2 deletions helm/quetzal/templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +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: QUETZAL_GCP_BUCKET_DOMAIN
value: {{ .Values.general.bucketDomain | quote }}
- name: DB_HOST
value: "db"
- name: DB_PORT
Expand Down
2 changes: 1 addition & 1 deletion helm/quetzal/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ general:
credentialsSecret: sandbox-credentials-secrets
dataBucket: gs://quetzal-sandbox-data
backupBucket: gs://quetzal-sandbox-backups
bucketPrefix:
bucketDomain:

ingress:
tlsSecret: sandbox-tls-secret
Expand Down
12 changes: 7 additions & 5 deletions quetzal/app/api/data/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,16 @@ def init_data_bucket(wid):
raise WorkerException('Workspace was not on the expected state')

# Do the initialization task
# TODO: manage exceptions/errors
# TODO: manage location and storage class through configuration or workspace options
bucket_name = f'{workspace.id}-{workspace.owner.username}-{workspace.name}'
parts = ['ws', str(workspace.id), workspace.owner.username, workspace.name]
sep = '-'
if storage_backend == 'GCP' and current_app.config['QUETZAL_GCP_BUCKET_DOMAIN']:
sep = '.'
parts.append(current_app.config['QUETZAL_GCP_BUCKET_DOMAIN'])
bucket_name = sep.join(parts)

try:
if storage_backend == 'GCP':
prefix = current_app.config['QUETZAL_GCP_BUCKET_PREFIX']
bucket_name = f'{prefix}-{bucket_name}'
# TODO: manage location and storage class through configuration or workspace options
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 d4fca1d

Please sign in to comment.