This patch adds a basic sanity check of the system configuration. For
now, we only check if the coredump files are created with a non-default
name. Later on, more checks can be added.
Signed-off-by: Felix Moessbauer <
felix.mo...@siemens.com>
---
This check should help to identify hard to debug issues around
coredumps: During the build, often coredumps are written as part
of the toolings feature probing (e.g. by CMake or autotools). These
are created in the current folder and might conflict with equally
named files or directories. As this unfortunately is the default config
of Linux, we warn about it and give a hint on how to change it.
kas/libcmds.py | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/kas/libcmds.py b/kas/libcmds.py
index 3c194da..2b92f23 100644
--- a/kas/libcmds.py
+++ b/kas/libcmds.py
@@ -29,6 +29,7 @@ import shutil
import os
import pprint
import configparser
+from pathlib import Path
from .libkas import (ssh_cleanup_agent, ssh_setup_agent, ssh_no_host_key_check,
get_build_environ, repos_fetch, repos_apply_patches)
from .includehandler import IncludeException
@@ -200,6 +201,32 @@ class SetupHome(Command):
shutil.copy(os.environ['AWS_WEB_IDENTITY_TOKEN_FILE'],
webid_token_file)
+ def _check_coredump_is_named(self):
+ """
+ The linux default name for coredumps is just 'core'. This likely
+ conflicts with files or directories from the image build which
+ are also named core, leading to hard to debug errors.
+ """
+ sysfs_kernel = Path('/proc/sys/kernel')
+ if not all([os.path.exists(sysfs_kernel / entry)
+ for entry in ['core_pattern', 'core_uses_pid']]):
+ logging.warning('[system check] could not check coredump pattern')
+ return
+
+ with open(sysfs_kernel / 'core_pattern', 'r') as f:
+ CORE_PATTERN = f.readline().strip()
+ with open(sysfs_kernel / 'core_uses_pid', 'r') as f:
+ CORE_USES_PID = int(f.readline().strip())
+ if CORE_PATTERN == 'core' and CORE_USES_PID == 0:
+ logging.warning(
+ '[system check] your system uses the default coredump '
+ 'name \'core\'. This may conflict with equally named files. '
+ 'See \'man 5 core\' on how to change this.')
+ return
+
+ def _check_environment(self):
+ self._check_coredump_is_named()
+
def execute(self, ctx):
if os.environ.get('NETRC_FILE', False):
shutil.copy(os.environ['NETRC_FILE'],
@@ -225,6 +252,7 @@ class SetupHome(Command):
+ os.environ.get('GIT_CREDENTIAL_USEHTTPPATH')
+ '\n')
+ self._check_environment()
self._setup_aws_creds()
ctx.environ['HOME'] = self.tmpdirname
--
2.39.2