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);
}
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);
}
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);
}
}
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) {