Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression introduced in v253 that prevents some units to be restarted #26839

Closed
fbuihuu opened this issue Mar 15, 2023 · 4 comments · Fixed by #26844
Closed

Regression introduced in v253 that prevents some units to be restarted #26839

fbuihuu opened this issue Mar 15, 2023 · 4 comments · Fixed by #26844
Labels
bug 🐛 Programming errors, that need preferential fixing pid1 regression ⚠️ A bug in something that used to work correctly and broke through some recent commit
Milestone

Comments

@fbuihuu
Copy link
Contributor

fbuihuu commented Mar 15, 2023

systemd version the issue has been seen with

253

Used distribution

openSUSE Factory

Linux kernel version used

irrelevant

CPU architectures issue was seen on

None

Component

systemd

Expected behaviour you didn't see

Be able to restart auditd.service properly.

Unexpected behaviour you saw

 # systemctl restart auditd.service 
Failed to restart auditd.service: Transaction contains conflicting jobs 'stop' and 'start' for augenrules.service. Probably contradicting requirement dependencies configured.
See system logs and 'systemctl status auditd.service' for details.

Steps to reproduce the problem

# systemctl cat foo.service 
# /etc/systemd/system/foo.service
[Unit]
Requires=bar.service
After=bar.service
PropagatesStopTo=bar.service

[Service]
ExecStartPre=echo start foo
ExecStart=sleep infinity
ExecStopPost=echo stopped foo
# systemctl cat bar.service 
# /etc/systemd/system/bar.service
[Service]
ExecStartPre=echo start bar
ExecStart=sleep infinity
ExecStopPost=echo stopped bar
# systemctl restart foo.service 
Failed to restart foo.service: Transaction contains conflicting jobs 'stop' and 'restart' for foo.service. Probably contradicting requirement dependencies configured.
See system logs and 'systemctl status foo.service' for details.

Note that this test case has been taken from #24068 except that Wants=bar.service was changed into Requires=bar.service.

Additional program output to the terminal or log subsystem illustrating the issue

No response

@fbuihuu fbuihuu added the bug 🐛 Programming errors, that need preferential fixing label Mar 15, 2023
@github-actions github-actions bot added the pid1 label Mar 15, 2023
@fbuihuu fbuihuu added the regression ⚠️ A bug in something that used to work correctly and broke through some recent commit label Mar 15, 2023
@fbuihuu fbuihuu added this to the v254 milestone Mar 15, 2023
@fbuihuu
Copy link
Contributor Author

fbuihuu commented Mar 15, 2023

Regression introduced by commit 017a7ba, hence /Cc @YHNdnzj @poettering

@fbuihuu
Copy link
Contributor Author

fbuihuu commented Mar 15, 2023

Also note that the test case provided in #24068, where foo.service has Wants=bar.service is also broken because bar.service is not restarted when foo.service is:

# systemctl status foo.service bar.service
● foo.service
     Loaded: loaded (/etc/systemd/system/foo.service; static)
     Active: active (running) since Wed 2023-03-15 18:38:26 CET; 2s ago
    Process: 39993 ExecStartPre=echo start foo (code=exited, status=0/SUCCESS)
   Main PID: 39994 (sleep)
      Tasks: 1 (limit: 1040)
        CPU: 2ms
     CGroup: /system.slice/foo.service
             └─39994 sleep infinity

Mar 15 18:38:26 vm-tw-efi systemd[1]: Starting foo.service...
Mar 15 18:38:26 vm-tw-efi echo[39993]: start foo
Mar 15 18:38:26 vm-tw-efi systemd[1]: Started foo.service.

● bar.service
     Loaded: loaded (/etc/systemd/system/bar.service; static)
     Active: active (running) since Wed 2023-03-15 18:38:26 CET; 2s ago
    Process: 39991 ExecStartPre=echo start bar (code=exited, status=0/SUCCESS)
   Main PID: 39992 (sleep)
      Tasks: 1 (limit: 1040)
        CPU: 2ms
     CGroup: /system.slice/bar.service
             └─39992 sleep infinity
# systemctl restart foo.service 
# systemctl status foo.service bar.service
● foo.service
     Loaded: loaded (/etc/systemd/system/foo.service; static)
     Active: active (running) since Wed 2023-03-15 18:38:40 CET; 2s ago
    Process: 40002 ExecStartPre=echo start foo (code=exited, status=0/SUCCESS)
   Main PID: 40003 (sleep)
      Tasks: 1 (limit: 1040)
        CPU: 2ms
     CGroup: /system.slice/foo.service
             └─40003 sleep infinity

○ bar.service
     Loaded: loaded (/etc/systemd/system/bar.service; static)
     Active: inactive (dead) since Wed 2023-03-15 18:38:40 CET; 2s ago
   Duration: 14.148s
    Process: 39991 ExecStartPre=echo start bar (code=exited, status=0/SUCCESS)
    Process: 39992 ExecStart=sleep infinity (code=killed, signal=TERM)
    Process: 40001 ExecStopPost=echo stopped bar (code=exited, status=0/SUCCESS)
   Main PID: 39992 (code=killed, signal=TERM)
        CPU: 4ms

YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Mar 15, 2023
When a restart is being propagated as stop, the unit that
issues propagation could also depend on the unit to be stopped.
This results in a job type conflict and failure to pull in
the dependent unit.

After this commit, we store the units that has a (re)start job
in a set. If they shall get stop propagation, a restart job is
added instead.

Fixes systemd#26839 (bug introduced in 017a7ba)
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Mar 16, 2023
When a restart is being propagated as stop, the unit that
issues propagation could also depend on the unit to be stopped.
This results in a job type conflict and failure to pull in
the dependent unit.

After this commit, we store the units that has a (re)start job
in a set. If they shall get stop propagation, a restart job is
added instead.

Fixes systemd#26839 (bug introduced in 017a7ba)
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Mar 16, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Mar 16, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Mar 17, 2023
When a restart is being propagated as stop, the unit that
issues propagation could also depend on the unit to be stopped.
This results in a job type conflict and failure to pull in
the dependent unit.

After this commit, we store the units that has a (re)start job
in a set. If they shall get stop propagation, a restart job is
added instead.

Fixes systemd#26839 (bug introduced in 017a7ba)
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Mar 17, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Mar 17, 2023
When a restart is being propagated as stop, the unit that
issues propagation could also depend on the unit to be stopped.
This results in a job type conflict and failure to pull in
the dependent unit.

After this commit, we store the units that has a (re)start job
in a set. If they shall get stop propagation, a restart job is
added instead.

Fixes systemd#26839 (bug introduced in 017a7ba)
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Mar 17, 2023
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue Mar 17, 2023
https://build.opensuse.org/request/show/1072270
by user fbui + dimstar_suse
- Add 5002-systemctl-explicitly-cast-the-constants-to-uint64_t.patch (bsc#1209305)
  Added temporarily until it's merged in either the stable v253 branch or in the
  SUSE git repo.

- Add 5001-Revert-core-propagate-stop-too-if-restart-is-issued.patch until
  systemd/systemd#26839 is fixed properly.

- testsuite: mtools is required by TEST-58-REPART

- testsuite: swtpm and tpm2.0-tools are needed by TEST-70-TPM2

- Add 5000-core-manager-run-generators-directly-when-we-are-in-.patch, a
  temporary workaround until dracutdevs/dracut#2211 is
  fixed in dracut.

- Upgrade to v253.1 (commit 6c327d74aa0d350482e82a247d7018559699798d)
  See https://github.com/openSUSE/systemd/blob/SUSE/v253/NEWS for details.
  * Rebased 0001-conf-parser-introduce-e
fbuihuu added a commit to fbuihuu/systemd that referenced this issue Mar 22, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Mar 22, 2023
When a restart is being propagated as stop, the unit that
issues propagation could also depend on the unit to be stopped.
This results in a job type conflict and failure to pull in
the dependent unit.

After this commit, we store the units that has a (re)start job
in a set. If they shall get stop propagation, a restart job is
added instead.

Fixes systemd#26839 (bug introduced in 017a7ba)
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Mar 22, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue May 17, 2023
…re)start job

Follow-up for 017a7ba

Before this commit, when a unit that is restarting propagates stop
to other units, it can also depend on them, which results in
job type conflict and thus failure to pull in the dependencies.

After this commit, we store the units that has a (re)start job
in a set. If they shall get stop propagation, a restart job is
added instead.

Fixes systemd#26839
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue May 17, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jun 1, 2023
…re)start job

Follow-up for 017a7ba

Before this commit, when a unit that is restarting propagates stop
to other units, it can also depend on them, which results in
job type conflict and thus failure to pull in the dependencies.

After this commit, we store the units that has a (re)start job
in a set. If they shall get stop propagation, a restart job is
added instead.

Fixes systemd#26839
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jun 1, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jun 1, 2023
@poettering
Copy link
Member

hmpf, honestly the unit in question is kinda stupid. it encodes a contradiction because it pulls the rug below itself while it is already going down. i am not convinced this really is an issue. And the failure on restart is to be expected then: the Requires= encodes the outcome after a restart is that the depending unit is up, and the PropagatesStopTo= encodes the outcome is down. So what now? the engine correctly detects this and complains.

I am kinda tempted to just say, "don't do that" and move on.

I mean, i understand that older versions of systemd didn't refuse such transactions, but i'd claim thta was a bug we have fixed, and it doesn't constitute a bug we now intrdouced.

@fbuihuu
Copy link
Contributor Author

fbuihuu commented Jun 21, 2023

Well this is still what auditd.service does and I'm not sure you can blame them to assume that restart is strictly equivalent to stop + start, which is how restart has always been described AFAIK.

My guess is that it's been done this way to automatically restart augenrules.service when auditd.service is.

YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 3, 2023
Follow-up for 017a7ba

Before this commit, when a unit that is restarting propagates stop
to other units, it can also depend on them, which results in
job type conflict and thus failure to pull in the dependencies.

So, let's introduce a new dependency atom UNIT_ATOM_PROPAGATE_STOP_GRACEFUL,
and use it for PropagatesStopTo=. It will enqueue a restart job if
there's already a start job, which meets the ultimate goal and avoids
job type conflict.

Fixes systemd#26839
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 3, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 3, 2023
Follow-up for 017a7ba

Before this commit, when a unit that is restarting propagates stop
to other units, it can also depend on them, which results in
job type conflict and thus failure to pull in the dependencies.

So, let's introduce a new dependency atom UNIT_ATOM_PROPAGATE_STOP_GRACEFUL,
and use it for PropagatesStopTo=. It will enqueue a restart job if
there's already a start job, which meets the ultimate goal and avoids
job type conflict.

Fixes systemd#26839
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 3, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
Follow-up for 017a7ba

Before this commit, when a unit that is restarting propagates stop
to other units, it can also depend on them, which results in
job type conflict and thus failure to pull in the dependencies.

So, let's introduce a new dependency atom UNIT_ATOM_PROPAGATE_STOP_GRACEFUL,
and use it for PropagatesStopTo=. It will enqueue a restart job if
there's already a start job, which meets the ultimate goal and avoids
job type conflict.

Fixes systemd#26839
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
Follow-up for 017a7ba

Before this commit, when a unit that is restarting propagates stop
to other units, it can also depend on them, which results in
job type conflict and thus failure to pull in the dependencies.

So, let's introduce a new dependency atom UNIT_ATOM_PROPAGATE_STOP_GRACEFUL,
and use it for PropagatesStopTo=. It will enqueue a restart job if
there's already a start job, which meets the ultimate goal and avoids
job type conflict.

Fixes systemd#26839
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
Follow-up for 017a7ba

Before this commit, when a unit that is restarting propagates stop
to other units, it can also depend on them, which results in
job type conflict and thus failure to pull in the dependencies.

So, let's introduce a new dependency atom UNIT_ATOM_PROPAGATE_STOP_GRACEFUL,
and use it for PropagatesStopTo=. It will enqueue a restart job if
there's already a start job, which meets the ultimate goal and avoids
job type conflict.

Fixes systemd#26839
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
Follow-up for 017a7ba

Before this commit, when a unit that is restarting propagates stop
to other units, it can also depend on them, which results in
job type conflict and thus failure to pull in the dependencies.

So, let's introduce a new dependency atom UNIT_ATOM_PROPAGATE_STOP_GRACEFUL,
and use it for PropagatesStopTo=. It will enqueue a restart job if
there's already a start job, which meets the ultimate goal and avoids
job type conflict.

Fixes systemd#26839
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
Follow-up for 017a7ba

Before this commit, when a unit that is restarting propagates stop
to other units, it can also depend on them, which results in
job type conflict and thus failure to pull in the dependencies.

So, let's introduce a new dependency atom UNIT_ATOM_PROPAGATE_STOP_GRACEFUL,
and use it for PropagatesStopTo=. It will enqueue a restart job if
there's already a start job, which meets the ultimate goal and avoids
job type conflict.

Fixes systemd#26839
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
Follow-up for 017a7ba

Before this commit, when a unit that is restarting propagates stop
to other units, it can also depend on them, which results in
job type conflict and thus failure to pull in the dependencies.

So, let's introduce a new dependency atom UNIT_ATOM_PROPAGATE_STOP_GRACEFUL,
and use it for PropagatesStopTo=. It will enqueue a restart job if
there's already a start job, which meets the ultimate goal and avoids
job type conflict.

Fixes systemd#26839
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
Follow-up for 017a7ba

Before this commit, when a unit that is restarting propagates stop
to other units, it can also depend on them, which results in
job type conflict and thus failure to pull in the dependencies.

So, let's introduce a new dependency atom UNIT_ATOM_PROPAGATE_STOP_GRACEFUL,
and use it for PropagatesStopTo=. It will enqueue a restart job if
there's already a start job, which meets the ultimate goal and avoids
job type conflict.

Fixes systemd#26839
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
Follow-up for 017a7ba

Before this commit, when a unit that is restarting propagates stop
to other units, it can also depend on them, which results in
job type conflict and thus failure to pull in the dependencies.

So, let's introduce a new dependency atom UNIT_ATOM_PROPAGATE_STOP_GRACEFUL,
and use it for PropagatesStopTo=. It will enqueue a restart job if
there's already a start job, which meets the ultimate goal and avoids
job type conflict.

Fixes systemd#26839
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 4, 2023
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 5, 2023
Follow-up for 017a7ba

Before this commit, when a unit that is restarting propagates stop
to other units, it can also depend on them, which results in
job type conflict and thus failure to pull in the dependencies.

So, let's introduce a new dependency atom UNIT_ATOM_PROPAGATE_STOP_GRACEFUL,
and use it for PropagatesStopTo=. It will enqueue a restart job if
there's already a start job, which meets the ultimate goal and avoids
job type conflict.

Fixes systemd#26839
YHNdnzj added a commit to YHNdnzj/systemd that referenced this issue Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Programming errors, that need preferential fixing pid1 regression ⚠️ A bug in something that used to work correctly and broke through some recent commit
Development

Successfully merging a pull request may close this issue.

2 participants