TCIB: Fix debug mode for oslo process execute

When pushing with buildah, there is no logfile options.
It dumps results of work to stderr.
In debug mode, we want those results logged. But we do not
reconfigure oslo.log defaults, so it skips all details as
it goes with INFO config instead.

Capture debug results of process execution utility for buildah
push and use the current logging context as well.

Also oslo process utils will log the time it took to do
buildah bud builds as a nice free bonus.

Change-Id: I5177408258b6d33daa26239e7b5c4f017b9372cf
Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
changes/44/763544/2
Bogdan Dobrelya 2 years ago
parent b316787336
commit e05e6bdf13
  1. 12
      tripleo_common/image/builder/buildah.py
  2. 9
      tripleo_common/utils/process.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.

@ -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

Loading…
Cancel
Save