Check if config param exists before using it

When using the cluster.stop_timeout_before_update config parameter,
check if it exists before using it.  That parameter is optional and
should not error if it is not specified.

Change-Id: Ic6b3172736f5cd348e391371f79defa1aeb790e6
This commit is contained in:
Duc Truong 2020-11-30 19:38:43 +00:00
parent 028af9be62
commit 4f585a2e70
1 changed files with 4 additions and 3 deletions

View File

@ -302,9 +302,10 @@ class ClusterAction(base.Action):
if config is not None:
# make sure config values are valid
try:
stop_timeout = config['cluster.stop_timeout_before_update']
config['cluster.stop_timeout_before_update'] = int(
stop_timeout)
stop_timeout = config.get('cluster.stop_timeout_before_update')
if stop_timeout:
config['cluster.stop_timeout_before_update'] = int(
stop_timeout)
except Exception as e:
return self.RES_ERROR, str(e)