Skip to content

Conversation

prakashsurya
Copy link
Contributor

@prakashsurya prakashsurya commented May 28, 2025

Problem

The "kdump-tools" service depends on local filesystem's being mounted, so that it can write to "/tmp". Even though that service's definitation states it should run "After=local-fs.target", it doesn't appear to also "Requires=local-fs.target", so it can end up running before the local filesystems are ready.

Solution

The solution here, is to add an override file for the service, to add the necessary "Requires=local-fs.target" declaration.

Testing Done

  • git-ab-pre-push is here

I applied this change manually, and verified the service's dependencies now depend on the local filesystems.

  • Before:
$ sudo systemctl list-dependencies kdump-tools --all
kdump-tools.service
● └─system.slice
●   └─-.slice
  • After:
$ sudo systemctl list-dependencies kdump-tools --all
kdump-tools.service
● ├─system.slice
● │ └─-.slice
● └─local-fs.target
●   ├─export-home.mount
●   │ └─system.slice
●   │   └─-.slice
●   ├─systemd-remount-fs.service
●   │ ├─system.slice
●   │ │ └─-.slice
●   │ └─local-fs-pre.target
●   ├─tmp.mount
●   │ └─system.slice
●   │   └─-.slice
●   ├─var-crash.mount
●   │ └─system.slice
●   │   └─-.slice
●   ├─var-delphix.mount
●   │ └─system.slice
●   │   └─-.slice
●   ├─var-log.mount
●   │ └─system.slice
●   │   └─-.slice
●   └─var-tmp.mount
●     └─system.slice
●       └─-.slice

@prakashsurya prakashsurya force-pushed the dlpx/pr/prakashsurya/cae04461-e455-4150-b33e-5ef92664c70f branch from 894496e to 8d6d8aa Compare May 28, 2025 17:03
@prakashsurya prakashsurya requested a review from sebroy May 28, 2025 17:04
@prakashsurya prakashsurya marked this pull request as ready for review May 28, 2025 17:04
@prakashsurya
Copy link
Contributor Author

FWIW, I think this is a bug in the upstream service definition.. and likely due to the fact that the new service on develop has DefaultDependencies=no.

  • on release:
# /lib/systemd/system/kdump-tools.service
[Unit]
Description=Kernel crash dump capture service

[Service]
Type=oneshot
StandardOutput=syslog+console
EnvironmentFile=/etc/default/kdump-tools
ExecStart=/etc/init.d/kdump-tools start
ExecStop=/etc/init.d/kdump-tools stop
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

$ sudo systemctl list-dependencies kdump-tools --all | head -n30
kdump-tools.service
● ├─system.slice
● │ └─-.slice
● └─sysinit.target
●   ├─dev-hugepages.mount
●   │ └─system.slice
●   │   └─-.slice
●   ├─dev-mqueue.mount
●   │ └─system.slice
●   │   └─-.slice
●   ├─keyboard-setup.service
●   │ ├─system.slice
●   │ │ └─-.slice
●   │ └─local-fs-pre.target
●   ├─kmod-static-nodes.service
●   │ └─system.slice
●   │   └─-.slice
●   ├─open-iscsi.service
●   │ ├─iscsi-name-init.service
●   │ │ ├─system.slice
●   │ │ │ └─-.slice
    │ │   └─...
●   │ ├─system.slice
●   │ │ └─-.slice
●   │ ├─network-online.target
●   │ │ └─systemd-networkd-wait-online.service
●   │ │   ├─system.slice
●   │ │   │ └─-.slice
●   │ │   └─systemd-networkd.service
●   │ │     ├─netplan-ovs-cleanup.service
  • on develop:
$ sudo systemctl cat kdump-tools
# /usr/lib/systemd/system/kdump-tools.service
[Unit]
Description=Kernel crash dump capture service
DefaultDependencies=no
After=local-fs.target
After=networking.service
Before=basic.target

[Service]
Type=oneshot
StandardOutput=journal+console
EnvironmentFile=/etc/default/kdump-tools
ExecStartPre=-/usr/share/kdump-tools/kdump_mem_estimator
ExecStart=/etc/init.d/kdump-tools start
ExecStop=/etc/init.d/kdump-tools stop
RemainAfterExit=yes

[Install]
WantedBy=basic.target

$ sudo systemctl list-dependencies kdump-tools --all
kdump-tools.service
● └─system.slice
●   └─-.slice

@sebroy
Copy link
Contributor

sebroy commented May 28, 2025

I don't understand. The systemd.unit man page says:

   Before=, After=
       These two settings expect a space-separated list of unit names. They may be specified more than once, in which case dependencies for all
       listed names are created.

       Those two settings configure ordering dependencies between units. If unit foo.service contains the setting Before=bar.service and both
       units are being started, bar.service's start-up is delayed until foo.service has finished starting up.  After= is the inverse of Before=,
       i.e. while Before= ensures that the configured unit is started before the listed unit begins starting up, After= ensures the opposite,
       that the listed unit is fully started up before the configured unit is started.

As such, it follows that kdump-tools won't begin starting up until after local-fs.target has started. Is the problem actually that our ZFS root isn't mounted as part of local-fs.target?

@prakashsurya
Copy link
Contributor Author

As such, it follows that kdump-tools won't begin starting up until after local-fs.target has started.

Then, why isn't local-fs.target listed as a dependency of kdump-tools.service ? I don't think it's a problem with local-fs.target..

@sebroy
Copy link
Contributor

sebroy commented May 28, 2025

Then, why isn't local-fs.target listed as a dependency of kdump-tools.service ? I don't think it's a problem with local-fs.target..

I think you answered my question in your latest comment relating to DefaultDependencies=no, which affects how After= behaves with respect to early-boot targets. If not for that, I think After= would be sufficient?

@prakashsurya
Copy link
Contributor Author

which affects how After= behaves with respect to early-boot targets.

yea.. I haven't verified, but perhaps kdump-tools is being started before local-fs.. and After= only works if the services/dependencies are started "in the same systemd transaction group" (not 100% what that means, but some searching around seems to imply this).. if we Require= it as well, it'll ensure local-fs is started when kdump-tools is started..

kind of speculating, but I think that's matching the behavior I'm seeing..

@prakashsurya prakashsurya merged commit 289dd79 into develop May 28, 2025
23 of 24 checks passed
@prakashsurya prakashsurya deleted the dlpx/pr/prakashsurya/cae04461-e455-4150-b33e-5ef92664c70f branch May 28, 2025 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants