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>
(cherry picked from commit e05e6bdf13
)
This commit is contained in:
parent
b5e9f3bc68
commit
b1d64d69fa
|
@ -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…
Reference in New Issue