Skip to content

Commit

Permalink
Attempts to eliminate some systemd unit cyclical dependencies (#181)
Browse files Browse the repository at this point in the history
* Adjusts ordering and requirements for /cache mounts and formatting if the disk to avoid cyclical dependencies (caused by implicit dependencies).

* Makes format-cache.service depend on local-fs-pre.target to be sure that disk devices are available.

* Configures format-cache.service to start after dev-sda.device.

* Adds Requires=dev-sda.device to format-cache.service.

* Removes Requires=dev-sda.device to format-cache.service.

* Removes ordering and dependency statements from mounts and moves them all to format-cache.service, since that is the unit that needs to be treated in a non-default way.

* Tries relying solely on RequiresMountsFor.

* Removes RequiresMountsFor, and readds Before, and adds RequiredBy for various mounts.

* Moves RequiredBy to Install section, adds back DefaultDependencies=no.

* Adds brief comments about why we add certain dependencies and ordering.
  • Loading branch information
nkinkade authored Jul 1, 2020
1 parent 2414959 commit c2d5e9c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
3 changes: 0 additions & 3 deletions configs/stage3_ubuntu/etc/systemd/system/cache-data.mount
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[Unit]
Description=Mount Experiment Data Volume
Before=docker.service
After=format-cache.service
Requires=format-cache.service

[Mount]
What=/dev/disk/by-label/cache-data
Expand Down
3 changes: 0 additions & 3 deletions configs/stage3_ubuntu/etc/systemd/system/cache-docker.mount
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[Unit]
Description=Mount Docker Data Volume
Before=docker.service
After=format-cache.service
Requires=format-cache.service

[Mount]
What=/dev/disk/by-label/cache-docker
Expand Down
10 changes: 6 additions & 4 deletions configs/stage3_ubuntu/etc/systemd/system/format-cache.service
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[Unit]
Before=docker.service cache-docker.mount cache-data.mount cache-core.mount
RequiresMountsFor=/cache
ConditionPathExists=!/cache/docker
# We want this unit to run before we mount to be sure that disk gets formatted first.
Before=cache-data.mount cache-docker.mount
ConditionPathExists=!/cache/data
ConditionPathExists=!/cache/core
ConditionPathExists=!/cache/docker
DefaultDependencies=no

[Service]
Type=oneshot
Expand All @@ -28,5 +28,7 @@ ExecStart=/usr/sbin/mkfs.xfs -f -L cache-data /dev/sda1
ExecStart=/usr/sbin/mkfs.xfs -f -L cache-docker /dev/sda2

[Install]
# This requirement should cause these mounts to fail if this unit fails.
RequiredBy=cache-data.mount cache-docker.mount
WantedBy=multi-user.target

0 comments on commit c2d5e9c

Please sign in to comment.