Skip to content

Commit e862630

Browse files
authored
Merge pull request #1008 from betatim/missing-logs
Investigating the missing logs
2 parents 055f8d2 + 6e372b5 commit e862630

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

repo2docker/app.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,12 +605,24 @@ def wait_for_container(self, container):
605605
try:
606606
for line in container.logs(stream=True):
607607
self.log.info(line.decode("utf-8"), extra=dict(phase="running"))
608+
608609
finally:
609610
container.reload()
610611
if container.status == "running":
611612
self.log.info("Stopping container...\n", extra=dict(phase="running"))
612613
container.kill()
613614
exit_code = container.attrs["State"]["ExitCode"]
615+
616+
container.wait()
617+
618+
self.log.info(
619+
"Container finished running.\n".upper(), extra=dict(phase="running")
620+
)
621+
# are there more logs? Let's send them back too
622+
late_logs = container.logs().decode("utf-8")
623+
for line in late_logs.split("\n"):
624+
self.log.info(line + "\n", extra=dict(phase="running"))
625+
614626
container.remove()
615627
if exit_code:
616628
sys.exit(exit_code)

repo2docker/buildpacks/repo2docker-entrypoint

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ if [[ ! -z "${R2D_ENTRYPOINT:-}" ]]; then
1515
if [[ ! -x "$R2D_ENTRYPOINT" ]]; then
1616
chmod u+x "$R2D_ENTRYPOINT"
1717
fi
18-
exec "$R2D_ENTRYPOINT" "$@" >&"$log_fd"
18+
exec "$R2D_ENTRYPOINT" "$@" 2>&1 >&"$log_fd"
1919
else
20-
exec "$@" >&"$log_fd"
20+
exec "$@" 2>&1 >&"$log_fd"
2121
fi
2222

2323
# Close the logging output again
24-
#exec {log_fd}>&-
24+
exec {log_fd}>&-

tests/unit/test_env.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ def test_env():
4242
# value
4343
"--env",
4444
"SPAM_2=",
45-
"--",
45+
# "--",
4646
tmpdir,
4747
"/bin/bash",
4848
"-c",
4949
# Docker exports all passed env variables, so we can
5050
# just look at exported variables.
51-
"export",
51+
"export; sleep 1",
52+
# "export; echo TIMDONE",
53+
# "export",
5254
],
5355
universal_newlines=True,
5456
stdout=subprocess.PIPE,
@@ -61,6 +63,9 @@ def test_env():
6163
# stdout should be empty
6264
assert not result.stdout
6365

66+
print(result.stderr.split("\n"))
67+
# assert False
68+
6469
# stderr should contain lines of output
6570
declares = [x for x in result.stderr.split("\n") if x.startswith("declare")]
6671
assert 'declare -x FOO="{}"'.format(ts) in declares

0 commit comments

Comments
 (0)