From 453a36ee53d00d13620fb75c56e7b31a93752ebb Mon Sep 17 00:00:00 2001 From: Daniel-Pivonka Date: Tue, 17 Nov 2020 14:05:05 -0500 Subject: [PATCH] cephadm: fix podman failure to pull authenticated registry image from systemd unit have podman keep auth file in /var/lic/ceph/ becasue podman commands run from systemd do not have access to the default location and the default location is not consistant depending on the user logged in as, where your using sudo or not. Signed-off-by: Daniel-Pivonka --- src/cephadm/cephadm | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 2b18283dfefe4..55fa04da7044c 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -2597,6 +2597,10 @@ class CephContainer: '--rm', '--ipc=host', ] + + if 'podman' in container_path and os.path.exists('/etc/ceph/podman-auth.json'): + cmd_args.append('--authfile=/etc/ceph/podman-auth.json') + envs: List[str] = [ '-e', 'CONTAINER_IMAGE=%s' % self.image, '-e', 'NODE_NAME=%s' % get_hostname(), @@ -2739,6 +2743,8 @@ def _pull_image(image): ] cmd = [container_path, 'pull', image] + if 'podman' in container_path and os.path.exists('/etc/ceph/podman-auth.json'): + cmd.append('--authfile=/etc/ceph/podman-auth.json') cmd_str = ' '.join(cmd) for sleep_secs in [1, 4, 25]: @@ -3392,10 +3398,14 @@ def command_registry_login(): def registry_login(url, username, password): logger.info("Logging into custom registry.") try: - out, _, _ = call_throws([container_path, 'login', - '-u', username, - '-p', password, - url]) + cmd = [container_path, 'login', + '-u', username, '-p', password, + url] + if 'podman' in container_path: + cmd.append('--authfile=/etc/ceph/podman-auth.json') + out, _, _ = call_throws(cmd) + if 'podman' in container_path: + os.chmod('/etc/ceph/podman-auth.json', 0o600) except: raise Error("Failed to login to custom registry @ %s as %s with given password" % (args.registry_url, args.registry_username)) @@ -3870,7 +3880,7 @@ def list_daemons(detail=True, legacy_dir=None): elif is_fsid(i): fsid = str(i) # convince mypy that fsid is a str here for j in os.listdir(os.path.join(data_dir, i)): - if '.' in j: + if '.' in j and os.path.isdir(os.path.join(data_dir, fsid, j)): name = j (daemon_type, daemon_id) = j.split('.', 1) unit_name = get_unit_name(fsid, -- 2.39.5