Merge "Improve logs and case-sensitive on k8s-coredump"
This commit is contained in:
@@ -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")
|
||||
|
@@ -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}')
|
||||
splitted_path = string_core_pattern.split("/")
|
||||
string_core_pattern = splitted_path[-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
|
||||
|
||||
splitted_path[-1] = processed_string
|
||||
full_path_processed = "/".join(splitted_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
|
||||
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user