cephadm: Support Docker Live Restore

Currently with Docker Live Restore [1] enabled and while restarting
Docker Engine - all Ceph container images will get restarted,
while the feature allows restarting docker.service without
containers downtime.

This is due to Requires=docker.service in systemd units templates,
which mandates that on docker.service restart - the ceph container
systemd units will be restarted as well.

Reworking Requires= to Wants= that is a weaker version of the former,
see [2].

Leaving After= entries, because they should allow systemd to correctly
order the startup (first docker, then ceph containers).

[1]: https://docs.docker.com/engine/daemon/live-restore/
[2]: https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html#Wants=

Fixes: https://tracker.ceph.com/issues/68028

Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
This commit is contained in:
Michal Nasiadka 2024-09-11 14:26:37 +02:00
parent fc70b44875
commit e0f7768652
5 changed files with 10 additions and 6 deletions

View File

@ -24,6 +24,10 @@ Requirements
Any modern Linux distribution should be sufficient. Dependencies
are installed automatically by the bootstrap process below.
See `Docker Live Restore <https://docs.docker.com/engine/daemon/live-restore/>`_
for an optional feature that allows restarting Docker Engine without restarting
all running containers.
See the section :ref:`Compatibility With Podman
Versions<cephadm-compatibility-with-podman>` for a table of Ceph versions that
are compatible with Podman. Not every version of Podman is compatible with

View File

@ -9,7 +9,7 @@ Description=Ceph %i for {{fsid}}
After=network-online.target local-fs.target time-sync.target{% if has_docker_engine %} docker.service{% endif %}
Wants=network-online.target local-fs.target time-sync.target
{%- if has_docker_engine %}
Requires=docker.service
Wants=docker.service
{%- endif %}
PartOf=ceph-{{fsid}}.target

View File

@ -5,7 +5,7 @@ After=network-online.target local-fs.target time-sync.target
Wants=network-online.target local-fs.target time-sync.target
{%- if has_docker_engine %}
After=docker.service
Requires=docker.service
Wants=docker.service
{%- endif %}
Before=ceph-{{ identity.fsid }}@%i.service

View File

@ -5,7 +5,7 @@ After=network-online.target local-fs.target time-sync.target
Wants=network-online.target local-fs.target time-sync.target
{%- if has_docker_engine %}
After=docker.service
Requires=docker.service
Wants=docker.service
{%- endif %}
After={{ primary.service_name }}

View File

@ -27,11 +27,11 @@ def _get_unit_file(ctx, fsid):
return str(systemd_unit._get_unit_file(ctx, fsid))
def test_docker_engine_requires_docker():
def test_docker_engine_wants_docker():
ctx = context.CephadmContext()
ctx.container_engine = mock_docker()
r = _get_unit_file(ctx, '9b9d7609-f4d5-4aba-94c8-effa764d96c9')
assert 'Requires=docker.service' in r
assert 'Wants=docker.service' in r
def test_podman_engine_does_not_req_docker():
@ -80,7 +80,7 @@ def test_new_docker():
'# configuration.',
'After=network-online.target local-fs.target time-sync.target docker.service',
'Wants=network-online.target local-fs.target time-sync.target',
'Requires=docker.service',
'Wants=docker.service',
'PartOf=ceph-9b9d7609-f4d5-4aba-94c8-effa764d96c9.target',
'Before=ceph-9b9d7609-f4d5-4aba-94c8-effa764d96c9.target',
'[Service]',