Fix exception not raised while install script failed

In kubernetes_mgmt, it will find 'Install Failed!\n' in stdout
to judge raise a exception of script install failed.

However in recent fix, we changed error message from script,
thus kubernetes_mgmt cannot catch error msg from stdout,
exception will not be raised.

This patch will fix matching error message in kuberntes_mgmt.

Closes-Bug: #1922192
Change-Id: Iffb3e045cbe121aca0fc74621cc5b3b5daf69f5b
This commit is contained in:
LiangLu
2021-04-02 09:01:26 +08:00
parent a6811d2c59
commit 206cc80e1f
3 changed files with 6 additions and 12 deletions

View File

@@ -765,7 +765,7 @@ fi
if [[ "$INSTALL_MODE" =~ "master" ]]; then if [[ "$INSTALL_MODE" =~ "master" ]]; then
result=$(kubectl get nodes -o wide | grep $CURRENT_HOST_IP) result=$(kubectl get nodes -o wide | grep $CURRENT_HOST_IP)
if [[ -z "$result" ]];then if [[ -z "$result" ]];then
echo "Install Failed! The node does not in Kubernetes cluster." echo "Install Failed! The node does not exist in Kubernetes cluster."
exit 255 exit 255
else else
echo "Install Success!" echo "Install Success!"
@@ -775,7 +775,7 @@ else
"This node has joined the cluster" ]]; then "This node has joined the cluster" ]]; then
echo "Install Success!" echo "Install Success!"
else else
echo "Install Failed! The node does not in Kubernetes cluster." echo "Install Failed! The node does not exist in Kubernetes cluster."
exit 255 exit 255
fi fi
fi fi

View File

@@ -97,17 +97,11 @@ class KubernetesMgmtDriver(vnflcm_abstract_driver.VnflcmMgmtAbstractDriver):
stdout = result.get_stdout() stdout = result.get_stdout()
LOG.debug(stdout) LOG.debug(stdout)
LOG.debug(err) LOG.debug(err)
elif type == 'certificate_key': elif type == 'certificate_key' or type == 'install':
if '[upload-certs] Using certificate key:\n' not \ if result.get_return_code() != 0:
in result.get_stdout():
err = result.get_stderr() err = result.get_stderr()
LOG.error(err) LOG.error(err)
raise exceptions.MgmtDriverRemoteCommandError(err_info=err) raise exceptions.MgmtDriverRemoteCommandError(err_info=err)
elif type == 'install':
err = result.get_stderr()
if 'Install Failed!\n' in result.get_stdout():
LOG.error(err)
raise exceptions.MgmtDriverRemoteCommandError(err_info=err)
return result.get_stdout() return result.get_stdout()
def _create_vim(self, context, vnf_instance, server, bearer_token, def _create_vim(self, context, vnf_instance, server, bearer_token,

View File

@@ -9,9 +9,9 @@ Content-Type: application/x-iso9066-image
Name: Scripts/install_k8s_cluster.sh Name: Scripts/install_k8s_cluster.sh
Content-Type: application/sh Content-Type: application/sh
Algorithm: SHA-256 Algorithm: SHA-256
Hash: 2489f6162817cce794a6f19a88c3c76ce83fa19cfcb75ad1204d76aaba4a9d1c Hash: bc859fb8ffb9f92a19139553bdd077428a2c9572196e5844f1c912a7a822c249
Name: Scripts/kubernetes_mgmt.py Name: Scripts/kubernetes_mgmt.py
Content-Type: text/x-python Content-Type: text/x-python
Algorithm: SHA-256 Algorithm: SHA-256
Hash: b292bc47d4c28a62b1261e6481498118e5dd93aa988c498568560f67c510003b Hash: b8c558cad30f219634a668f84d6e04998949e941f3909b5c60374b84dff58545