From: Patricia Reinoso Date: Tue, 30 Aug 2022 16:08:48 +0000 (+0000) Subject: Fix bug 2149 X-Git-Tag: release-v13.0-start~11 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F12507%2F3;p=osm%2FN2VC.git Fix bug 2149 Set appropriate delete method for cluster role bindings in case of exception Change-Id: I187ec50dbec37ed9ff51e18234ab51e02c42ce40 Signed-off-by: Patricia Reinoso --- diff --git a/n2vc/k8s_juju_conn.py b/n2vc/k8s_juju_conn.py index 396d79b..6708748 100644 --- a/n2vc/k8s_juju_conn.py +++ b/n2vc/k8s_juju_conn.py @@ -156,7 +156,7 @@ class K8sJujuConnector(K8sConnector): self.log.debug("Role binding created") cleanup_data.append( { - "delete": kubectl.delete_service_account, + "delete": kubectl.delete_cluster_role_binding, "args": (metadata_name,), } ) diff --git a/n2vc/tests/unit/test_k8s_juju_conn.py b/n2vc/tests/unit/test_k8s_juju_conn.py index 3e35494..6119d50 100644 --- a/n2vc/tests/unit/test_k8s_juju_conn.py +++ b/n2vc/tests/unit/test_k8s_juju_conn.py @@ -134,9 +134,15 @@ class InitEnvTest(K8sJujuConnTestCase): uuid, created = self.loop.run_until_complete( self.k8s_juju_conn.init_env(k8s_creds=kubeconfig) ) - self.assertIsNone(created) self.assertIsNone(uuid) + self.kubectl.create_cluster_role.assert_called_once() + self.kubectl.create_service_account.assert_called_once() + self.kubectl.create_cluster_role_binding.assert_called_once() + self.kubectl.get_default_storage_class.assert_called_once() + self.kubectl.delete_cluster_role.assert_called_once() + self.kubectl.delete_service_account.assert_called_once() + self.kubectl.delete_cluster_role_binding.assert_called_once() self.k8s_juju_conn.libjuju.add_k8s.assert_called_once()