From 5012c9e4018fbe20bf157b5d8a63d6cfbcf360d5 Mon Sep 17 00:00:00 2001 From: Jarrod Johnon Date: Tue, 7 Oct 2014 11:14:22 -0400 Subject: [PATCH] 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. --- confluent_server/confluent/auth.py | 2 ++ confluent_server/confluent/config/configmanager.py | 7 +++++++ confluent_server/confluent/sockapi.py | 2 ++ 3 files changed, 11 insertions(+) diff --git a/confluent_server/confluent/auth.py b/confluent_server/confluent/auth.py index 9c1c7a3d..4c535f78 100644 --- a/confluent_server/confluent/auth.py +++ b/confluent_server/confluent/auth.py @@ -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 diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index 55455735..7594794f 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -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: diff --git a/confluent_server/confluent/sockapi.py b/confluent_server/confluent/sockapi.py index 9a291dd7..f8b31cc4 100644 --- a/confluent_server/confluent/sockapi.py +++ b/confluent_server/confluent/sockapi.py @@ -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: