diff --git a/tripleo_common/image/builder/buildah.py b/tripleo_common/image/builder/buildah.py index d921e9f9e..74dab545a 100644 --- a/tripleo_common/image/builder/buildah.py +++ b/tripleo_common/image/builder/buildah.py @@ -67,6 +67,8 @@ class BuildahBuilder(base.BaseBuilder): """ logging.register_options(CONF) + if debug: + CONF.debug = True logging.setup(CONF, '') super(BuildahBuilder, self).__init__() @@ -212,7 +214,15 @@ class BuildahBuilder(base.BaseBuilder): 'docker://' + destination] self.log.info("Pushing %s image with: %s" % (destination, ' '.join(args))) - process.execute(*args, run_as_root=False, use_standard_locale=True) + if self.debug: + # buildah push logs to stderr, since there is no --log* opt + # so we'll use the current logging context for that + process.execute(*args, log_stdout=True, run_as_root=False, + use_standard_locale=True, logger=self.log, + loglevel=logging.DEBUG) + else: + process.execute(*args, run_as_root=False, + use_standard_locale=True) def build_all(self, deps=None): """Build all containers. diff --git a/tripleo_common/utils/process.py b/tripleo_common/utils/process.py index 3087340d6..f6600ce3f 100644 --- a/tripleo_common/utils/process.py +++ b/tripleo_common/utils/process.py @@ -43,6 +43,7 @@ def execute(*cmd, **kwargs): :raises: OSError """ + logger = kwargs.pop('logger', LOG) use_standard_locale = kwargs.pop('use_standard_locale', False) if use_standard_locale: env = kwargs.pop('env_variables', os.environ.copy()) @@ -50,9 +51,9 @@ def execute(*cmd, **kwargs): kwargs['env_variables'] = env log_stdout = kwargs.pop('log_stdout', True) result = processutils.execute(*cmd, **kwargs) - LOG.debug('Execution completed, command line is "%s"', - ' '.join(map(str, cmd))) + logger.debug('Execution completed, command line is "%s"', + ' '.join(map(str, cmd))) if log_stdout: - LOG.debug('Command stdout is: "%s"', result[0]) - LOG.debug('Command stderr is: "%s"', result[1]) + logger.debug('Command stdout is: "%s"', result[0]) + logger.debug('Command stderr is: "%s"', result[1]) return result