Add error handler to os-refresh-config
Previously on error the program simply exitted. This will allow script writers to write error handlers to be called whenever any phase fails. Change-Id: I3f8025663700192e9d8132a0e9122b4e0085ebbd
This commit is contained in:
parent
fd60517cb8
commit
64d3619302
@ -9,6 +9,7 @@ pre-defined set of directories::
|
|||||||
/opt/stack/os-config-refresh/configure.d
|
/opt/stack/os-config-refresh/configure.d
|
||||||
/opt/stack/os-config-refresh/post-configure.d
|
/opt/stack/os-config-refresh/post-configure.d
|
||||||
/opt/stack/os-config-refresh/migration.d
|
/opt/stack/os-config-refresh/migration.d
|
||||||
|
/opt/stack/os-config-refresh/error.d
|
||||||
|
|
||||||
`/opt/stack/os-config-refresh` is the default base directory. You can
|
`/opt/stack/os-config-refresh` is the default base directory. You can
|
||||||
set `OS_REFRESH_CONFIG_BASE_DIR` environment variable to override the
|
set `OS_REFRESH_CONFIG_BASE_DIR` environment variable to override the
|
||||||
@ -21,10 +22,10 @@ Its intended purpose is to separate scripts execution into 4 phases:
|
|||||||
3. Activate(post-configure.d).
|
3. Activate(post-configure.d).
|
||||||
4. Migrate(migration.d),
|
4. Migrate(migration.d),
|
||||||
|
|
||||||
It runs through all the phases above to ensure configuration is
|
It runs through all the phases above to ensure configuration is applied
|
||||||
applied and enabled on a machine. It will exit with an error if any
|
and enabled on a machine. It will run the scripts in error.d and then
|
||||||
phase has a problem. The scripts in each phase should not depend on
|
exit with a non-zero exit status if any phase has a problem. The scripts
|
||||||
each other having worked properly.
|
in each phase should not depend on each other having worked properly.
|
||||||
|
|
||||||
Note: Earlier versions of os-refresh-config ran migration before
|
Note: Earlier versions of os-refresh-config ran migration before
|
||||||
post-configure. This was an oversight in the initial design, as
|
post-configure. This was an oversight in the initial design, as
|
||||||
|
@ -91,6 +91,13 @@ def main(argv=sys.argv):
|
|||||||
log.info('Completed phase %s' % phase)
|
log.info('Completed phase %s' % phase)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
log.error("during %s phase. [%s]\n" % (phase, e))
|
log.error("during %s phase. [%s]\n" % (phase, e))
|
||||||
|
error_dir = os.path.join(BASE_DIR, 'error.d')
|
||||||
|
if os.path.exists(error_dir):
|
||||||
|
log.info('Calling error handlers.')
|
||||||
|
try:
|
||||||
|
subprocess.call(['dib-run-parts', error_dir])
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
log.error("Aborting...")
|
log.error("Aborting...")
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user