fix 1010. Proper exception handling when looking for used kdu name 57/8557/1
authortierno <alfonso.tiernosepulveda@telefonica.com>
Tue, 4 Feb 2020 15:26:25 +0000 (15:26 +0000)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Tue, 4 Feb 2020 15:26:37 +0000 (15:26 +0000)
Change-Id: Ieaa07ddd0dcd3901a242665ef8306e6f08b23c3a
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
n2vc/k8s_helm_conn.py

index 01b448b..3541db6 100644 (file)
@@ -370,8 +370,8 @@ class K8sHelmConnector(K8sConnector):
                 if result is not None:
                     # instance already exists: generate a new one
                     kdu_instance = None
                 if result is not None:
                     # instance already exists: generate a new one
                     kdu_instance = None
-            except Exception as e:
-                kdu_instance = None
+            except K8sException:
+                pass
 
         # helm repo install
         command = '{} install {} --output yaml --kubeconfig={} --home={} {} {} --name={} {} {}'\
 
         # helm repo install
         command = '{} install {} --output yaml --kubeconfig={} --home={} {} {} --name={} {} {}'\
@@ -1113,7 +1113,7 @@ class K8sHelmConnector(K8sConnector):
                 self.debug('Return code: {}'.format(return_code))
 
             if raise_exception_on_error and return_code != 0:
                 self.debug('Return code: {}'.format(return_code))
 
             if raise_exception_on_error and return_code != 0:
-                raise Exception(output)
+                raise K8sException(output)
 
             if encode_utf8:
                 output = output.encode('utf-8').strip()
 
             if encode_utf8:
                 output = output.encode('utf-8').strip()
@@ -1121,12 +1121,13 @@ class K8sHelmConnector(K8sConnector):
 
             return output, return_code
 
 
             return output, return_code
 
+        except K8sException:
+            raise
         except Exception as e:
             msg = 'Exception executing command: {} -> {}'.format(command, e)
         except Exception as e:
             msg = 'Exception executing command: {} -> {}'.format(command, e)
-            if show_error_log:
-                self.error(msg)
+            self.error(msg)
             if raise_exception_on_error:
             if raise_exception_on_error:
-                raise e
+                raise K8sException(e) from e
             else:
                 return '', -1
 
             else:
                 return '', -1