Bug 616857 - RFE: Make chkconfig try to use systemctl first then use it's own way.
RFE: Make chkconfig try to use systemctl first then use it's own way.
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: chkconfig (Show other bugs)
rawhide
All Linux
low Severity medium
: ---
: ---
Assigned To: Bill Nottingham
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-07-21 10:42 EDT by Jóhann B. Guðmundsson
Modified: 2014-03-16 23:24 EDT (History)
6 users (show)

See Also:
Fixed In Version: chkconfig-1.3.51-1.fc15
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-03-16 00:11:18 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
Patch to add --no-forward arg (1.92 KB, patch)
2011-02-28 16:46 EST, Toshio Ernie Kuratomi
no flags Details | Diff
Patch to add --no-redirect arg (3.41 KB, patch)
2011-03-01 18:45 EST, Toshio Ernie Kuratomi
no flags Details | Diff

  None (edit)
Description Jóhann B. Guðmundsson 2010-07-21 10:42:30 EDT
Description of problem:

To avoid unnecessary bashing on mailing lists and load on our community 
( channels and forums ) it would be good if chkconfig would try to use systemd-install first then fallback to it's traditional way of handling things. 

If it finds a service file in /lib/systemd/system/ for the service that's being chkconfig then it should systemd-install enable/disable $service.service and or throw a deprecation warning which will then inform the user about systemd-install.

If it does not it should use it's traditional way of doing things.

I think all chkconfig scenarios or atleast most of them and how they map to systemctl can be found in my reply here.

http://lists.fedoraproject.org/pipermail/devel/2010-July/139229.html 

Lennart has added to his todo list to the ability for systemd-install to fallback to chkconfig if native systemd file does not exist which will cover the same from systemd's end.

That leaves us I think with only the service script which should use systemctl instead of what it does now and bug 612728 to be fully "Admin/Power" user compatible. 

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


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Comment 1 Fedora Update System 2011-02-21 15:35:01 EST
chkconfig-1.3.50-1.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/chkconfig-1.3.50-1.fc15
Comment 2 Toshio Ernie Kuratomi 2011-02-23 18:04:41 EST
This update further broke the draft guidelines for systemd unit files.  There's several ways we could work around it.

Description of problem:

The draft scriptlet for upgrading from a service using SystemVinit scripts to the same service using unit files is this:

%post
if [ $1 -eq 1 ] ; then 
        # Initial installation 
        /bin/systemctl daemon-reload >/dev/null 2>&1 || :
elif [ $1 -ge 2 ] ; then
        # Package upgrade
        if [ -f %{_initddir}/httpd ] ; then
                if /sbin/chkconfig httpd ; then
                        /bin/systemctl --no-reload enable httpd.service >/dev/null 2>&1 || :
                fi
        fi
fi

On package upgrade, if there's a sysvinit script, run chkconfig to determine if the init script is enabled.  If it is enabled, then run systemctl to register the new unit file.

The problem that now occurs with the script is that when /sbin/chkconfig runs in the %post script, both the SysVinit scripts and the systemd unit files are installed.  Since the patch to chkconfig forwards to systemd if systemd unit files are present, we end up asking systemd if the service is enabled via the unit file which it isn't since we haven't yet gotten to the line where we enable it.

Options:
* Rewrite the scriptlets to use triggers instead.  Triggers are error prone due to small mistakes in a trigger having unforeseen interactions with updated packages down the road but we could do this.
* Add a command line parameter to chkconfig so that it won't forward to systemd if we specify --no-systemd, for instance.  Update the draft Guidelines to use that parameter in the scriptlet.
* Change chkconfig to use SysVinit scripts first and fallback to unit files after.  This seems confusing although the Guidelines will state that you should not have both systemd and SysV init scripts in the same package.  (A subpackage is fine).
* Revert the patch to chkconfig
Comment 3 Jóhann B. Guðmundsson 2011-02-24 11:24:06 EST
reply to comment 2...

Has this been thought through by FPC?

"The Guidelines will state that you should not have both systemd and SysV init scripts in the same package.  (A subpackage is fine)."
Comment 4 Toshio Ernie Kuratomi 2011-02-24 11:54:05 EST
Yes.  If you have a comment on that, ping me on IRC (abadger1999) or in the Guidelines ticket: https://fedorahosted.org/fpc/ticket/31
Comment 5 Toshio Ernie Kuratomi 2011-02-28 16:46:11 EST
Created attachment 481456 [details]
Patch to add --no-forward arg

Here's a patch that adds a --no-forward arg to chkconfig.  When given, chkconfig does not forward requests to systemd.  This touches only code, not documentation.  I also don't know whether it makes sense to apply this to both --levels and to --levels [...] on/off but this patch does so.  I suppose that if someone has a service installed and wants to use it with a SysV init system, they'll need to have --no-forward on --levels on/off as well.
Comment 6 Bill Nottingham 2011-03-01 15:12:06 EST
We have a --no-redirect in /sbin/service... I wonder if it's better to keep the same name/convention. (The idea looks fine.)
Comment 7 Toshio Ernie Kuratomi 2011-03-01 18:45:56 EST
Created attachment 481742 [details]
Patch to add --no-redirect arg

* Changed name of parameter to --no-redirect.
* Added a man page section for the paramter.

Patch applied to a build: http://koji.fedoraproject.org/koji/taskinfo?taskID=2877444

Minimally tested by installing two versions of a package (one with sysv init scripts and one with a systemd unit file) and then running the following commands:

chkconfig --add supervisord
chkconfig --no-redirect --levels 5 supervisord on
chkconfig --levels 5 supervisord
echo $?
1
chkconfig --no-redirect --levels 5 supervisord
echo $?
0
chkconfig --no-redirect --levels 3 supervisord
echo $?
1
Comment 8 Fedora Update System 2011-03-04 05:03:16 EST
chkconfig-1.3.50-1.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 9 Fedora Update System 2011-03-09 01:19:59 EST
chkconfig-1.3.51-1.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/chkconfig-1.3.51-1.fc15
Comment 10 Fedora Update System 2011-03-16 00:11:11 EDT
chkconfig-1.3.51-1.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.

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