Log ssh & scp related issues also on screen 16/72316/3
authorLuc Provoost <luc.provoost@intel.com>
Fri, 2 Apr 2021 12:53:09 +0000 (14:53 +0200)
committerLuc Provoost <luc.provoost@intel.com>
Wed, 7 Apr 2021 12:31:18 +0000 (12:31 +0000)
When scripts are doing an ssh or scp to the PROX instances, errors were
sometimes hidden. E.g. when we try to upload a config file to the PROX
instance that is already existing but owned by another user, we would
not see the error on the screen.
Note this will only happen if you build your own image. In case you use
the pre-canned PROX images, this should not cause issues.

Change-Id: I94176b737cd548c93afc71450a85910d7eca2b0c
Signed-off-by: Luc Provoost <luc.provoost@intel.com>
VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py

index 3389bd6..9f4539c 100644 (file)
@@ -59,8 +59,6 @@ class prox_ctrl(object):
                 if attempts > 20:
                     RapidLog.exception("Failed to connect to instance after %d\
                             attempts:\n%s" % (attempts, ex))
-                    raise Exception("Failed to connect to instance after %d \
-                            attempts:\n%s" % (attempts, ex))
                 time.sleep(2)
                 RapidLog.debug("Trying to connect to machine \
                        on %s, attempt: %d" % (self._ip, attempts))
@@ -79,8 +77,6 @@ class prox_ctrl(object):
             if attempts > 20:
                 RapidLog.exception("Failed to connect to PROX on %s after %d \
                         attempts" % (self._ip, attempts))
-                raise Exception("Failed to connect to PROX on %s after %d \
-                        attempts" % (self._ip, attempts))
             time.sleep(2)
             RapidLog.debug("Trying to connect to PROX (just launched) on %s, \
                     attempt: %d" % (self._ip, attempts))
@@ -101,10 +97,7 @@ class prox_ctrl(object):
         try:
             return subprocess.check_output(cmd, stderr=subprocess.STDOUT)
         except subprocess.CalledProcessError as ex:
-            #if _connect and ex.returncode == 255:
-            if _connect:
-                raise RuntimeWarning(ex.output.strip())
-            raise RuntimeError('ssh returned exit status %d:\n%s'
+            RapidLog.exception('ssh returned exit status %d:\n%s'
                     % (ex.returncode, ex.output.strip()))
 
     def prox_sock(self, port=8474):
@@ -139,7 +132,7 @@ class prox_ctrl(object):
             # Actually ignore output on success, but capture stderr on failure
             subprocess.check_output(cmd, stderr=subprocess.STDOUT)
         except subprocess.CalledProcessError as ex:
-            raise RuntimeError('scp returned exit status %d:\n%s'
+            RapidLog.exception('scp returned exit status %d:\n%s'
                     % (ex.returncode, ex.output.strip()))
 
     def scp_get(self, src, dst):
@@ -161,7 +154,7 @@ class prox_ctrl(object):
             # Actually ignore output on success, but capture stderr on failure
             subprocess.check_output(cmd, stderr=subprocess.STDOUT)
         except subprocess.CalledProcessError as ex:
-            raise RuntimeError('scp returned exit status %d:\n%s'
+            RapidLog.exception('scp returned exit status %d:\n%s'
                     % (ex.returncode, ex.output.strip()))
 
     def _build_ssh(self, command):