2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 11:01:09 +00:00

For skipauth clients, allow a 'shutdown' verb

To facilitate a clean coordinated shutdown, create a verb so that a termination can be done
and know when it is completed.  Only allow for the 'special' case of 'skipauth', where unix domain
socket connection is in hand and only root or the service owner can access.
This commit is contained in:
Jarrod Johnon 2014-10-07 11:14:22 -04:00
parent a907da0532
commit 5012c9e401
3 changed files with 11 additions and 0 deletions

View File

@ -108,6 +108,8 @@ def authorize(name, element, tenant=False, operation='create',
and the relevant ConfigManager object for the context of the
request.
"""
if operation not in ('create', 'start', 'update', 'retrieve', 'delete'):
return None
user, tenant = _get_usertenant(name, tenant)
if tenant is not None and not configmanager.is_tenant(tenant):
return None

View File

@ -1123,6 +1123,13 @@ class ConfigManager(object):
except OSError:
pass
@classmethod
def shutdown(cls):
cls._bg_sync_to_file()
if cls._cfgwriter is not None:
cls._cfgwriter.join()
sys.exit(0)
@classmethod
def _bg_sync_to_file(cls):
with cls._syncstate:

View File

@ -184,6 +184,8 @@ def process_request(connection, request, cfm, authdata, authname, skipauth):
consession.destroy()
return
consession.write(data)
elif operation == 'shutdown':
configmanager.ConfigManager.shutdown()
else:
hdlr = pluginapi.handle_path(path, operation, cfm, params)
except exc.NotFoundException: