RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1792219 - socket.targets incorrectly pulls any socket unit installed on the system
Summary: socket.targets incorrectly pulls any socket unit installed on the system
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: systemd
Version: 8.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 8.0
Assignee: David Tardon
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-01-17 10:27 UTC by Renaud Métrich
Modified: 2023-12-15 17:12 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-03-20 13:46:43 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Renaud Métrich 2020-01-17 10:27:46 UTC
Description of problem:

This behaviour was found with BZ #1792173 on RHEL 8.

The systemd.special(7) manpage states the following about "sockets.target":
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
       sockets.target
           A special target unit that sets up all socket units (see systemd.socket(5) for details)
           that shall be active after boot.

           Services that can be socket-activated shall add Wants= dependencies to this unit for their
           socket unit during installation. This is best configured via a WantedBy=sockets.target in
           the socket unit's "[Install]" section.
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

The wording is confusing because the admin can believe that only sockets installed into "sockets.target" are affected, which is not the case.
In fact, as long as a socket is pulled by some target (e.g. "WantedBy=multi-user.target"), a dependency "After" is added to "sockets.target" for that socket, e.g. with "tangd.socket" which currently is installed in multi-user.target:

-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# systemctl show sockets.target -p After --no-pager
After=dbus.socket syslog.socket systemd-journald.socket systemd-journald-dev-log.socket cups.socket tangd.socket systemd-journald-audit.socket systemd-udevd-kernel.socket systemd-initctl.socket sssd-kcm.socket systemd-udevd-control.socket
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This is problematic because if, for some reason, the admin wants a Unix socket to listen on a remote file system, this creates an ordering cycle, breaking the system boot.

IMHO, only sockets installed in sockets.target should be brought online early to reach sockets.target.


Version-Release number of selected component (if applicable):

systemd-219 (RHEL 7) and later


How reproducible:

Always


Steps to Reproduce:

1. Create a "remote" file system (mount delayed)

  # mkdir /my-delayed-mount
  # semanage fcontext -a -t var_run_t "/my-delayed-mount(/.*)?"
  # restorecon -F /my-delayed-mount
  # echo 'tmpfs			/my-delayed-mount	tmpfs	defaults,_netdev,rootcontext="system_u:object_r:var_run_t:s0"	0 0' >> /etc/fstab

2. Create a custom socket listening on the "remote" file system, started by "multi-user.target"

  # cat > /etc/systemd/system/socket-on-remote-fs.service << EOF
[Service]
ExecStart=/bin/true
EOF

  # cat > /etc/systemd/system/socket-on-remote-fs.socket << EOF
[Socket]
ListenStream=/my-delayed-mount/socket-on-remote-fs.sock

[Install]
WantedBy=multi-user.target
EOF
  
3. Enable the socket and reboot

  # systemctl enable socket-on-remote-fs.socket
  # reboot

Actual results:

[    6.596288] systemd[1]: my\x2ddelayed\x2dmount.mount: Found ordering cycle on network.target/start
[    6.599433] systemd[1]: my\x2ddelayed\x2dmount.mount: Found dependency on NetworkManager.service/start
[    6.602596] systemd[1]: my\x2ddelayed\x2dmount.mount: Found dependency on basic.target/start
[    6.605733] systemd[1]: my\x2ddelayed\x2dmount.mount: Found dependency on sockets.target/start
[    6.609254] systemd[1]: my\x2ddelayed\x2dmount.mount: Found dependency on socket-on-remote-fs.socket/start
[    6.615472] systemd[1]: my\x2ddelayed\x2dmount.mount: Found dependency on my\x2ddelayed\x2dmount.mount/start
[ SKIP ] Ordering cycle found, skipping Network
[ SKIP ] Ordering cycle found, skipping Network Manager
[ SKIP ] Ordering cycle found, skipping A So…stening on a non-local file system
[  OK  ] Stopped Switch Root.
...
[FAILED] Failed to mount /home.
See 'systemctl status home.mount' for details.


Expected results:

No ordering cycle since the socket is WantedBy "multi-user.target", not "sockets.target".


Additional info:

This boot resulted in not having NetworkManager start at all ("network.target" being skipped).
See also BZ #1792173 for actual use case (tangd.socket not starting).

Comment 1 David Tardon 2020-03-20 13:46:35 UTC
(In reply to Renaud Métrich from comment #0)
> The systemd.special(7) manpage states the following about "sockets.target":
> -------- 8< ---------------- 8< ---------------- 8< ---------------- 8<
> --------
>        sockets.target
>            A special target unit that sets up all socket units (see
> systemd.socket(5) for details)
>            that shall be active after boot.
> 
>            Services that can be socket-activated shall add Wants=
> dependencies to this unit for their
>            socket unit during installation. This is best configured via a
> WantedBy=sockets.target in
>            the socket unit's "[Install]" section.
> -------- 8< ---------------- 8< ---------------- 8< ---------------- 8<
> --------
> 
> The wording is confusing because the admin can believe that only sockets
> installed into "sockets.target" are affected, which is not the case.

Well, *all socket units* sounds pretty unconditional to me... And it's said even more clearly in "Default dependencies" section on systemd.socket(5).

> In fact, as long as a socket is pulled by some target (e.g.
> "WantedBy=multi-user.target"), a dependency "After" is added to
> "sockets.target" for that socket, e.g. with "tangd.socket" which currently
> is installed in multi-user.target:

Yes, the dependency is added as a default dependency to any loaded socket.
 
> This is problematic because if, for some reason, the admin wants a Unix
> socket to listen on a remote file system, this creates an ordering cycle,
> breaking the system boot.
>
> IMHO, only sockets installed in sockets.target should be brought online
> early to reach sockets.target.

That would be a change of behavior. It's worked like this since ever and it's specified that it shall work like this (btw, the same is true for paths.target and timers.target). The standard way to avoid default dependencies when they cause problems for a unit is to use DefaultDependencies=no in that unit.

Comment 2 RHEL Program Management 2020-03-20 13:46:43 UTC
Development Management has reviewed and declined this request. You may appeal this decision by reopening this request.


Note You need to log in before you can comment on or make changes to this bug.