forked from bottlerocket-os/bottlerocket
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The current systemd boot sequence is error prone on isolated scenarios like sending invalid configurations through user data. These scenarios could cause inconsistent states at the end of the boot process, which affect the mechanism to determine if a boot was successful after applying new configurations or updates. It is also difficult to implement features that require service initialization order. In order to fix the problems presented above, this commit defines a new boot sequence, with three main systemd targets: preconfigured, configured and multi-user. Preconfigured This target is used to start the boot process. Failures in any of the required service units will cause the target to fail, stopping the boot process. The boot is marked as successful during the execution of this target only if the migrator "oneshot" service exists successfully. Services initialized during this phase include: * migrator * mark-successful-boot * send-boot-success * storewolf * apiserver * early-boot-config * sundog * settings-applier Once the target is reached (completed), the "activate-configured.service" unit will set the configured target as the default target and start it. Configured This target should be used to setup additional configurations in the host before services like kubernetes/ecs start. Services initialized during this phase include: * chronyd * host-containerd Once the target is reached (completed) the "activate-multi-user.service" unit will set the multi-user target as the default target, and start it. Multi-user This is the final target enabled in the boot sequence. Services initialized during this phase include: * host-containers@* * docker * ecs * kubernetes
- Loading branch information
1 parent
e04cdf5
commit 0e74737
Showing
29 changed files
with
191 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
[Unit] | ||
Description=A versatile implementation of the Network Time Protocol | ||
Documentation=https://chrony.tuxfamily.org | ||
After=network-online.target configured.target | ||
Requires=network-online.target configured.target | ||
After=network-online.target preconfigured.target | ||
Wants=network-online.target preconfigured.target | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=/usr/sbin/chronyd -d -F -1 | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
WantedBy=configured.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,3 @@ MemoryAccounting=true | |
|
||
[Install] | ||
WantedBy=multi-user.target | ||
RequiredBy=mark-successful-boot.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,3 @@ MemoryAccounting=true | |
|
||
[Install] | ||
WantedBy=multi-user.target | ||
RequiredBy=mark-successful-boot.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,3 @@ MemoryAccounting=true | |
|
||
[Install] | ||
WantedBy=multi-user.target | ||
RequiredBy=mark-successful-boot.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,3 @@ MemoryAccounting=true | |
|
||
[Install] | ||
WantedBy=multi-user.target | ||
RequiredBy=mark-successful-boot.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,3 @@ MemoryAccounting=true | |
|
||
[Install] | ||
WantedBy=multi-user.target | ||
RequiredBy=mark-successful-boot.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
[Unit] | ||
Description=Call signpost to mark the boot as successful after all required targets are met. | ||
After=multi-user.target | ||
# Each service that must start correctly in order for a boot to be successful should be of type "notify" | ||
# and include "RequiredBy=mark-successful-boot.service" in its [Install] section. | ||
# This unit is in charge of updating the partitions on successful boots. Use other service | ||
# units instead of adding more `ExecStart*` lines to prevent indirect dependencies on | ||
# other units not listed in the `RequiredBy` section. | ||
Requires=migrator.service | ||
# Block manual interactions with this service, manually running it could leave the system in an | ||
# unexpected state | ||
RefuseManualStart=true | ||
RefuseManualStop=true | ||
|
||
[Service] | ||
EnvironmentFile=/etc/network/proxy.env | ||
Type=oneshot | ||
RemainAfterExit=true | ||
ExecStart=/bin/signpost mark-successful-boot | ||
ExecStartPost=-/usr/bin/metricdog send-boot-success | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
RequiredBy=preconfigured.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
[Unit] | ||
Description=Bottlerocket data store migrator | ||
RefuseManualStart=true | ||
RefuseManualStop=true | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/migrator --datastore-path /var/lib/bottlerocket/datastore/current --migration-directory /var/lib/bottlerocket-migrations --root-path /usr/share/updog/root.json --metadata-directory /var/cache/bottlerocket-metadata --migrate-to-version-from-os-release | ||
ExecStart=/usr/bin/migrator \ | ||
--datastore-path /var/lib/bottlerocket/datastore/current \ | ||
--migration-directory /var/lib/bottlerocket-migrations \ | ||
--root-path /usr/share/updog/root.json \ | ||
--metadata-directory /var/cache/bottlerocket-metadata \ | ||
--migrate-to-version-from-os-release | ||
RemainAfterExit=true | ||
StandardError=journal+console | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
RequiredBy=preconfigured.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ Source107: [email protected] | |
Source110: mark-successful-boot.service | ||
Source111: metricdog.service | ||
Source112: metricdog.timer | ||
Source113: send-boot-success.service | ||
|
||
# 2xx sources: tmpfilesd configs | ||
Source200: migration-tmpfiles.conf | ||
|
@@ -337,7 +338,7 @@ install -p -m 0644 %{S:5} %{S:6} %{buildroot}%{_cross_templatedir} | |
install -d %{buildroot}%{_cross_unitdir} | ||
install -p -m 0644 \ | ||
%{S:100} %{S:101} %{S:102} %{S:103} %{S:105} \ | ||
%{S:106} %{S:107} %{S:110} %{S:111} %{S:112} \ | ||
%{S:106} %{S:107} %{S:110} %{S:111} %{S:112} %{S:113}\ | ||
%{buildroot}%{_cross_unitdir} | ||
|
||
install -d %{buildroot}%{_cross_tmpfilesdir} | ||
|
@@ -440,6 +441,7 @@ install -p -m 0644 %{S:300} %{buildroot}%{_cross_udevrulesdir}/80-ephemeral-stor | |
%{_cross_templatedir}/metricdog-toml | ||
%{_cross_unitdir}/metricdog.service | ||
%{_cross_unitdir}/metricdog.timer | ||
%{_cross_unitdir}/send-boot-success.service | ||
|
||
%files -n %{_cross_os}logdog | ||
%{_cross_bindir}/logdog | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[Unit] | ||
Description=Send boot success | ||
# The unit depends on 'configured.target' since Metricdog indirectly | ||
# depends on the proxy.env file created by settings-applier in the | ||
# preconfigured target | ||
After=network-online.target configured.target | ||
Wants=network-online.target configured.target | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=true | ||
EnvironmentFile=/etc/network/proxy.env | ||
ExecStart=-/usr/bin/metricdog send-boot-success | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[Unit] | ||
Description=Isolates configured.target | ||
After=preconfigured.target | ||
Requires=preconfigured.target | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/systemctl set-default configured | ||
ExecStart=/usr/bin/systemctl isolate default | ||
RemainAfterExit=true | ||
StandardError=journal+console | ||
|
||
[Install] | ||
WantedBy=preconfigured.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[Unit] | ||
Description=Isolates multi-user.target | ||
After=configured.target | ||
Requires=configured.target | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/bin/systemctl set-default multi-user | ||
ExecStart=/usr/bin/systemctl isolate default | ||
RemainAfterExit=true | ||
StandardError=journal+console | ||
|
||
[Install] | ||
WantedBy=configured.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
[Unit] | ||
Description=Bottlerocket user and dynamic configuration complete | ||
After=settings-applier.service | ||
Requires=settings-applier.service early-boot-config.service | ||
Description=Bottlerocket final configuration complete | ||
After=preconfigured.target | ||
Requires=preconfigured.target | ||
AllowIsolate=yes | ||
|
||
[Install] | ||
RequiredBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[Unit] | ||
Description=Multi-User System | ||
Documentation=man:systemd.special(7) | ||
Requires=basic.target configured.target | ||
Conflicts=rescue.service rescue.target | ||
After=basic.target rescue.service rescue.target configured.target | ||
AllowIsolate=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[Unit] | ||
Description=Bottlerocket initial configuration complete | ||
AllowIsolate=yes | ||
After=basic.target | ||
Requires=basic.target | ||
# Prevent manually starting/stopping the target | ||
RefuseManualStart=true | ||
RefuseManualStop=true | ||
|
||
[Install] | ||
RequiredBy=configured.target multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.