Fix backup nova instance with creating job error

Currently, it will fail when doing nova backup with creating
a backup job. It is because freezer-scheduler will call freezer-agent
with '--config config-file', but the config opts in config-file (from
job file) were not parsed to CONF, at the same time EngineManager uses
the CONF.engine_name(now it is the default 'tar'), this will lead the
code go into wrong branch, although it will not throw errors and show
the backup is success, but when doing restore after this, we can find
that the backup data can not be used and print EOF error in log file.

This patch will fix the above issue.

Change-Id: I826e4ed71dfd2cde6103e8432faba7adb4648c36
Closes-Bug: #1710238
This commit is contained in:
Pengju Jiao 2017-08-11 23:15:55 +08:00
parent f83de1a0e5
commit 50df2c8ca3
1 changed files with 7 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import sys
import tempfile
from oslo_config import cfg
from oslo_config.cfg import NoSuchOptError
from oslo_log import log
from oslo_utils import encodeutils
@ -550,6 +551,12 @@ def get_backup_args():
defaults['log_config_append'] = None
defaults.update(conf.default)
for config_key in conf.default.keys():
try:
CONF.set_override(config_key, conf.default[config_key])
except NoSuchOptError:
LOG.debug('No such opt, {0}, so set it'.format(config_key))
setattr(CONF, config_key, conf.default[config_key])
if defaults['log_file']:
CONF.set_override('log_file', defaults['log_file'])