From 0a0e1302c200d31ef856e2e84dc45ab0bcb64cf4 Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Fri, 5 Apr 2019 20:42:48 -0400 Subject: [PATCH] MariaDB: Catch when mysqld process has exited immediately This PS updates the logic terminating mysqld to catch when it has exited prior to waiting for it to do so. Change-Id: Iefea71b7c49e5cfc01bdf8b80644990d78f2e910 Signed-off-by: Pete Birley --- mariadb/templates/bin/_start.py.tpl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/mariadb/templates/bin/_start.py.tpl b/mariadb/templates/bin/_start.py.tpl index ee8fdca8d7..0620697901 100644 --- a/mariadb/templates/bin/_start.py.tpl +++ b/mariadb/templates/bin/_start.py.tpl @@ -14,14 +14,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os -import sys -import re + +import errno import logging +import os import select import signal import subprocess import socket +import sys import tempfile import time import threading @@ -182,7 +183,14 @@ def stop_mysqld(): if is_pid_mysqld(mysqld_pid): logger.info("pid from pidfile is mysqld") os.kill(mysqld_pid, 15) - pid, status = os.waitpid(mysqld_pid, 0) + try: + pid, status = os.waitpid(mysqld_pid, 0) + except OSError as err: + # The process has already exited + if err.errno == errno.ECHILD: + return + else: + raise logger.info("Mysqld stopped: pid = {0}, " "exit status = {1}".format(pid, status)) else: @@ -282,7 +290,7 @@ def safe_update_configmap(configmap_dict, configmap_patch): configmap_patch -- a dict containign the patch """ logger.debug("Safe Patching configmap") - #NOTE(portdirect): Explictly set the resource version we are patching to + # NOTE(portdirect): Explictly set the resource version we are patching to # ensure nothing else has modified the confimap since we read it. configmap_patch['metadata']['resourceVersion'] = configmap_dict[ 'metadata']['resource_version']