Commit 676da1f5 authored by BAIRE Anthony's avatar BAIRE Anthony
Browse files

fix pull()

parent f013c296
......@@ -589,29 +589,43 @@ class ImageManager:
def pull(self, version_id: int, *, swarm=False):
with report_error("unable to pull version id %d to %s", version_id,
("swarm" if swarm else "sandbox")):
assert 0, "TODO"
ses = self.ctrl.session
with ses.begin():
# get the version object and check its state
version = ses.query(WebappVersion).filter_by(id=version_id).one()
image = self.ctrl.gen_image_name(version.webapp)
tag = version.number
if swarm:
# pull to the swarm
# TODO: wait for push if webapp is dirty
# if dirty:
# await self.push(webapp, version)
yield from self.push(webapp, version)
if version.state == VersionState.committed:
# must be pushed to the registry first
yield from self.push(version_id)
with ses.begin():
version = ses.query(WebappVersion).filter_by(id=version_id).one()
if version.state != VersionState.ready:
raise Error("bad version state: %s" % version.state)
yield from self.swarm_pull_manager.process((image, tag))
yield from self.sandbox_pull_manager.process((webapp.image, version))
else:
# pull to sid
# pull to the sandbox
if version.state == VersionState.committed:
# do not pull!
return
# TODO: pull only if not dirty
# if dirty:
# return
yield from self.sandbox_pull_manager.process((webapp.image, version))
if version.state != VersionState.ready:
raise Error("bad version state: %s" % version.state)
yield from self.sandbox_pull_manager.process((image, tag))
# return a future
@ensure_future
@asyncio.coroutine
def push(self, version_id: int):
return self.sandbox_push_manager.process(version_id)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment