From f37a05a46d5bbea2407d4d9a57074d9494fcc944 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 31 Oct 2019 10:25:40 -0500 Subject: [PATCH] mgr/ssh: add 'redeploy' operation This will stop, reprovision container, and restart. For most daemons, that means we can - change the container image - refresh the config - refresh the keyring For OSDs, it means we also re-run ceph-volume activate. Signed-off-by: Sage Weil --- src/pybind/mgr/orchestrator.py | 2 +- src/pybind/mgr/orchestrator_cli/module.py | 4 ++-- src/pybind/mgr/ssh/module.py | 18 +++++++++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index 2c8fb02f936..7bd803c062f 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -405,7 +405,7 @@ class Orchestrator(object): * If using service_id, perform the action on a single specific daemon instance. - :param action: one of "start", "stop", "reload", "restart" + :param action: one of "start", "stop", "reload", "restart", "redeploy" :param service_type: e.g. "mds", "rgw", ... :param service_name: name of logical service ("cephfs", "us-east", ...) :param service_id: service daemon instance (usually a short hostname) diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 45bd20330a4..a9f624544f7 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -344,7 +344,7 @@ Usage: return HandleCommandResult(stdout=completion.result_str()) @_write_cli('orchestrator service', - "name=action,type=CephChoices,strings=start|stop|reload|restart " + "name=action,type=CephChoices,strings=start|stop|reload|restart|redeploy " "name=svc_type,type=CephString " "name=svc_name,type=CephString", 'Start, stop or reload an entire service (i.e. all daemons)') @@ -355,7 +355,7 @@ Usage: return HandleCommandResult(stdout=completion.result_str()) @_write_cli('orchestrator service-instance', - "name=action,type=CephChoices,strings=start|stop|reload|restart " + "name=action,type=CephChoices,strings=start|stop|reload|restart|redeploy " "name=svc_type,type=CephString " "name=svc_id,type=CephString", 'Start, stop or reload a specific service instance') diff --git a/src/pybind/mgr/ssh/module.py b/src/pybind/mgr/ssh/module.py index 8cf4c8a1647..1929fbd234e 100644 --- a/src/pybind/mgr/ssh/module.py +++ b/src/pybind/mgr/ssh/module.py @@ -526,6 +526,22 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator): return SSHWriteCompletion(results) def _service_action(self, service_type, service_id, host, action): + if action == 'redeploy': + # recreate the systemd unit and then restart + if service_type == 'mon': + # get mon. key + ret, keyring, err = self.mon_command({ + 'prefix': 'auth get', + 'entity': 'mon.', + }) + else: + ret, keyring, err = self.mon_command({ + 'prefix': 'auth get', + 'entity': '%s.%s' % (service_type, service_id), + }) + return self._create_daemon(service_type, service_id, host, + keyring) + actions = { 'start': ['reset-failed', 'start'], 'stop': ['stop'], @@ -709,7 +725,7 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator): stdin=j) self.log.debug('create_daemon code %s out %s' % (code, out)) - return "Created {} on host '{}'".format(name, host) + return "(Re)deployed {} on host '{}'".format(name, host) except Exception as e: self.log.error("create_daemon({}): error: {}".format(host, e)) -- 2.39.5