kopia lustrzana https://github.com/jupyterhub/repo2docker
reduce redundant output when capturing late logs
it's unclear if late logs ever captures logs not already echoed, but this at least eliminates the redundant outputpull/1016/head
rodzic
eb75209019
commit
164efd31ab
|
@ -16,10 +16,10 @@ import getpass
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from .engine import BuildError, ContainerEngineException, ImageLoadError
|
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import escapism
|
import escapism
|
||||||
|
from iso8601 import parse_date
|
||||||
from pythonjsonlogger import jsonlogger
|
from pythonjsonlogger import jsonlogger
|
||||||
|
|
||||||
from traitlets import Any, Dict, Int, List, Unicode, Bool, default
|
from traitlets import Any, Dict, Int, List, Unicode, Bool, default
|
||||||
|
@ -38,6 +38,7 @@ from .buildpacks import (
|
||||||
RBuildPack,
|
RBuildPack,
|
||||||
)
|
)
|
||||||
from . import contentproviders
|
from . import contentproviders
|
||||||
|
from .engine import BuildError, ContainerEngineException, ImageLoadError
|
||||||
from .utils import ByteSpecification, chdir
|
from .utils import ByteSpecification, chdir
|
||||||
|
|
||||||
|
|
||||||
|
@ -629,9 +630,12 @@ class Repo2Docker(Application):
|
||||||
Displaying logs while it's running
|
Displaying logs while it's running
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
last_timestamp = None
|
||||||
try:
|
try:
|
||||||
for line in container.logs(stream=True):
|
for line in container.logs(stream=True, timestamps=True):
|
||||||
self.log.info(line.decode("utf-8"), extra=dict(phase="running"))
|
line = line.decode("utf-8")
|
||||||
|
last_timestamp, line = line.split(" ", maxsplit=1)
|
||||||
|
self.log.info(line, extra=dict(phase="running"))
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
container.reload()
|
container.reload()
|
||||||
|
@ -646,9 +650,16 @@ class Repo2Docker(Application):
|
||||||
"Container finished running.\n".upper(), extra=dict(phase="running")
|
"Container finished running.\n".upper(), extra=dict(phase="running")
|
||||||
)
|
)
|
||||||
# are there more logs? Let's send them back too
|
# are there more logs? Let's send them back too
|
||||||
late_logs = container.logs().decode("utf-8")
|
if last_timestamp:
|
||||||
|
# docker only accepts integer timestamps
|
||||||
|
# this means we will usually replay logs from the last second
|
||||||
|
# of the container
|
||||||
|
# we should check if this ever returns anything new,
|
||||||
|
# since we know it ~always returns something redundant
|
||||||
|
last_timestamp = int(parse_date(last_timestamp).timestamp())
|
||||||
|
late_logs = container.logs(since=last_timestamp).decode("utf-8")
|
||||||
for line in late_logs.split("\n"):
|
for line in late_logs.split("\n"):
|
||||||
self.log.info(line + "\n", extra=dict(phase="running"))
|
self.log.debug(line + "\n", extra=dict(phase="running"))
|
||||||
|
|
||||||
container.remove()
|
container.remove()
|
||||||
if exit_code:
|
if exit_code:
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -50,6 +50,7 @@ setup(
|
||||||
"docker",
|
"docker",
|
||||||
"entrypoints",
|
"entrypoints",
|
||||||
"escapism",
|
"escapism",
|
||||||
|
"iso8601",
|
||||||
"jinja2",
|
"jinja2",
|
||||||
"python-json-logger",
|
"python-json-logger",
|
||||||
"requests",
|
"requests",
|
||||||
|
|
Ładowanie…
Reference in New Issue