Skip to content

Commit

Permalink
Expose parameter to control container autocreate
Browse files Browse the repository at this point in the history
It requires an updated version of OIO-SDS that exposes this parameter,
otherwise parameter will be ignored with a warning.
  • Loading branch information
murlock authored and fvennetier committed May 9, 2018
1 parent 9c78a48 commit 434be2b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions conf/default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ use = egg:oioswift#main
allow_account_management = true
account_autocreate = true

# Manage if container should be created if nonexisting
# It must be true if hashedcontainer, regexcontainer, autocontainer or container_hierarchy middleware is used
sds_autocreate = true

[filter:hashedcontainer]
use = egg:oioswift#hashedcontainer

Expand Down
4 changes: 4 additions & 0 deletions oioswift/proxy/controllers/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ def _link_object(self, req):
return HTTPUnprocessableEntity(request=req)
except (exceptions.ServiceBusy, exceptions.OioTimeout):
raise
except (exceptions.NoSuchContainer, exceptions.NotFound):
raise HTTPNotFound(request=req)
except exceptions.ClientException as err:
# 481 = CODE_POLICY_NOT_SATISFIABLE
if err.status == 481:
Expand Down Expand Up @@ -496,6 +498,8 @@ def _store_object(self, req, data_source, headers):
return HTTPUnprocessableEntity(request=req)
except (exceptions.ServiceBusy, exceptions.OioTimeout):
raise
except (exceptions.NoSuchContainer, exceptions.NotFound):
raise HTTPNotFound(request=req)
except exceptions.ClientException as err:
# 481 = CODE_POLICY_NOT_SATISFIABLE
if err.status == 481:
Expand Down
11 changes: 11 additions & 0 deletions oioswift/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from oioswift.proxy.controllers.obj import ObjectControllerRouter
from oio import ObjectStorageApi
from swift.proxy.server import Application as SwiftApplication
from swift.common.utils import config_true_value
import swift.common.utils
import swift.proxy.server

Expand Down Expand Up @@ -80,6 +81,16 @@ def __init__(self, conf, memcache=None, logger=None, account_ring=None,
sds_conf.pop('namespace') # removed to avoid unpacking conflict
# Loaded by ObjectStorageApi if None
sds_proxy_url = sds_conf.pop('proxy_url', None)
# Fix boolean parameter
if 'autocreate' in sds_conf and not (
hasattr(ObjectStorageApi, 'EXTRA_KEYWORDS') or
'autocreate' in ObjectStorageApi.EXTRA_KEYWORDS):
logger.error('autocreate parameter is not available with current '
'OpenIO SDS')
else:
sds_conf['autocreate'] = config_true_value(
sds_conf.get('autocreate', 'true'))

self.storage = storage or \
ObjectStorageApi(sds_namespace, endpoint=sds_proxy_url, **sds_conf)

Expand Down

0 comments on commit 434be2b

Please sign in to comment.