From 01ccb0b861424a4cfaf6948cd8cd5767f5793a2e Mon Sep 17 00:00:00 2001 From: Tin Lam Date: Tue, 7 Apr 2020 21:56:27 -0500 Subject: [PATCH] fix(mariadb): handle empty grastate value In the scenario where grastate values cannot be found, we will set the configmap to 'None' and log a warning.. This should also prevent a possible type incompatibility issue in error scenario. Change-Id: I0fb08b329a3fb05c65bead5781c84a592ae4c263 Signed-off-by: Tin Lam --- mariadb/templates/bin/_start.py.tpl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mariadb/templates/bin/_start.py.tpl b/mariadb/templates/bin/_start.py.tpl index 783eb87659..cbd8de968a 100644 --- a/mariadb/templates/bin/_start.py.tpl +++ b/mariadb/templates/bin/_start.py.tpl @@ -495,7 +495,7 @@ def get_grastate_val(key): except IndexError: logger.warn("IndexError: Unable to find %s with ':' in grastate.dat", key) - return [] + return None def set_grastate_val(key, value): @@ -530,8 +530,11 @@ def update_grastate_configmap(): grastate['sample_time'] = "{0}Z".format(datetime.utcnow().isoformat("T")) for grastate_key, grastate_value in list(grastate.items()): configmap_key = "{0}.{1}".format(grastate_key, local_hostname) - if get_configmap_value( - type='data', key=configmap_key) != grastate_value: + # NOTE(lamt): In the event the grastate_value is none, treat it as the + # string "None" for processing. + if grastate_value is None: + grastate_value = "None" + if get_configmap_value(type='data', key=configmap_key) != grastate_value: set_configmap_data(key=configmap_key, value=grastate_value)