Skip to content

Commit

Permalink
Merge PR ceph#31181 into master
Browse files Browse the repository at this point in the history
* refs/pull/31181/head:
	ceph-daemon: only pass podman -it if need an interactive shell

Reviewed-by: Sebastian Wagner <[email protected]>
Reviewed-by: Michael Fritch <[email protected]>
  • Loading branch information
liewegas committed Oct 29, 2019
2 parents cfc1f71 + 8c7dbec commit 3c0df44
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
1 change: 1 addition & 0 deletions .githubmap
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,4 @@ travisn Travis Nielsen <[email protected]>
sidharthanup Sidharth Anupkrishnan <[email protected]>
varshar16 Varsha Rao <[email protected]>
guits Guillaume Abrioux <[email protected]>
mgfritch Michael Fritch <[email protected]>
40 changes: 28 additions & 12 deletions src/ceph-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,10 @@ def get_container_mounts(fsid, daemon_type, daemon_id):

return mounts

def get_container(fsid, daemon_type, daemon_id, privileged=False):
podman_args = []
def get_container(fsid, daemon_type, daemon_id, privileged=False,
podman_args=None):
if not podman_args:
podman_args = []
if daemon_type == 'osd' or privileged:
podman_args += ['--privileged']
return CephContainer(
Expand Down Expand Up @@ -710,9 +712,7 @@ class CephContainer:
return [
podman_path,
'run',
'-it',
'--net=host',
'--env', 'LANG=C',
] + self.podman_args + envs + vols + [
'--entrypoint', cmd[0],
self.image
Expand All @@ -722,8 +722,7 @@ class CephContainer:
return [
podman_path,
'exec',
'--env', 'LANG=C',
'-it',
] + self.podman_args + [
self.cname,
] + cmd

Expand Down Expand Up @@ -1133,20 +1132,39 @@ def command_shell():
mounts[pathify(args.config)] = '/etc/ceph/ceph.conf:z'
if args.keyring:
mounts[pathify(args.keyring)] = '/etc/ceph/ceph.keyring:z'
podman_args = ['--privileged']
if args.command:
command = args.command
else:
command = ['bash']
podman_args += [
'-it',
'--env', 'LANG=C',
]
c = CephContainer(
image=args.image,
entrypoint='doesnotmatter',
args=[],
podman_args=['--privileged'],
podman_args=podman_args,
volume_mounts=mounts)
return subprocess.call(c.shell_cmd(args.command))
return subprocess.call(c.shell_cmd(command))

##################################

def command_enter():
(daemon_type, daemon_id) = args.name.split('.')
c = get_container(args.fsid, daemon_type, daemon_id)
return subprocess.call(c.exec_cmd(args.command))
podman_args = []
if args.command:
command = args.command
else:
command = ['bash']
podman_args += [
'-it',
'--env', 'LANG=C',
]
c = get_container(args.fsid, daemon_type, daemon_id,
podman_args=podman_args)
return subprocess.call(c.exec_cmd(command))

##################################

Expand Down Expand Up @@ -1510,7 +1528,6 @@ parser_shell.add_argument(
help='ceph.keyring to pass through to the container')
parser_shell.add_argument(
'command', nargs='*',
default=['bash'],
help='command (optional)')

parser_enter = subparsers.add_parser(
Expand All @@ -1526,7 +1543,6 @@ parser_enter.add_argument(
help='daemon name (type.id)')
parser_enter.add_argument(
'command', nargs='*',
default=['bash'],
help='command')

parser_ceph_volume = subparsers.add_parser(
Expand Down

0 comments on commit 3c0df44

Please sign in to comment.