kopia lustrzana https://github.com/jupyterhub/repo2docker
Merge pull request #727 from minrk/full-progress
include full docker progress events in push progress eventspull/517/head
commit
37774fc288
|
@ -453,24 +453,39 @@ class Repo2Docker(Application):
|
||||||
client = docker.APIClient(version="auto", **kwargs_from_env())
|
client = docker.APIClient(version="auto", **kwargs_from_env())
|
||||||
# Build a progress setup for each layer, and only emit per-layer
|
# Build a progress setup for each layer, and only emit per-layer
|
||||||
# info every 1.5s
|
# info every 1.5s
|
||||||
|
progress_layers = {}
|
||||||
layers = {}
|
layers = {}
|
||||||
last_emit_time = time.time()
|
last_emit_time = time.time()
|
||||||
for line in client.push(self.output_image_spec, stream=True):
|
for chunk in client.push(self.output_image_spec, stream=True):
|
||||||
progress = json.loads(line.decode("utf-8"))
|
# each chunk can be one or more lines of json events
|
||||||
if "error" in progress:
|
# split lines here in case multiple are delivered at once
|
||||||
self.log.error(progress["error"], extra=dict(phase="failed"))
|
for line in chunk.splitlines():
|
||||||
raise docker.errors.ImageLoadError(progress["error"])
|
line = line.decode("utf-8", errors="replace")
|
||||||
if "id" not in progress:
|
try:
|
||||||
continue
|
progress = json.loads(line)
|
||||||
if "progressDetail" in progress and progress["progressDetail"]:
|
except Exception as e:
|
||||||
layers[progress["id"]] = progress["progressDetail"]
|
self.log.warning("Not a JSON progress line: %r", line)
|
||||||
else:
|
continue
|
||||||
layers[progress["id"]] = progress["status"]
|
if "error" in progress:
|
||||||
if time.time() - last_emit_time > 1.5:
|
self.log.error(progress["error"], extra=dict(phase="failed"))
|
||||||
self.log.info(
|
raise docker.errors.ImageLoadError(progress["error"])
|
||||||
"Pushing image\n", extra=dict(progress=layers, phase="pushing")
|
if "id" not in progress:
|
||||||
)
|
continue
|
||||||
last_emit_time = time.time()
|
# deprecated truncated-progress data
|
||||||
|
if "progressDetail" in progress and progress["progressDetail"]:
|
||||||
|
progress_layers[progress["id"]] = progress["progressDetail"]
|
||||||
|
else:
|
||||||
|
progress_layers[progress["id"]] = progress["status"]
|
||||||
|
# include full progress data for each layer in 'layers' data
|
||||||
|
layers[progress["id"]] = progress
|
||||||
|
if time.time() - last_emit_time > 1.5:
|
||||||
|
self.log.info(
|
||||||
|
"Pushing image\n",
|
||||||
|
extra=dict(
|
||||||
|
progress=progress_layers, layers=layers, phase="pushing"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
last_emit_time = time.time()
|
||||||
self.log.info(
|
self.log.info(
|
||||||
"Successfully pushed {}".format(self.output_image_spec),
|
"Successfully pushed {}".format(self.output_image_spec),
|
||||||
extra=dict(phase="pushing"),
|
extra=dict(phase="pushing"),
|
||||||
|
|
Ładowanie…
Reference in New Issue