Bug 1316387 - systemctl preset-all disables but wont enable default.target
systemctl preset-all disables but wont enable default.target
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: systemd (Show other bugs)
7.2
Unspecified Unspecified
unspecified Severity low
: rc
: ---
Assigned To: Jan Synacek
qe-baseos-daemons
:
Depends On:
Blocks: 1298243 1420851 1549617 1551061
  Show dependency treegraph
 
Reported: 2016-03-10 02:19 EST by Aaron Howell
Modified: 2018-06-13 07:42 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2018-06-13 07:42:07 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Aaron Howell 2016-03-10 02:19:49 EST
Description of problem:
systemctl preset-all disables but wont enable default.target.
So if the target is not enabled in preset policy it is removed. If it is enabled in default policy however it is not added. This is confusing behaviour.

It should either work for both or none. 

Version-Release number of selected component (if applicable):
systemd-219-19.el7_2.4.x86_64

How reproducible:
Everytime

Steps to Reproduce:
1. # No reference to multi-user.target in any systemd-preset files (ie uses 99-default.preset)
2. sudo systemctl preset-all
3. # Add "enable multi-user.target" to a systemd-preset file (eg /etc/systemd/system-preset/01-target.preset)
4. sudo systemctl preset-all

Actual results:
$ sudo systemctl status multi-user.target 
● multi-user.target - Multi-User System
   Loaded: loaded (/usr/lib/systemd/system/multi-user.target; static; vendor preset: disabled)
   Active: active since Wed 2016-03-09 15:57:02 AEDT; 1 day 1h ago
     Docs: man:systemd.special(7)
$ sudo systemctl get-default 
multi-user.target
$ sudo systemctl preset-all
Removed symlink /etc/systemd/system/default.target.
$sudo systemctl get-default 
graphical.target
$ echo "enable multi-user.target" >> sudo tee -a /etc/systemd/system-preset/01-target.preset
$ sudo systemctl daemon-reload
$ sudo systemctl status multi-user.target 
● multi-user.target - Multi-User System
   Loaded: loaded (/usr/lib/systemd/system/multi-user.target; static; vendor preset: enabled)
   Active: active since Wed 2016-03-09 15:57:02 AEDT; 1 day 1h ago
     Docs: man:systemd.special(7)
$ sudo systemctl preset-all
$ sudo systemctl get-default 
graphical.target

Expected results:
# Work for both
$ sudo systemctl status multi-user.target 
● multi-user.target - Multi-User System
   Loaded: loaded (/usr/lib/systemd/system/multi-user.target; static; vendor preset: disabled)
   Active: active since Wed 2016-03-09 15:57:02 AEDT; 1 day 1h ago
     Docs: man:systemd.special(7)
$ sudo systemctl get-default 
multi-user.target
$ sudo systemctl preset-all
Removed symlink /etc/systemd/system/default.target.
$sudo systemctl get-default 
graphical.target
$ echo "enable multi-user.target" >> sudo tee -a /etc/systemd/system-preset/01-target.preset
$ sudo systemctl daemon-reload
$ sudo systemctl status multi-user.target 
● multi-user.target - Multi-User System
   Loaded: loaded (/usr/lib/systemd/system/multi-user.target; static; vendor preset: enabled)
   Active: active since Wed 2016-03-09 15:57:02 AEDT; 1 day 1h ago
     Docs: man:systemd.special(7)
$ sudo systemctl preset-all
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.
$ sudo systemctl get-default 
multi-user.target

------ OR --------
# Work for neither
$ sudo systemctl status multi-user.target 
● multi-user.target - Multi-User System
   Loaded: loaded (/usr/lib/systemd/system/multi-user.target; static; vendor preset: disabled)
   Active: active since Wed 2016-03-09 15:57:02 AEDT; 1 day 1h ago
     Docs: man:systemd.special(7)
$ sudo systemctl get-default 
multi-user.target
$ sudo systemctl preset-all
$sudo systemctl get-default 
multi-user.target
$ echo "enable multi-user.target" >> sudo tee -a /etc/systemd/system-preset/01-target.preset
$ sudo rm /etc/systemd/system/default.target
$ sudo systemctl daemon-reload
$ sudo systemctl status multi-user.target 
● multi-user.target - Multi-User System
   Loaded: loaded (/usr/lib/systemd/system/multi-user.target; static; vendor preset: enabled)
   Active: active since Wed 2016-03-09 15:57:02 AEDT; 1 day 1h ago
     Docs: man:systemd.special(7)
$ sudo systemctl preset-all
$ sudo systemctl get-default 
graphical.target


Additional info:
Possibly if it works for both a default preset policy should be added to:
/usr/lib/systemd/system-preset/90-default.preset
Comment 3 Aaron Howell 2016-11-28 00:24:24 EST
I just realised the "works for neither" section had a typo - the last lines of output should be:
$ sudo systemctl get-default 
multi-user.target
Comment 9 Jan Synacek 2018-05-24 07:54:44 EDT
https://github.com/systemd/systemd/issues/9078
Comment 10 Jan Synacek 2018-06-13 07:42:07 EDT
Ok, so this actually works as it should. See the uspstream issue for details.

To sum up:
The 'preset-all' command removes default.target, even if it's in the configuration file, because "default.target" is not an actual name of a unit file. Also, when "multi-user.target" or "graphical.target" is specified in the configuration, it is not enabled as it doesn't have an Install section (see https://github.com/systemd/systemd/commit/02ebe178a2bd6b2448d4fbfa4a1f7fa98e9e82b1 for the reasoning).

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