]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-daemon: only pass podman -it if need an interactive shell
authorSage Weil <sage@redhat.com>
Sun, 27 Oct 2019 17:29:36 +0000 (12:29 -0500)
committerSage Weil <sage@redhat.com>
Tue, 29 Oct 2019 14:41:16 +0000 (09:41 -0500)
Otherwise, we get errors like

2019-10-26T17:29:42.004 INFO:tasks.workunit.client.0.mira109.stderr:+ sudo /usr/sbin/ceph-daemon shell -- ceph -v
2019-10-26T17:29:42.004 INFO:tasks.workunit.client.0.mira109.stderr:+ grep 'ceph version'
2019-10-26T17:29:42.149 INFO:tasks.workunit.client.0.mira109.stderr:the input device is not a TTY

Fixes: https://tracker.ceph.com/issues/42499
Signed-off-by: Sage Weil <sage@redhat.com>
src/ceph-daemon

index 831baa773566b049f78b37d6190683248a5efb0d..949af8ffb27e29f830d41897bdf5ca4cb951bc4e 100755 (executable)
@@ -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(
@@ -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
@@ -722,8 +722,7 @@ class CephContainer:
         return [
             podman_path,
             'exec',
-            '--env', 'LANG=C',
-            '-it',
+        ] + self.podman_args + [
             self.cname,
         ] + cmd
 
@@ -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))
 
 ##################################
 
@@ -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(
@@ -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(