Skip to content

Commit

Permalink
fix NoSuchBucket error (#577)
Browse files Browse the repository at this point in the history
* use the same helper function as the other tests

* more logging on server side

* we need read access to check if bucket exists

* creating bucket if it does not exist
  • Loading branch information
wilko77 committed Jun 22, 2020
1 parent 084fef2 commit 23d582d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
8 changes: 7 additions & 1 deletion backend/entityservice/views/objectstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import opentracing
from flask import request
from minio.credentials import AssumeRoleProvider, Credentials
from minio.error import ResponseError

from entityservice.settings import Config as config
import entityservice.database as db
from entityservice.object_store import connect_to_upload_object_store
from entityservice.object_store import connect_to_upload_object_store, connect_to_object_store, create_bucket
from entityservice.utils import safe_fail_request, object_store_upload_path
from entityservice.views import bind_log_and_span, precheck_upload_token
from entityservice.views.serialization import ObjectStoreCredentials
Expand Down Expand Up @@ -67,6 +68,11 @@ def authorize_external_upload(project_id):

log.info("Retrieved temporary credentials")

client = connect_to_object_store()
if not client.bucket_exists(bucket_name):
log.warning(f'bucket "{bucket_name}" does not exist! Trying to create now...')
create_bucket(client, bucket_name)

credentials_json = ObjectStoreCredentials().dump(credential_values)
log.debug("Temp credentials", **credentials_json)

Expand Down
21 changes: 1 addition & 20 deletions e2etests/tests/test_project_uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,7 @@ def test_project_single_party_data_uploaded_encodings_and_blocks_format(requests

def test_project_upload_external_encodings(requests, a_project, binary_test_file_path):

r = requests.get(
url + 'projects/{}/authorize-external-upload'.format(a_project['project_id']),
headers={'Authorization': a_project['update_tokens'][0]},
)
assert r.status_code == 201
upload_response = r.json()

credentials = upload_response['credentials']
upload_info = upload_response['upload']

# Use Minio python client to upload data

mc = Minio(
minio_host or upload_info['endpoint'],
access_key=credentials['AccessKeyId'],
secret_key=credentials['SecretAccessKey'],
session_token=credentials['SessionToken'],
region='us-east-1',
secure=upload_info['secure']
)
mc, upload_info = get_temp_upload_client(a_project, requests, a_project['update_tokens'][0])

etag = mc.fput_object(
upload_info['bucket'],
Expand Down

0 comments on commit 23d582d

Please sign in to comment.