From bf0bfef19594bf3748fed9ec957b5c868ab50b36 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Sat, 21 Oct 2023 11:28:30 -0400 Subject: [PATCH] cephadm: move some podman specific mount logic to podman class Signed-off-by: John Mulligan --- src/cephadm/cephadm.py | 11 +---------- src/cephadm/cephadmlib/container_engines.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/cephadm/cephadm.py b/src/cephadm/cephadm.py index c56bd6bc2a2..641b269c132 100755 --- a/src/cephadm/cephadm.py +++ b/src/cephadm/cephadm.py @@ -2647,17 +2647,8 @@ def get_container_mounts( def _update_podman_mounts(ctx: CephadmContext, mounts: Dict[str, str]) -> None: """Update the given mounts dict with mounts specific to podman.""" - # Modifications podman makes to /etc/hosts causes issues with - # certain daemons (specifically referencing "host.containers.internal" entry - # being added to /etc/hosts in this case). To avoid that, but still - # allow users to use /etc/hosts for hostname resolution, we can - # mount the host's /etc/hosts file. - # https://tracker.ceph.com/issues/58532 - # https://tracker.ceph.com/issues/57018 if isinstance(ctx.container_engine, Podman): - if os.path.exists('/etc/hosts'): - if '/etc/hosts' not in mounts: - mounts['/etc/hosts'] = '/etc/hosts:ro' + ctx.container_engine.update_mounts(ctx, mounts) def get_ceph_volume_container(ctx: CephadmContext, diff --git a/src/cephadm/cephadmlib/container_engines.py b/src/cephadm/cephadmlib/container_engines.py index 99d64ff015c..8ced8ab3ff4 100644 --- a/src/cephadm/cephadmlib/container_engines.py +++ b/src/cephadm/cephadmlib/container_engines.py @@ -2,7 +2,7 @@ import os -from typing import Tuple, List, Optional +from typing import Tuple, List, Optional, Dict from .call_wrappers import call_throws, CallVerbosity from .context import CephadmContext @@ -78,6 +78,21 @@ class Podman(ContainerEngine): args.append('--no-hosts') return args + def update_mounts( + self, ctx: CephadmContext, mounts: Dict[str, str] + ) -> None: + """Update mounts adding entries that are specific to podman.""" + # Modifications podman makes to /etc/hosts causes issues with certain + # daemons (specifically referencing "host.containers.internal" entry + # being added to /etc/hosts in this case). To avoid that, but still + # allow users to use /etc/hosts for hostname resolution, we can mount + # the host's /etc/hosts file. + # https://tracker.ceph.com/issues/58532 + # https://tracker.ceph.com/issues/57018 + if os.path.exists('/etc/hosts'): + if '/etc/hosts' not in mounts: + mounts['/etc/hosts'] = '/etc/hosts:ro' + class Docker(ContainerEngine): EXE = 'docker' -- 2.39.5