diff --git a/utilities/k8s-coredump/k8s-coredump/k8s_coredump/common/constants.py b/utilities/k8s-coredump/k8s-coredump/k8s_coredump/common/constants.py index 9dffb704..2f503994 100644 --- a/utilities/k8s-coredump/k8s-coredump/k8s_coredump/common/constants.py +++ b/utilities/k8s-coredump/k8s-coredump/k8s_coredump/common/constants.py @@ -14,5 +14,7 @@ LOCALHOST_URL = "https://localhost:10250/pods" SYSTEMD_COREDUMP = "/usr/lib/systemd/systemd-coredump" -logging.basicConfig(filename=K8S_COREDUMP_LOG, level=logging.DEBUG) +logging.basicConfig(filename=K8S_COREDUMP_LOG, level=logging.DEBUG, + format='%(asctime)s %(levelname)s %(message)s', + datefmt='%FT%T') LOG = logging.getLogger("k8s-coredump") diff --git a/utilities/k8s-coredump/k8s-coredump/k8s_coredump/config_functions.py b/utilities/k8s-coredump/k8s-coredump/k8s_coredump/config_functions.py index 69b49a4c..a518d940 100644 --- a/utilities/k8s-coredump/k8s-coredump/k8s_coredump/config_functions.py +++ b/utilities/k8s-coredump/k8s-coredump/k8s_coredump/config_functions.py @@ -66,9 +66,12 @@ def parse_core_pattern(string_core_pattern, **kwargs): str String with all the information replaced accordingly """ - string_core_pattern = string_core_pattern.lower() + LOG.info(f'Full path passed to parse_core_pattern: {string_core_pattern}') + splited_path = string_core_pattern.split("/") + string_core_pattern = splited_path[splited_path.__len__()-1] + LOG.info(f'Parsing core pattern: {string_core_pattern}') - processed_string = string_core_pattern + processed_string = string_core_pattern.lower() processed_string = processed_string.replace('%p', kwargs['pid']) processed_string = processed_string.replace('%u', kwargs['uid']) processed_string = processed_string.replace('%g', kwargs['gid']) @@ -77,7 +80,12 @@ def parse_core_pattern(string_core_pattern, **kwargs): processed_string = processed_string.replace('%h', kwargs['hostname']) processed_string = processed_string.replace('%e', kwargs['comm2']) LOG.info(f'Core pattern parsed to {processed_string}') - return processed_string + + splited_path[splited_path.__len__()-1] = processed_string + full_path_processed = "/".join(splited_path) + LOG.info(f'Full path parsed by parse_core_pattern: {full_path_processed}') + + return full_path_processed def parse_size_config(string_config): @@ -108,6 +116,7 @@ def parse_size_config(string_config): f'(Multiplier of bytes: {size_properties["multiplier"]})') return float(value), size_properties + LOG.info(f'Unable to parse size configuration from: {string_config}') return None diff --git a/utilities/k8s-coredump/k8s-coredump/k8s_coredump/coredump.py b/utilities/k8s-coredump/k8s-coredump/k8s_coredump/coredump.py index ffcaebeb..308451d3 100644 --- a/utilities/k8s-coredump/k8s-coredump/k8s_coredump/coredump.py +++ b/utilities/k8s-coredump/k8s-coredump/k8s_coredump/coredump.py @@ -127,8 +127,8 @@ def CoreDumpHandler(**kwargs): except ValueError as e: LOG.error("Pod defined an invalid core dump annotation: %s" % e) sys.exit(-1) - except KeyError: - LOG.debug("Pod does have annotations defined") + except KeyError as e: + LOG.debug("Pod does have annotations defined but some configuration is missing: %s" % e) pass # not handled by pod, redirect to systemd coredump handler