Skip to content

Many fixes, in particular to the install logic - #2973

Merged
martinpitt merged 70 commits into
systemd:masterfrom
poettering:search-path
Apr 12, 2016
Merged

martinpitt merged 70 commits into
systemd:masterfrom
poettering:search-path

Conversation

@poettering

Copy link
Copy Markdown
Member

This contains a big pile of fixes, primarily to the install logic and the core.

(Note that there will be more coming. For example, the install logic can now recognize transient unit files, however the core currently doesn't create any. Instead it just creates drop-ins with no main unit file. I am working on fixing this. As soon as fixed "systemctl list-unit-files" should show the usual unit files but also generated and transient ones).

This stuff has been lying around for a while on my checkout, since it contains many fixes, I#d really like to see this go in now, so that it doesn't continue to be this rebase-all-the-time orgy.

@keszybz

keszybz commented Apr 6, 2016

Copy link
Copy Markdown
Member

I don't think it's possible to comment on individual commits any more. Oh, github!

@poettering

Copy link
Copy Markdown
Member Author

@keszybz hmm, what do you mean? seems to work here?

@keszybz

keszybz commented Apr 6, 2016

Copy link
Copy Markdown
Member

When I pick "commit (37)", and then a commit from the list, I'm taken to the "files changed" view, with "showing changes from one commit". I cannot comment on a commit as such, afaict.

Comment thread man/systemd-nspawn.xml Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the command line

@keszybz

keszybz commented Apr 7, 2016

Copy link
Copy Markdown
Member
test_sysv_disable (__main__.EnableTests)
only sysv: disable ... Synchronizing state of test_enable.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install disable test_enable
insserv: warning: current start runlevel(s) (empty) of script `test_enable' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `test_enable' overrides LSB defaults (0 1 6).
ok
test_sysv_enable (__main__.EnableTests)
only sysv: enable ... Synchronizing state of test_enable.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable test_enable
Failed to execute operation: Unit file is transient or generated.
ERROR
test_unit_alias_disable (__main__.EnableTests)
no sysv: disable unit with an alias ... Removed symlink /etc/systemd/system/test_enablea.service.
ok
test_unit_alias_enable (__main__.EnableTests)
no sysv: enable unit with an alias ... Created symlink from /etc/systemd/system/test_enablea.service to /lib/systemd/system/test_enable.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/test_enable.service to /lib/systemd/system/test_enable.service.
ok
test_unit_disable (__main__.EnableTests)
no sysv: disable unit ... Removed symlink /etc/systemd/system/multi-user.target.wants/test_enable.service.
ok
test_unit_enable (__main__.EnableTests)
no sysv: enable unit ... Created symlink from /etc/systemd/system/multi-user.target.wants/test_enable.service to /lib/systemd/system/test_enable.service.
ok
test_unit_link (__main__.EnableTests)
systemctl link ... Created symlink from /etc/systemd/system/tmpoc0218l4.service to /tmp/tmpoc0218l4.service.
ok

This is not an upstream test... @martinpitt ?

@martinpitt

Copy link
Copy Markdown
Contributor

Wrt test_sysv_enable: This is http://anonscm.debian.org/cgit/pkg-systemd/systemd.git/tree/debian/tests/unit-config#n270 , these tests cover the enabling/starting/disabling of native units, SysV scripts, or the case when both exist.

This creates a SysV init script (only) and then calls systemctl enable on it. In the current version this defers to systemd-sysv-install for SysV init scripts, and if there is also a native .service unit it does the usual symlink dance. It seems that with this PR this now tries to enable the /run/systemd/generator.late/mysysvscript.service unit? (There's also a new state UNIT_FILE_GENERATED).

Note that this is the (only) failure on s390x only. On i386/amd64 it already fails during build in make check in 5 places, all of which on

Assertion 'path' failed at ../src/basic/mkdir.c:61, function mkdir_parents_internal(). Aborting.

@poettering

Copy link
Copy Markdown
Member Author

@martinpitt hmm, any idea how i can figure out the stacktrace where the mkdir fails? Currently there's no way for me to debug that...

@martinpitt

Copy link
Copy Markdown
Contributor

Wrt. the sysv enable regression, that's reasonably straightforward to reproduce:

cat << EOF | sudo tee /etc/init.d/test_enable
### BEGIN INIT INFO
# Provides:          test_enable%s
# Required-Start:     
# Required-Stop:      
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Testsuite script%s
### END INIT INFO

echo hello
EOF
sudo chmod 755 /etc/init.d/test_enable
sudo systemctl enable test_enable
sudo systemctl enable test_enable

With trunk it should look like

test_enable.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable test_enable

(twice). With this branch, the second one fails with this "Unit file is transient or generated." error because /run/systemd/generator.late/test_enable.service already exists, and that now upsets systemctl.

This is actually a bug in the tests as well as /run/systemd/generator.late/ should be cleaned up between the tests -- i. e. there is a systemctl daemon-reload missing after cleaning up /etc/init.d/test_enable. However, systemctl enable previously used to be idempotent, is that something which we want to keep? Either way, I'm happy to fix the tests (trivial, already have the fix locally), but that will hide this particular problem.

As for the mkdir assertion during make check, I'm currently investigating this. I don't get this on my laptop either, so doing a build in a production cloud instance.

@martinpitt

Copy link
Copy Markdown
Contributor

I fixed the daemon-reload between tests in http://anonscm.debian.org/cgit/pkg-systemd/systemd.git/commit/?id=400b6df031 and added explicit tests that systemctl enable/disable are idempotent in http://anonscm.debian.org/cgit/pkg-systemd/systemd.git/commit/?id=12085d6.

This actually uncovered a slightly more serious bug with disable: in the scenario above,

$ sudo systemctl enable test_enable
$ systemctl is-enabled test_enable; echo $?
generated
0
$ sudo systemctl disable test_enable
$ systemctl is-enabled test_enable; echo $?
generated
0

After systemctl disable, is-enabled should certainly not succeed any more. With current master it correctly says "disabled" and exits with 1.

BTW, http://anonscm.debian.org/cgit/pkg-systemd/systemd.git/tree/debian/tests/unit-config is not really distro specific -- it should run for you by merely replacing /lib/systemd/ with /usr/lib/systemd. If you want, I can detect the path automatically and propose the test script for upstream inclusion (I can test this in a Fedora container).

@martinpitt

Copy link
Copy Markdown
Contributor

As for the mkdir test failure, this happens when running the tests without an $XDG_RUNTIME_DIR:

$ env -u XDG_RUNTIME_DIR ./test-sched-prio 
Assertion 'path' failed at ../src/basic/mkdir.c:61, function mkdir_parents_internal(). Aborting.
Aborted (core dumped)

(The build happens in a minimal environment). This is perfectly reproducible locally for me, please let me know if it isn't for you.

@martinpitt

Copy link
Copy Markdown
Contributor

I updated http://anonscm.debian.org/cgit/pkg-systemd/systemd.git/tree/debian/tests/unit-config now to detect the systemd unit path and also replace the Debian-specific update-rc.d call with systemd-sysv-install. Now the test runs unmodified on Fedora 23 too, I tested this in a minimal F23 container.

Note that while the test is normally safe to run on a production install, it could leave /etc/init.d/test_install or some test_install.service behind if it crashes at the right place. Running it again should clean up everything, though.

As I said, if you want I'm happy to propose this test for upstream inclusion now, to make it easier for others to run.

@keszybz

keszybz commented Apr 7, 2016

Copy link
Copy Markdown
Member

unsafe_tests seems like the right place for this.

After reading the patches I think the idea is that generated units cannot be enabled or disabled, and are supposed to be linked into the right place by the generator. This make sense in case of "native" generated units, but breaks down for sysv "wrapper" units, which are both generated, and have external enablement status which we report. I think the code must be changed to allow enable/disable/is-enabled checks, at least for the wrapper units.

@poettering
poettering force-pushed the search-path branch 3 times, most recently from 4a7f5b6 to 9b6bb6a Compare April 8, 2016 17:32
@poettering

Copy link
Copy Markdown
Member Author

I force pushed a new version, that hopefully fixes all issues @keszybz and the test suite found...

I also added a number of more commits that complete the unit file install logic rework, by adding a new "systemctl revert" command.

We only use it inside of install.c, hence let's make it static.
Exit early, so that we can get rid of the large if block.
This allows dropping all user configuration and reverting back to the vendor
default of a unit file. It basically undoes what "systemctl edit", "systemctl
set-property" and "systemctl mask" do.
There's no point in first determining the drop-in file name path, then
forgetting it again, and then determining it again. Instead, just generated it
once, and then write to ti directly.
We don#t really support systems where XDG_RUNTIME_DIR is not supported for
systemd --user. Hence, let's always set our own XDG_RUNTIME_DIR for tests that
involve systemd --user, so that we know it is set, and that it doesn't polute
the user's actual runtime dir.
This hopefully reduces confusion resulting in issues like systemd#2992.
This new command removes all, or all hidden container images that have been
downloaded.
…pted to be enabled

We don't allow using config symlinks to enable units, but the error message we
printed was awful. Fix that, and generate a more readable error.

Fixes systemd#3010.
We only use it for the Tx code anyway, hence sd-lldp.h shouldn't expose it, as
it only implements Rx.
Otherwise "systemctl status" will immediately report that our unit file is out
of date.
Let's make this more digestable to read by making the list of documented unit
file paths a bit shorter.

Specifically, let's drop references to $XDG_CONFIG_HOME and $XDG_DATA_HOME, as
their default values are listed too already. Given that the fact that the XDG
basedir spec makes these paths configurable is probably not a strong point of
the spec, let's drop the reference to the env vars, and keep only the literal,
default paths for them in the list. Of course, we do support the full XDG
basedir spec in this regard, but it's one thing to implement it and another one
to recommend it by documenting it.

Replace "$HOME" by "~", because UNIX.
@poettering

Copy link
Copy Markdown
Member Author

And yeah @evverx found a memory leak. In fact we should really free the changes list in all of the install methods, just to be sure, and the revert method is just one of those. Will add a new commit to fix this on top, and rebase.

@poettering

Copy link
Copy Markdown
Member Author

ok, rebased and and force pushed, let's see if the CI still likes it.

@evverx

evverx commented Apr 12, 2016

Copy link
Copy Markdown
Contributor

In fact we should really free the changes list in all of the install methods.

Indeed. Thanks!

Sorry, but what is @centos-ci ? :)

…on't choke on ELOOP

ELOOP indicates that there's a symlink in /etc for a native unit file, and
that's completely OK.
@poettering

Copy link
Copy Markdown
Member Author

@centos-ci is a Jenkins instance, currently in the works to being set up for us, so that we also can have integration tests on RHEL in addition to Ubuntu. However it's not complete yet, and it ended up spamming a lot of PRs, unfortunately.

@johannbg

Copy link
Copy Markdown
Contributor

@poettering

Whats the difference of the integration test being performed on Ubuntu vs RHEL and should not one integration test be enough upstream or is there plans to have integration test on all the llinux distribution out there?

@poettering

Copy link
Copy Markdown
Member Author

@johannbg not the right place to discuss this. → ML

@martinpitt

Copy link
Copy Markdown
Contributor

Yay, CI is green again thanks to your latest fix (3c6d8e5). So let's land this before something else shatters this again :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

7 participants