From f81c4737301120af1613f61594da672c2487a57e Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 21 Apr 2010 12:41:15 +0200 Subject: [PATCH] Add RPC call to send SIGTERM to import/export daemon This will be used to stop the daemon without doing complete cleanup (yet). Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- daemons/ganeti-noded | 7 +++++++ lib/backend.py | 16 ++++++++++++++++ lib/rpc.py | 13 +++++++++++++ 3 files changed, 36 insertions(+) diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index 28c6edaad..fe6a0df83 100755 --- a/daemons/ganeti-noded +++ b/daemons/ganeti-noded @@ -890,6 +890,13 @@ class NodeHttpServer(http.server.HttpServer): """ return backend.GetImportExportStatus(params[0]) + @staticmethod + def perspective_impexp_abort(params): + """Aborts an import or export. + + """ + return backend.AbortImportExport(params[0]) + @staticmethod def perspective_impexp_cleanup(params): """Cleans up after an import or export. diff --git a/lib/backend.py b/lib/backend.py index 69ac800c9..897b557cb 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -47,6 +47,7 @@ import logging import tempfile import zlib import base64 +import signal from ganeti import errors from ganeti import utils @@ -2845,6 +2846,21 @@ def GetImportExportStatus(names): return result +def AbortImportExport(name): + """Sends SIGTERM to a running import/export daemon. + + """ + logging.info("Abort import/export %s", name) + + status_dir = utils.PathJoin(constants.IMPORT_EXPORT_DIR, name) + pid = utils.ReadLockedPidFile(utils.PathJoin(status_dir, _IES_PID_FILE)) + + if pid: + logging.info("Import/export %s is running with PID %s, sending SIGTERM", + name, pid) + os.kill(pid, signal.SIGTERM) + + def CleanupImportExport(name): """Cleanup after an import or export. diff --git a/lib/rpc.py b/lib/rpc.py index 23df3ec3f..b7fff3d33 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -1288,6 +1288,19 @@ class RpcRunner(object): return result + def call_impexp_abort(self, node, name): + """Aborts an import or export. + + This is a single-node call. + + @type node: string + @param node: Node name + @type name: string + @param name: Import/export name + + """ + return self._SingleNodeCall(node, "impexp_abort", [name]) + def call_impexp_cleanup(self, node, name): """Cleans up after an import or export. -- GitLab