Skip to content

Commit dba8b78

Browse files
phlogistonjohnadk3798
authored andcommitted
mgr/cephadm: update get_container_image function
Update get_container_image to be a public function as it is only called by code outside of its class. Add a 2nd boolean argument that forces the use of a ceph image regardless of what the passed service name is. This new flag will be used to create ceph image based sidecars for other services. Signed-off-by: John Mulligan <[email protected]> (cherry picked from commit d1815c6) Resolves: rhbz#2364414
1 parent a9a7642 commit dba8b78

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/pybind/mgr/cephadm/module.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,8 +1719,19 @@ def _client_keyring_rm(
17191719
self._kick_serve_loop()
17201720
return HandleCommandResult()
17211721

1722-
def _get_container_image(self, daemon_name: str, use_current_daemon_image: bool = False) -> Optional[str]:
1723-
daemon_type = daemon_name.split('.', 1)[0] # type: ignore
1722+
def get_container_image(
1723+
self,
1724+
daemon_name: str,
1725+
use_current_daemon_image: bool = False,
1726+
force_ceph_image: bool = False,
1727+
) -> Optional[str]:
1728+
"""Return an image for the given daemon_name.
1729+
If `use_current_daemon_image` is set the function will try to re-use
1730+
the image for an existing service.
1731+
If force_ceph_image is true the daemon_name will be ignored and the
1732+
main ceph container image will be returned.
1733+
"""
1734+
daemon_type = daemon_name.split('.', 1)[0]
17241735
image: Optional[str] = None
17251736
# Try to use current image if specified. This is necessary
17261737
# because, if we're reconfiguring the daemon, we can
@@ -1740,7 +1751,7 @@ def _get_container_image(self, daemon_name: str, use_current_daemon_image: bool
17401751
except OrchestratorError:
17411752
self.log.debug(f'Could not find daemon {daemon_name} in cache '
17421753
'while searching for its image')
1743-
if daemon_type in CEPH_IMAGE_TYPES:
1754+
if daemon_type in CEPH_IMAGE_TYPES or force_ceph_image:
17441755
# get container image
17451756
image = str(self.get_foreign_ceph_option(
17461757
utils.name_to_config_section(daemon_name),

src/pybind/mgr/cephadm/serve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1903,7 +1903,7 @@ async def _run_cephadm(self,
19031903
# Skip the image check for daemons deployed that are not ceph containers
19041904
if not str(entity).startswith(bypass_image):
19051905
if not image and entity is not cephadmNoImage:
1906-
image = self.mgr._get_container_image(
1906+
image = self.mgr.get_container_image(
19071907
entity,
19081908
use_current_daemon_image=use_current_daemon_image
19091909
)

0 commit comments

Comments
 (0)