diff options
author | Jürg Billeter <j@bitron.ch> | 2019-09-19 11:45:42 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-09-19 14:20:21 +0200 |
commit | e555cc249ee295d23e8093422db5f8ba2214d23b (patch) | |
tree | df5bb4b4c0cd1b16f50143304bca1e8a0145b766 /src | |
parent | 08de3b1a405bda2c0de9174d7f82a619dd96b775 (diff) | |
download | buildstream-e555cc249ee295d23e8093422db5f8ba2214d23b.tar.gz |
_artifactcache.py: Move capabilities check to _check() and extend it
It's sufficient to check the capabilities once per bst session. This
avoids the extra round trip in remote.init().
This also adds a check for allow_updates for push remotes.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildstream/_artifactcache.py | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/buildstream/_artifactcache.py b/src/buildstream/_artifactcache.py index 2f2fdc8cb..f8d856be7 100644 --- a/src/buildstream/_artifactcache.py +++ b/src/buildstream/_artifactcache.py @@ -49,6 +49,19 @@ class ArtifactRemote(BaseRemote): # Remote.init(), and is expected to fail when called by itself. # def _configure_protocols(self): + # Set up artifact stub + self.artifact_service = artifact_pb2_grpc.ArtifactServiceStub(self.channel) + + # _check(): + # + # Check if this remote provides everything required for the + # particular kind of remote. This is expected to be called as part + # of check(), and must be called in a non-main process. + # + # Returns: + # (str|None): An error message, or None if no error message. + # + def _check(self): capabilities_service = buildstream_pb2_grpc.CapabilitiesStub(self.channel) # Check whether the server supports newer proto based artifact. @@ -60,19 +73,18 @@ class ArtifactRemote(BaseRemote): except grpc.RpcError as e: # Check if this remote has the artifact service if e.code() == grpc.StatusCode.UNIMPLEMENTED: - raise ArtifactError( - "Configured remote does not have the BuildStream " - "capabilities service. Please check remote configuration.") + return ("Configured remote does not have the BuildStream " + "capabilities service. Please check remote configuration.") # Else raise exception with details - raise ArtifactError( - "Remote initialisation failed: {}".format(e.details())) + return "Remote initialisation failed: {}".format(e.details()) if not response.artifact_capabilities: - raise ArtifactError( - "Configured remote does not support artifact service") + return "Configured remote does not support artifact service" - # Set up artifact stub - self.artifact_service = artifact_pb2_grpc.ArtifactServiceStub(self.channel) + if self.spec.push and not response.artifact_capabilities.allow_updates: + return 'Artifact server does not allow push' + + return None # get_artifact(): # |