docker-cmd hook handle empty config file
Early in a server boot the file /var/run/heat-config/heat-config may exist but be empty. This causes a stack trace to be raised in this script. This change detects a json parse error and exits gracefully. Change-Id: I29d731098659bfbf10a2caf80c2cfc49de5df4cc Closes-Bug: #1648249
This commit is contained in:
parent
8ab13c5489
commit
d10069ac13
@ -45,7 +45,7 @@ def main(argv=sys.argv):
|
||||
log.setLevel('DEBUG')
|
||||
|
||||
if not os.path.exists(CONF_FILE):
|
||||
log.error('No config file %s' % CONF_FILE)
|
||||
log.warning('No config file %s' % CONF_FILE)
|
||||
return 1
|
||||
|
||||
if not os.path.isdir(WORKING_DIR):
|
||||
@ -53,8 +53,9 @@ def main(argv=sys.argv):
|
||||
|
||||
try:
|
||||
configs = json.load(open(CONF_FILE))
|
||||
except ValueError:
|
||||
pass
|
||||
except ValueError as e:
|
||||
log.warning('Could not load config json: %s' % e)
|
||||
return 1
|
||||
|
||||
cmd_configs = list(build_configs(configs))
|
||||
try:
|
||||
|
@ -22,7 +22,7 @@ from testtools import matchers
|
||||
from tests.software_config import common
|
||||
|
||||
|
||||
class HookDockerComposeTest(common.RunScriptTest):
|
||||
class HookDockerCmdTest(common.RunScriptTest):
|
||||
data = {
|
||||
"name": "abcdef001",
|
||||
"group": "docker-cmd",
|
||||
@ -52,7 +52,7 @@ class HookDockerComposeTest(common.RunScriptTest):
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(HookDockerComposeTest, self).setUp()
|
||||
super(HookDockerCmdTest, self).setUp()
|
||||
self.hook_path = self.relative_path(
|
||||
__file__,
|
||||
'../..',
|
||||
|
Loading…
Reference in New Issue
Block a user