Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
obs-proxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
infrastructure
obs-proxy
Commits
185b6ce3
Unverified
Commit
185b6ce3
authored
1 year ago
by
Andrej Shadura
Browse files
Options
Downloads
Patches
Plain Diff
Use structlog in chunked client
Signed-off-by:
Andrej Shadura
<
andrew.shadura@collabora.co.uk
>
parent
e474c661
No related branches found
No related tags found
No related merge requests found
Pipeline
#585887
failed
1 year ago
Stage: test
Stage: docker
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
obs_proxy/chunked_uploads/client.py
+10
-5
10 additions, 5 deletions
obs_proxy/chunked_uploads/client.py
with
10 additions
and
5 deletions
obs_proxy/chunked_uploads/client.py
+
10
−
5
View file @
185b6ce3
...
...
@@ -11,13 +11,15 @@
import
hashlib
from
dataclasses
import
dataclass
from
logging
import
debu
g
import
structlo
g
import
httpx
from
aiofiles.threadpool
import
AsyncFileIO
from
werkzeug.datastructures
import
ContentRange
from
werkzeug.http
import
unquote_etag
logger
=
structlog
.
get_logger
()
UPLOAD_CHUNK_SIZE
=
512
*
1024
*
1024
MAX_ATTEMPTS
=
5
...
...
@@ -78,28 +80,31 @@ async def upload_chunked(
exc
=
None
for
attempt
in
range
(
MAX_ATTEMPTS
):
try
:
debug
(
f
"
patching
{
uri
}
(
{
len
(
chunk
)
}
{
content_range
}
)
"
)
logger
.
debug
(
"
patching
"
,
uri
=
uri
,
size
=
len
(
chunk
)
,
content_range
=
content_range
,
attempt
=
attempt
)
)
r
=
await
client
.
patch
(
uri
,
content
=
chunk
,
headers
=
chunk_headers
,
**
kv
,
)
logger
.
debug
(
"
patch result
"
,
result
=
r
)
if
r
.
is_success
:
break
else
:
r
.
raise_for_status
()
except
httpx
.
HTTPStatusError
as
e
:
if
not
e
.
response
.
is_server_error
:
logger
.
debug
(
"
not server error, not retrying
"
,
resp
=
e
.
response
)
raise
debug
(
f
"
retrying (
{
attempt
}
)
"
)
logger
.
exception
(
"
retrying
"
,
attempt
=
attempt
)
exc
=
e
except
httpx
.
HTTPError
as
e
:
debug
(
f
"
retrying (
{
attempt
}
)
"
)
logger
.
exception
(
"
retrying
"
,
attempt
=
attempt
)
exc
=
e
else
:
raise
exc
logger
.
debug
(
"
get etag
"
,
uri
=
uri
)
# now verify the hash
r
=
await
client
.
head
(
uri
,
...
...
@@ -108,7 +113,7 @@ async def upload_chunked(
calculated_hash
=
file_hasher
.
hexdigest
()
etag
,
_
=
unquote_etag
(
r
.
headers
.
get
(
"
etag
"
))
debug
(
"
f{etag = } vs {
calculated_hash
= }
"
)
logger
.
debug
(
"
check upload
"
,
etag
=
etag
,
calculated_hash
=
calculated_hash
)
if
etag
!=
calculated_hash
:
raise
ChunkedUploadVerificationError
(
...
...
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