]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/vstart_runner: allow writing to command's stdin
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 18 May 2023 13:52:10 +0000 (09:52 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 1 Aug 2023 15:16:27 +0000 (11:16 -0400)
There's no technical reason to disallow this. The original intent was to
avoid deadlocks but this possibility is already present when interacting
with a teuthology RemoteProcess. Avoiding it only for local processes
does not make sense.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
qa/tasks/vstart_runner.py

index df4886fb669757bc62ea2b58cf3a5b219ffd9ca0..6549dcaf11bee167ba44cab2c963672fb82298d3 100644 (file)
@@ -204,6 +204,7 @@ class LocalRemoteProcess(object):
     def __init__(self, args, subproc, check_status, stdout, stderr, usr_args):
         self.args = args
         self.subproc = subproc
+        self.stdin = subproc.stdin
         self.stdout = stdout
         self.stderr = stderr
         self.usr_args = usr_args
@@ -233,6 +234,12 @@ class LocalRemoteProcess(object):
             self.stderr.write(err)
 
     def wait(self):
+        # Null subproc.stdin so communicate() does not try flushing/closing it
+        # again.
+        if self.stdin is not None and self.stdin.closed:
+            self.stdin = None
+            self.subproc.stdin = None
+
         if self.finished:
             # Avoid calling communicate() on a dead process because it'll
             # give you stick about std* already being closed
@@ -285,16 +292,6 @@ class LocalRemoteProcess(object):
         else:
             log.debug(f"kill: already terminated ({self.usr_args})")
 
-    @property
-    def stdin(self):
-        class FakeStdIn(object):
-            def __init__(self, mount_daemon):
-                self.mount_daemon = mount_daemon
-
-            def close(self):
-                self.mount_daemon.kill()
-
-        return FakeStdIn(self)
 
 
 class LocalRemote(RemoteShell):