summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam@afuera.me.uk>2018-07-03 23:44:44 +0200
committerSam Thursfield <sam@afuera.me.uk>2018-07-03 23:44:44 +0200
commitc50d64d903d1322733544eb86d730426af4a0812 (patch)
treee47d0c2e943ac35971736a114ca4a906f24725b9
parent9067e269a9f2866e659ef33a69aad72b01cb6633 (diff)
downloadbuildstream-sam/pushing-fix.tar.gz
_artifactcache/pushreceive.py: Avoid premature 'done' messagessam/pushing-fix
Code exists in OSTreePusher.needed_commits() to raise a PushExistsException() if the local commit (what we want to push) is not a descendent of the remote commit (what the artifact cache has). Code also exists in OSTreePusher.run() to ignore this exception, unless there are no refs that we can push. So situations occur where the push continues even though one of the refs can't be updated due to this inconsistency. That would be fine except that before we raise the PushExistsException, we call send_done() and hang up the connection. So the push goes on to fail with "Expected reply, got none" as the remote has already hung up. This commit moves the send_done() call further down so that it only happens once we know the PushExistsException is not going to be ignored.
-rw-r--r--buildstream/_artifactcache/pushreceive.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/buildstream/_artifactcache/pushreceive.py b/buildstream/_artifactcache/pushreceive.py
index 41dacf33f..5cd65b2e6 100644
--- a/buildstream/_artifactcache/pushreceive.py
+++ b/buildstream/_artifactcache/pushreceive.py
@@ -222,6 +222,7 @@ class PushMessageWriter(object):
self.write(command)
def send_done(self):
+ logging.info('Sending done')
command = PushCommand(PushCommandType.done, {})
self.write(command)
@@ -497,7 +498,6 @@ class OSTreePusher(object):
if parent is None:
break
if remote is not None and parent != remote:
- self.writer.send_done()
raise PushExistsException('Remote commit {} not descendent of '
'commit {}'.format(remote, local))
@@ -552,7 +552,6 @@ class OSTreePusher(object):
update_refs[branch] = remote_rev, rev
if not update_refs:
logging.info('Nothing to update')
- self.writer.send_done()
raise PushExistsException('Nothing to update')
# Send update command
@@ -583,6 +582,7 @@ class OSTreePusher(object):
# Re-raise PushExistsException if all refs exist already
if ref_count == 0 and exc_info:
+ self.writer.send_done()
raise exc_info[0].with_traceback(exc_info[1], exc_info[2])
logging.info('Enumerating objects to send')