import: two minor debugability improvements (#42081)
TEST-13-NSPAWN.machined occasionally fails when importing, and it's hard to debug, so try to make it better. eg: https://github.com/systemd/systemd/actions/runs/25800895182/job/75790334230?pr=42071
This commit is contained in:
@@ -392,13 +392,14 @@ int import_remove_tree(const char *path, int *userns_fd, ImportFlags flags) {
|
||||
assert(path);
|
||||
assert(userns_fd);
|
||||
|
||||
r = import_make_foreign_userns(userns_fd);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* Try the userns dance first, to remove foreign UID range owned trees */
|
||||
if (FLAGS_SET(flags, IMPORT_FOREIGN_UID))
|
||||
if (FLAGS_SET(flags, IMPORT_FOREIGN_UID)) {
|
||||
r = import_make_foreign_userns(userns_fd);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) remove_tree_foreign(path, *userns_fd);
|
||||
}
|
||||
|
||||
r = rm_rf(path, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME|REMOVE_MISSING_OK|REMOVE_CHMOD);
|
||||
if (r < 0)
|
||||
|
||||
@@ -368,6 +368,17 @@ static int tar_import_process(TarImport *i) {
|
||||
r = decompressor_push(i->compress, i->buffer, i->buffer_size, tar_import_write, i);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to decode and write: %m");
|
||||
|
||||
/* Try to check the actual exit code from the child process, to make debugging easier */
|
||||
if (r == -EPIPE && pidref_is_set(&i->tar_pid)) {
|
||||
int q = pidref_wait_for_terminate_and_check("tar", &i->tar_pid, WAIT_LOG);
|
||||
pidref_done(&i->tar_pid);
|
||||
if (q < 0)
|
||||
r = q;
|
||||
else if (q != EXIT_SUCCESS)
|
||||
r = -EPROTO;
|
||||
}
|
||||
|
||||
goto finish;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user