]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/vstart_runner: don't let command run after timeout
authorRishabh Dave <ridave@redhat.com>
Wed, 3 Apr 2024 05:41:29 +0000 (11:11 +0530)
committerRishabh Dave <ridave@redhat.com>
Wed, 17 Apr 2024 04:39:59 +0000 (10:09 +0530)
Parameter "timeout" is accepted by LocalRemote.run() but the method
doesn't do anything about it besides accepting it. Thus, this parameter
has no effect.

In LocalRemote.run(), pass this parameter to LocalRemoteProcess.wait()
and from this method pass it to subprocess.Popen.communicate(). Thus,
command will be terminated by subprocess module at seconds specified by
"timeout" parameter. IOW, "timeout" parameter will have an effect.

Fixes: https://tracker.ceph.com/issues/65533
Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/vstart_runner.py

index 8d9dc6f1845c54170d993d3d3c8537617906d0d0..b5dbe3c5f97cdff9da75ad1d2953e5a26cabf319 100644 (file)
@@ -233,7 +233,7 @@ class LocalRemoteProcess(object):
         else:
             self.stderr.write(err)
 
-    def wait(self):
+    def wait(self, timeout=None):
         # Null subproc.stdin so communicate() does not try flushing/closing it
         # again.
         if self.stdin is not None and self.stdin.closed:
@@ -249,7 +249,7 @@ class LocalRemoteProcess(object):
             else:
                 return
 
-        out, err = self.subproc.communicate()
+        out, err = self.subproc.communicate(timeout=timeout)
         out, err = rm_nonascii_chars(out), rm_nonascii_chars(err)
         self._write_stdout(out)
         self._write_stderr(err)
@@ -488,7 +488,7 @@ sudo() {
         )
 
         if wait:
-            proc.wait()
+            proc.wait(timeout)
 
         return proc