Logging traceback for key injection error in robot tests 58/12058/6
authoraticig <gulsum.atici@canonical.com>
Mon, 16 May 2022 20:03:54 +0000 (23:03 +0300)
committeraticig <gulsum.atici@canonical.com>
Mon, 16 May 2022 21:24:50 +0000 (00:24 +0300)
Add traceback for key injection error in robot tests
and increase the paramiko ssh client timeout from 10s to 30s.

Change-Id: I4f0c24f550e98dc072210cebb36a57b4530818ac
Signed-off-by: aticig <gulsum.atici@canonical.com>
NG-RO/osm_ng_ro/ns_thread.py
RO-plugin/osm_ro_plugin/vimconn.py
releasenotes/notes/adding_traceback-4a7ab809ca34682c.yaml [new file with mode: 0644]

index d728d70..cfd36ec 100644 (file)
@@ -32,6 +32,7 @@ import queue
 from shutil import rmtree
 import threading
 import time
+import traceback
 from unittest.mock import Mock
 
 from importlib_metadata import entry_points
@@ -604,6 +605,7 @@ class VimInteractionVdu(VimInteractionBase):
         except (vimconn.VimConnException, NsWorkerException) as e:
             retries += 1
 
+            self.logger.debug(traceback.format_exc())
             if retries < self.max_retries_inject_ssh_key:
                 return (
                     "BUILD",
index 50e14fa..8b207b1 100644 (file)
@@ -33,6 +33,7 @@ from io import StringIO
 import logging
 import socket
 import sys
+import traceback
 import warnings
 
 import paramiko
@@ -766,32 +767,32 @@ class VimConnector:
 
                 client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
                 client.connect(
-                    ip_addr, username=user, password=password, pkey=pkey, timeout=10
+                    ip_addr, username=user, password=password, pkey=pkey, timeout=30
                 )
 
                 for command in commands:
-                    (i, o, e) = client.exec_command(command, timeout=10)
+                    (i, o, e) = client.exec_command(command, timeout=30)
                     returncode = o.channel.recv_exit_status()
                     outerror = e.read()
 
                     if returncode != 0:
                         text = "run_command='{}' Error='{}'".format(command, outerror)
+                        self.logger.debug(traceback.format_tb(e.__traceback__))
                         raise VimConnUnexpectedResponse(
                             "Cannot inject ssh key in VM: '{}'".format(text)
                         )
-
                         return
             except (
                 socket.error,
                 paramiko.AuthenticationException,
                 paramiko.SSHException,
             ) as message:
+                self.logger.debug(traceback.format_exc())
                 raise VimConnUnexpectedResponse(
                     "Cannot inject ssh key in VM: '{}' - {}".format(
                         ip_addr, str(message)
                     )
                 )
-
                 return
 
     # Optional methods
diff --git a/releasenotes/notes/adding_traceback-4a7ab809ca34682c.yaml b/releasenotes/notes/adding_traceback-4a7ab809ca34682c.yaml
new file mode 100644 (file)
index 0000000..42beebc
--- /dev/null
@@ -0,0 +1,21 @@
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+---
+other:
+  - |
+    If there are more than one VNF in a NS, sometimes ssh key injection is failing in the second VNF.
+    Adding traceback and increasing the paramiko ssh client connection timeout from 10 second to 30 second.