Remove buffering when running koji commands
If the compose is aborted while koji tasks are running, we can be left with empty log files. That complicates debugging. JIRA: RHELCMP-1218 Signed-off-by: Ondrej Nosek <onosek@redhat.com>
This commit is contained in:
parent
54882a0fc4
commit
d9f111edae
@ -242,6 +242,9 @@ class KojiWrapper(object):
|
||||
@contextlib.contextmanager
|
||||
def get_koji_cmd_env(self):
|
||||
"""Get environment variables for running a koji command.
|
||||
Buffering is disabled - if the compose is aborted while koji tasks are
|
||||
running, we can be left with empty log files. That complicates
|
||||
debugging.
|
||||
|
||||
If we are authenticated with a keytab, we need a fresh credentials
|
||||
cache to avoid possible race condition.
|
||||
@ -250,9 +253,10 @@ class KojiWrapper(object):
|
||||
with util.temp_dir(prefix="krb_ccache") as tempdir:
|
||||
env = os.environ.copy()
|
||||
env["KRB5CCNAME"] = "DIR:%s" % tempdir
|
||||
env["PYTHONUNBUFFERED"] = "1"
|
||||
yield env
|
||||
else:
|
||||
yield None
|
||||
yield {"PYTHONUNBUFFERED": "1"}
|
||||
|
||||
def run_runroot_cmd(self, command, log_file=None):
|
||||
"""Run koji runroot command and wait for results.
|
||||
@ -269,6 +273,7 @@ class KojiWrapper(object):
|
||||
logfile=log_file,
|
||||
show_cmd=True,
|
||||
env=env,
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
)
|
||||
|
||||
@ -510,6 +515,7 @@ class KojiWrapper(object):
|
||||
can_fail=True,
|
||||
logfile=log_file,
|
||||
env=env,
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
)
|
||||
|
||||
|
@ -625,7 +625,8 @@ class RunrootKojiWrapperTest(KojiWrapperBaseTestCase):
|
||||
mock.call(
|
||||
cmd,
|
||||
can_fail=True,
|
||||
env=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
logfile=None,
|
||||
show_cmd=True,
|
||||
universal_newlines=True,
|
||||
@ -653,7 +654,8 @@ class RunrootKojiWrapperTest(KojiWrapperBaseTestCase):
|
||||
mock.call(
|
||||
cmd,
|
||||
can_fail=True,
|
||||
env=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
logfile=None,
|
||||
show_cmd=True,
|
||||
universal_newlines=True,
|
||||
@ -682,7 +684,12 @@ class RunrootKojiWrapperTest(KojiWrapperBaseTestCase):
|
||||
mock.call(
|
||||
cmd,
|
||||
can_fail=True,
|
||||
env={"KRB5CCNAME": "DIR:/tmp/foo", "FOO": "BAR"},
|
||||
env={
|
||||
"KRB5CCNAME": "DIR:/tmp/foo",
|
||||
"FOO": "BAR",
|
||||
"PYTHONUNBUFFERED": "1",
|
||||
},
|
||||
buffer_size=-1,
|
||||
logfile=None,
|
||||
show_cmd=True,
|
||||
universal_newlines=True,
|
||||
@ -708,7 +715,8 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
)
|
||||
],
|
||||
@ -734,7 +742,12 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env={"KRB5CCNAME": "DIR:/tmp/foo", "FOO": "BAR"},
|
||||
env={
|
||||
"KRB5CCNAME": "DIR:/tmp/foo",
|
||||
"FOO": "BAR",
|
||||
"PYTHONUNBUFFERED": "1",
|
||||
},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
)
|
||||
],
|
||||
@ -756,7 +769,8 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile="logfile",
|
||||
env=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
)
|
||||
],
|
||||
@ -778,7 +792,8 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
)
|
||||
],
|
||||
@ -800,7 +815,8 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
)
|
||||
],
|
||||
@ -823,7 +839,8 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
),
|
||||
mock.call(
|
||||
@ -851,7 +868,8 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
),
|
||||
mock.call(
|
||||
@ -880,7 +898,8 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
),
|
||||
mock.call(
|
||||
@ -922,7 +941,8 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
),
|
||||
mock.call(
|
||||
@ -957,7 +977,8 @@ class RunBlockingCmdTest(KojiWrapperBaseTestCase):
|
||||
"cmd",
|
||||
can_fail=True,
|
||||
logfile=None,
|
||||
env=None,
|
||||
env={"PYTHONUNBUFFERED": "1"},
|
||||
buffer_size=-1,
|
||||
universal_newlines=True,
|
||||
),
|
||||
mock.call(
|
||||
|
Loading…
Reference in New Issue
Block a user