Skip to content

Commit

Permalink
Use Upholds= to ensure services run after daemon-reload
Browse files Browse the repository at this point in the history
When a systemd-sysext image is loaded, normally a daemon-reload is done
but the targets are not evaluated, meaning that enabled services don't
start. In Flatcar we ship a workaround for that by restarting a certain
list of targets but this is not upstream behavior. Currently upstream
also doesn't do the daemon-reload but we can file an upstream PR for
that.
  • Loading branch information
pothos committed Mar 20, 2023
1 parent 6ba139a commit bf99cb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 6 additions & 0 deletions convert_torcx_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ for FILE in "${SYSEXTNAME}"/usr/lib/systemd/system/*.service "${SYSEXTNAME}"/usr
-e 's,After=torcx.target,,g' -e 's,Requires=torcx.target,,g' "${FILE}"
fi
done
for ENTRY in "${SYSEXTNAME}/usr/lib/systemd/system/"*.wants/*; do
UNIT=$(basename "${ENTRY}")
TARGET=$(echo "${ENTRY}" | rev | cut -d / -f 2 | rev | sed 's/.wants$//')
mkdir -p "${SYSEXTNAME}/usr/lib/systemd/system/${TARGET}.d"
{ echo "[Unit]"; echo "Upholds=${UNIT}"; } > "${SYSEXTNAME}/usr/lib/systemd/system/${TARGET}.d/10-${UNIT/./-}.conf"
done
mkdir -p "${SYSEXTNAME}/usr/lib/extension-release.d"
{ echo "ID=flatcar" ; echo "SYSEXT_LEVEL=1.0" ; } > "${SYSEXTNAME}/usr/lib/extension-release.d/extension-release.${SYSEXTNAME}"
rm -f "${SYSEXTNAME}".raw
Expand Down
8 changes: 4 additions & 4 deletions create_docker_sysext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ if [ "${ONLY_CONTAINERD}" != 1 ]; then
[Install]
WantedBy=sockets.target
EOF
mkdir -p "${SYSEXTNAME}/usr/lib/systemd/system/sockets.target.wants"
ln -s ../docker.socket "${SYSEXTNAME}/usr/lib/systemd/system/sockets.target.wants/docker.socket"
mkdir -p "${SYSEXTNAME}/usr/lib/systemd/system/sockets.target.d"
{ echo "[Unit]"; echo "Upholds=docker.socket"; } > "${SYSEXTNAME}/usr/lib/systemd/system/sockets.target.d/10-docker-socket.conf"
cat > "${SYSEXTNAME}/usr/lib/systemd/system/docker.service" <<-'EOF'
[Unit]
Description=Docker Application Container Engine
Expand Down Expand Up @@ -120,8 +120,8 @@ if [ "${ONLY_DOCKER}" != 1 ]; then
[Install]
WantedBy=multi-user.target
EOF
mkdir -p "${SYSEXTNAME}/usr/lib/systemd/system/multi-user.target.wants"
ln -s ../containerd.service "${SYSEXTNAME}/usr/lib/systemd/system/multi-user.target.wants/containerd.service"
mkdir -p "${SYSEXTNAME}/usr/lib/systemd/system/multi-user.target.d"
{ echo "[Unit]"; echo "Upholds=containerd.service"; } > "${SYSEXTNAME}/usr/lib/systemd/system/multi-user.target.d/10-containerd-service.conf"
mkdir -p "${SYSEXTNAME}/usr/share/containerd"
cat > "${SYSEXTNAME}/usr/share/containerd/config.toml" <<-'EOF'
version = 2
Expand Down

0 comments on commit bf99cb1

Please sign in to comment.