Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildgrid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
Show more breadcrumbs
BuildGrid
buildgrid
Commits
4ad5feca
Commit
4ad5feca
authored
6 years ago
by
Martin Blanchard
Browse files
Options
Downloads
Patches
Plain Diff
storage/remote.py: Port to new CAS downloader helper
#79
parent
e7769a3e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildgrid/server/cas/storage/remote.py
+11
-24
11 additions, 24 deletions
buildgrid/server/cas/storage/remote.py
with
11 additions
and
24 deletions
buildgrid/server/cas/storage/remote.py
+
11
−
24
View file @
4ad5feca
...
...
@@ -23,11 +23,16 @@ Forwwards storage requests to a remote storage.
import
io
import
logging
<<<<<<<
HEAD
import
grpc
from
buildgrid.utils
import
gen_fetch_blob
,
gen_write_request_blob
=======
from
buildgrid.client.cas
import
download
>>>>>>>
storage
/
remote
.
py
:
Port
to
new
CAS
downloader
helper
from
buildgrid._protos.google.bytestream
import
bytestream_pb2_grpc
from
buildgrid._protos.build.bazel.remote.execution.v2
import
remote_execution_pb2
,
remote_execution_pb2_grpc
from
buildgrid.utils
import
gen_write_request_blob
from
.storage_abc
import
StorageABC
...
...
@@ -36,7 +41,10 @@ class RemoteStorage(StorageABC):
def
__init__
(
self
,
channel
,
instance_name
):
self
.
logger
=
logging
.
getLogger
(
__name__
)
self
.
_instance_name
=
instance_name
self
.
instance_name
=
instance_name
self
.
channel
=
channel
self
.
_stub_bs
=
bytestream_pb2_grpc
.
ByteStreamStub
(
channel
)
self
.
_stub_cas
=
remote_execution_pb2_grpc
.
ContentAddressableStorageStub
(
channel
)
...
...
@@ -46,29 +54,8 @@ class RemoteStorage(StorageABC):
return
False
def
get_blob
(
self
,
digest
):
try
:
fetched_data
=
io
.
BytesIO
()
length
=
0
for
data
in
gen_fetch_blob
(
self
.
_stub_bs
,
digest
,
self
.
_instance_name
):
length
+=
fetched_data
.
write
(
data
)
if
length
:
assert
digest
.
size_bytes
==
length
fetched_data
.
seek
(
0
)
return
fetched_data
else
:
return
None
except
grpc
.
RpcError
as
e
:
if
e
.
code
()
==
grpc
.
StatusCode
.
NOT_FOUND
:
pass
else
:
self
.
logger
.
error
(
e
.
details
())
raise
return
None
with
download
(
self
.
channel
,
instance
=
self
.
instance_name
)
as
cas
:
return
io
.
BytesIO
(
cas
.
get_blob
(
digest
))
def
begin_write
(
self
,
digest
):
return
io
.
BytesIO
(
digest
.
SerializeToString
())
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment