enforce running multi-input on the proxy

Now, multi-input storlet(with 'X-Storlet-Extra-Resources') runs
on object-server side.
but it causes that specified extra resources get ignored,
as current object-server does not support X-Storlet-Extra-Resources.

This patch forces multi-input storlet to run on proxy-server side.

Change-Id: I7fc2e72c3f39b5461f502ef314d0aba5686aa3f7
Closes-Bug: #1657044
This commit is contained in:
Akihito Takai 2017-01-17 19:38:41 +09:00 committed by Takashi Kajinami
parent 1e5bc9afb7
commit 49fce5b942
3 changed files with 28 additions and 5 deletions

View File

@ -307,7 +307,8 @@ class StorletBaseHandler(object):
r = self.request.headers['X-Storlet-Range']
return len(Range(r).ranges) > 1
def _has_run_on_proxy_header(self):
@property
def has_run_on_proxy_header(self):
"""
Check whether there is a header mandating storlet execution on proxy
@ -320,9 +321,23 @@ class StorletBaseHandler(object):
return True
return False
@property
def has_extra_resources_header(self):
"""
Check whether the client specifies multi input storlet execution.
If the request contains 'X-Storlet-Extra-Resources' header,
Storlets gathers multiple object data into the place, which
currently should happen in proxy-server.
:return: Whether the request contains X-Storlet-Extra-Resources header
"""
return 'X-Storlet-Extra-Resources' in self.request.headers
@property
def execute_on_proxy(self):
return (self._has_run_on_proxy_header() or
return (self.has_run_on_proxy_header or
self.has_extra_resources_header or
self.storlet_execute_on_proxy)
@property

View File

@ -19,9 +19,10 @@ import unittest
from hashlib import md5
class TestMultiInputStorletOnProxy(StorletJavaFunctionalTest):
class TestMultiInputStorlet(StorletJavaFunctionalTest):
def setUp(self):
super(TestMultiInputStorletOnProxy, self).setUp(
self.additional_headers = {}
super(TestMultiInputStorlet, self).setUp(
storlet_dir='MultiInputStorlet',
storlet_name='multiinputstorlet-1.0.jar',
storlet_main='org.openstack.storlet.multiinput.MultiInputStorlet',
@ -45,6 +46,7 @@ class TestMultiInputStorletOnProxy(StorletJavaFunctionalTest):
'/%s/%s' % (self.container, obj2),
'X-Storlet-Run-On-Proxy': ''
}
headers.update(self.additional_headers)
resp_headers, resp_content = c.get_object(
self.url, self.token, self.container, obj,
@ -72,6 +74,7 @@ class TestMultiInputStorletOnProxy(StorletJavaFunctionalTest):
'X-Storlet-Extra-Resources':
'/%s/%s' % (self.container, obj2),
}
headers.update(self.additional_headers)
expected_string = '0123456789abcdefghijklmnopqr'
etag = c.put_object(
@ -90,5 +93,11 @@ class TestMultiInputStorletOnProxy(StorletJavaFunctionalTest):
self.assertEqual('value2', resp_headers['x-object-meta-key2'])
class TestMultiInputStorletOnProxy(TestMultiInputStorlet):
def setUp(self):
super(TestMultiInputStorletOnProxy, self).setUp()
self.additional_headers = {'X-Storlet-Run-On-Proxy': ''}
if __name__ == '__main__':
unittest.main()

View File

@ -182,7 +182,6 @@ class TestStorletMiddlewareProxy(BaseTestStorletMiddleware):
with storlet_enabled():
headers = {'X-Run-Storlet': 'Storlet-1.0.jar',
'X-Storlet-Run-On-Proxy': '',
'X-Storlet-Extra-Resources': '/c2/o2'}
resp = self.get_request_response(target, 'GET', headers=headers)
self.assertEqual('200 OK', resp.status)