Add core dump extraction from container in docker plugin - #124
Add core dump extraction from container in docker plugin#124Tejaswini-Janjale25 wants to merge 2 commits into
Conversation
1bdd4a4 to
6f63983
Compare
| "--extract-core", | ||
| action="store_true", | ||
| default=False, | ||
| help="Extract core dump files from the container before teardown.", |
There was a problem hiding this comment.
message can be improved e.g. help="Directory where extracted core dumps are stored.
There was a problem hiding this comment.
I have updated the message
| return | ||
|
|
||
| for remote_path in core_paths: | ||
| local_path = os.path.join(output_base, remote_path.lstrip("/")) |
There was a problem hiding this comment.
Should we check Path.is_dir() before attempting extraction?
There was a problem hiding this comment.
Added a check — if the given output directory isn't a valid directory, we log a warning and skip extraction instead of trying to download into an invalid path.
6f63983 to
88da2c0
Compare
46b4e8a to
16a96e2
Compare
draganbjedov
left a comment
There was a problem hiding this comment.
Using core is bad. It does not clearly states what is core. Instead core-dumps
| ) | ||
| parser.addoption("--qemu-image", action="store", help="Path to a QEMU image") | ||
| parser.addoption( | ||
| "--extract-core", |
There was a problem hiding this comment.
| "--extract-core", | |
| "--extract-core-dump", |
| help="Copy core dump files from the QEMU target to the host before teardown.", | ||
| ) | ||
| parser.addoption( | ||
| "--core-output-dir", |
There was a problem hiding this comment.
| "--core-output-dir", | |
| "--core-dump-output-dir", |
| "--core-output-dir", | ||
| default=os.path.join( | ||
| os.environ.get("TEST_UNDECLARED_OUTPUTS_DIR", "/tmp"), | ||
| "cores", |
There was a problem hiding this comment.
| "cores", | |
| "coredumps", |
|
|
||
| def _extract_cores_from_qemu(target, output_base): | ||
| """Extract core dump files from a QEMU (QNX) target via SSH/SFTP.""" | ||
| logger.info(f"Attempting core extraction to {output_base}") |
There was a problem hiding this comment.
| logger.info(f"Attempting core extraction to {output_base}") | |
| logger.info(f"Attempting core dumps extraction to {output_base}") |
| " && (ls -1 /opt/*/*.core /opt/*/*.core.gz /root/*.core /root/*.core.gz /data/*/*.core /data/*/*.core.gz 2>/dev/null || true)" | ||
| ) | ||
|
|
||
| core_paths = [line.strip() for line in output.decode().splitlines() if line.strip()] |
There was a problem hiding this comment.
| core_paths = [line.strip() for line in output.decode().splitlines() if line.strip()] | |
| coredumps_paths = [line.strip() for line in output.decode().splitlines() if line.strip()] |
| ) | ||
|
|
||
| config_setting( | ||
| name = "extract_core_enabled", |
There was a problem hiding this comment.
| name = "extract_core_enabled", | |
| name = "extract_core_dump_enabled", |
| # docker plugin falls back to $TEST_UNDECLARED_OUTPUTS_DIR/cores. | ||
| # Set with: bazel test --//score/itf/plugins:core_output_dir=/abs/path | ||
| string_flag( | ||
| name = "core_output_dir", |
There was a problem hiding this comment.
| name = "core_output_dir", | |
| name = "core_dumps_output_dir", |
| "Defaults to $TEST_UNDECLARED_OUTPUTS_DIR/sysroot or /tmp/sysroot.", | ||
| ) | ||
| parser.addoption( | ||
| "--extract-core", |
There was a problem hiding this comment.
| "--extract-core", | |
| "--extract-core-dumps", |
| help="Copy core dump files from the container to the host before teardown.", | ||
| ) | ||
| parser.addoption( | ||
| "--core-output-dir", |
There was a problem hiding this comment.
| "--core-output-dir", | |
| "--core-dumps-output-dir", |
| logger.warning(f"Failed to extract {remote_path}", exc_info=True) | ||
|
|
||
|
|
||
| def _extract_core_from_container(target, output_base): |
There was a problem hiding this comment.
| def _extract_core_from_container(target, output_base): | |
| def _extract_core_dumps_from_container(target, output_base): |
16a96e2 to
8cd262d
Compare
Issue: SWP-130715
8cd262d to
5d81f97
Compare
Add optional core dump extraction from Docker containers on teardown. Generic plugin change, currently used for ITF tests in bigdata.