Skip to content
Snippets Groups Projects
Commit f16da81b authored by Raoul Hidalgo Charman's avatar Raoul Hidalgo Charman
Browse files

cas: move push_message into CASRemote

Part of #802
parent 3dc85269
No related branches found
No related tags found
No related merge requests found
Pipeline #39719352 failed
......@@ -733,7 +733,7 @@ class ArtifactCache():
"servers are configured as push remotes.")
for remote in push_remotes:
message_digest = self.cas.push_message(remote, message)
message_digest = remote.push_message(message)
return message_digest
......
......@@ -331,29 +331,6 @@ class CASCache():
self._send_directory(remote, directory.ref)
# push_message():
#
# Push the given protobuf message to a remote.
#
# Args:
# remote (CASRemote): The remote to push to
# message (Message): A protobuf message to push.
#
# Raises:
# (CASError): if there was an error
#
def push_message(self, remote, message):
message_buffer = message.SerializeToString()
message_digest = utils._message_digest(message_buffer)
remote.init()
with io.BytesIO(message_buffer) as b:
remote._send_blob(message_digest, b)
return message_digest
# objpath():
#
# Return the path of an object based on its digest.
......
......@@ -229,6 +229,28 @@ class CASRemote():
return True
# push_message():
#
# Push the given protobuf message to a remote.
#
# Args:
# message (Message): A protobuf message to push.
#
# Raises:
# (CASError): if there was an error
#
def push_message(self, message):
message_buffer = message.SerializeToString()
message_digest = utils._message_digest(message_buffer)
remote.init()
with io.BytesIO(message_buffer) as b:
remote._send_blob(message_digest, b)
return message_digest
################################################
# Local Private Methods #
################################################
......
......@@ -310,12 +310,12 @@ class SandboxRemote(Sandbox):
# Push command and action
try:
cascache.push_message(casremote, command_proto)
casremote.push_message(command_proto)
except grpc.RpcError as e:
raise SandboxError("Failed to push command to remote: {}".format(e))
try:
cascache.push_message(casremote, action)
casremote.push_message(action)
except grpc.RpcError as e:
raise SandboxError("Failed to push action to remote: {}".format(e))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment