Skip to content

Commit

Permalink
Correctly retrieve s3 attachment
Browse files Browse the repository at this point in the history
This commit fixes an issue if s3 path did not exist for some reason ( got deleted or was an old path ), retrieving s3 attachments would error out as the path would not exist. Secondly, if the path does not exist but has been configured - we create the path before starting the s3 service.
  • Loading branch information
sonicaj committed May 17, 2021
1 parent 0242720 commit c40a4d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Expand Up @@ -44,11 +44,16 @@ def render_certificates(s3, middleware):

def configure_minio_sys_dir(s3):
storage_path = s3['storage_path']
# Create storage path if it does not exist
os.makedirs(storage_path, exist_ok=True)
minio_dir = os.path.join(storage_path, '.minio.sys')
shutil.rmtree(minio_dir, ignore_errors=True)


def render(service, middleware):
s3 = middleware.call_sync('s3.config')
if not s3['storage_path']:
return

configure_minio_sys_dir(s3)
render_certificates(s3, middleware)
2 changes: 1 addition & 1 deletion src/middlewared/middlewared/plugins/s3_/attachments.py
Expand Up @@ -13,7 +13,7 @@ async def query(self, path, enabled, options=None):
results = []

s3_config = await self.middleware.call('s3.config')
if not s3_config['storage_path']:
if not s3_config['storage_path'] or not os.path.exists(s3_config['storage_path']):
return results
else:
s3_ds = await self.middleware.call('zfs.dataset.path_to_dataset', s3_config['storage_path'])
Expand Down

0 comments on commit c40a4d5

Please sign in to comment.