]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/transaction: drop job that has unfulfilled required (Requires, BindsTo) dependencies
authorMichal Sekletar <msekleta@redhat.com>
Tue, 30 May 2023 13:47:16 +0000 (15:47 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 31 May 2023 21:45:51 +0000 (06:45 +0900)
Resolves: #11338

src/core/transaction.c

index 65a00bd9284e4762b0c42aa845a8d68d52fe63b9..39f8f6c96df7b7ab3dc5bc527d99ccc219750a61 100644 (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) {