From 1c21a746c7290ecb839a5d03c7573349d2a5dec4 Mon Sep 17 00:00:00 2001 From: aticig Date: Mon, 16 May 2022 23:03:54 +0300 Subject: [PATCH] Logging traceback for key injection error in robot tests 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 --- NG-RO/osm_ng_ro/ns_thread.py | 2 ++ RO-plugin/osm_ro_plugin/vimconn.py | 9 ++++---- .../adding_traceback-4a7ab809ca34682c.yaml | 21 +++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/adding_traceback-4a7ab809ca34682c.yaml diff --git a/NG-RO/osm_ng_ro/ns_thread.py b/NG-RO/osm_ng_ro/ns_thread.py index c381595e..8a5c5c1e 100644 --- a/NG-RO/osm_ng_ro/ns_thread.py +++ b/NG-RO/osm_ng_ro/ns_thread.py @@ -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 @@ -596,6 +597,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", diff --git a/RO-plugin/osm_ro_plugin/vimconn.py b/RO-plugin/osm_ro_plugin/vimconn.py index 0b780132..312c307a 100644 --- a/RO-plugin/osm_ro_plugin/vimconn.py +++ b/RO-plugin/osm_ro_plugin/vimconn.py @@ -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 index 00000000..42beebc8 --- /dev/null +++ b/releasenotes/notes/adding_traceback-4a7ab809ca34682c.yaml @@ -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. -- 2.25.1