core/transaction: drop job that has unfulfilled required (Requires, BindsTo) dependencies

Resolves: #11338
This commit is contained in:
Michal Sekletar
2023-06-01 06:45:51 +09:00
committed by Yu Watanabe
parent d9689a35f9
commit 89e9df12b3
+10 -3
View File
@@ -1003,7 +1003,7 @@ int transaction_add_job_and_dependencies(
r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, false, false, ignore_order, e);
if (r < 0) {
if (r != -EBADR) /* job type not applicable */
return r;
goto fail;
sd_bus_error_free(e);
}
@@ -1025,7 +1025,7 @@ int transaction_add_job_and_dependencies(
r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, true, false, false, ignore_order, e);
if (r < 0) {
if (r != -EBADR) /* job type not applicable */
return r;
goto fail;
sd_bus_error_free(e);
}
@@ -1035,7 +1035,7 @@ int transaction_add_job_and_dependencies(
r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, true, true, false, ignore_order, e);
if (r < 0) {
if (r != -EBADR) /* job type not applicable */
return r;
goto fail;
sd_bus_error_free(e);
}
@@ -1102,6 +1102,13 @@ int transaction_add_job_and_dependencies(
}
return 0;
fail:
/* Recursive call failed to add required jobs so let's drop top level job as well. */
log_unit_debug_errno(unit, r, "Cannot add dependency job to transaction, deleting job %s/%s again: %s",
unit->id, job_type_to_string(type), bus_error_message(e, r));
transaction_delete_job(tr, ret, /* delete_dependencies= */ false);
return r;
}
static bool shall_stop_on_isolate(Transaction *tr, Unit *u) {