-
Notifications
You must be signed in to change notification settings - Fork 2
Verify digest of file objects in mirror (#7069, #7089) #7090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Verify digest of file objects in mirror (#7069, #7089) #7090
Conversation
5675607
to
8ac6802
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #7090 +/- ##
===========================================
- Coverage 85.27% 85.18% -0.10%
===========================================
Files 151 152 +1
Lines 21846 21948 +102
===========================================
+ Hits 18629 18696 +67
- Misses 3217 3252 +35 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
33d63d0
to
50f39fb
Compare
50f39fb
to
37c4900
Compare
8ac6802
to
797754e
Compare
0071471
to
fe9a0b3
Compare
6cdc15d
to
cd69dc8
Compare
797754e
to
4e36a22
Compare
4e36a22
to
e084cdf
Compare
fcef109
to
8a18e23
Compare
febc6b6
to
e6143f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subject: [PATCH] REVIEW 1
---
Index: src/azul/digests.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/azul/digests.py b/src/azul/digests.py
--- a/src/azul/digests.py (revision 7e9ef6fe283c02343f85699fb2ea0e5c286f5ed1)
+++ b/src/azul/digests.py (date 1746601204964)
@@ -2,6 +2,7 @@
import pickle
from typing import (
Any,
+ TYPE_CHECKING,
)
import resumablesha256
@@ -10,8 +11,13 @@
R,
)
-# TODO: add type stub
-Hasher = Any
+if TYPE_CHECKING:
+ class Hasher:
+ def hexdigest(self) -> str: ...
+
+ def update(self, data: bytes, /) -> None: ...
+else:
+ Hasher = Any # REVIEW: without the else branch we would need to put any mention of Hasher in quotes, and the import would also need to be conditional on TYPE_CHECKING
def get_resumable_hasher(digest_type: str) -> Hasher:
Index: src/azul/azulclient.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/azul/azulclient.py b/src/azul/azulclient.py
--- a/src/azul/azulclient.py (revision 7e9ef6fe283c02343f85699fb2ea0e5c286f5ed1)
+++ b/src/azul/azulclient.py (date 1746600449726)
@@ -708,7 +708,7 @@
for file in plugin.list_files(source, prefix):
info_key = self.mirror_service.info_object_key(file)
if info_key in already_mirrored:
- log.info('Not mirroring file %r because an info object is already present at %r',
+ log.info('Not mirroring file %r because info object already exists at %r',
file.uuid, info_key)
else:
log.info('Mirroring file %r', file.uuid)
Index: src/azul/service/storage_service.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/azul/service/storage_service.py b/src/azul/service/storage_service.py
--- a/src/azul/service/storage_service.py (revision 7e9ef6fe283c02343f85699fb2ea0e5c286f5ed1)
+++ b/src/azul/service/storage_service.py (date 1746601204969)
@@ -37,9 +37,11 @@
)
from azul.collections import (
+ OrderedSet,
adict,
)
from azul.deployment import (
+ R,
aws,
)
@@ -114,14 +116,19 @@
**self._object_creation_kwargs(content_type=content_type, tagging=tagging),
**kwargs)
- def list(self, prefix: str) -> list[str]:
- keys = []
+ # REVIEW: Consider OrderedSet. It better reflects S3's ordering and uniqueness guarantees
+
+ def list(self, prefix: str) -> OrderedSet[str]:
+ keys, num_keys = OrderedSet(), 0
token = None
- while True:
+ while True: # REVIEW: Consider using a paginator (https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3/paginator/ListObjectsV2.html#listobjectsv2)
response = self._s3.list_objects_v2(Bucket=self.bucket_name,
Prefix=prefix,
**adict(ContinuationToken=token))
- keys.extend(object['Key'] for object in response.get('Contents', ()))
+ contents = response.get('Contents', ())
+ num_keys += len(contents)
+ keys.update(object['Key'] for object in contents)
+ assert len(keys) == num_keys, R('Got duplicate keys from S3')
token = response.get('NextContinuationToken')
if token is None:
break
7e9ef6f
to
3716614
Compare
1d26528
to
16a4215
Compare
Security design review
|
608521c
to
a007756
Compare
Connected issues: #7069
Checklist
Author
develop
issues/<GitHub handle of author>/<issue#>-<slug>
1 when the issue title describes a problem, the corresponding PR
title is
Fix:
followed by the issue titleAuthor (partiality)
p
tag to titles of partial commitspartial
or completely resolves all connected issuespartial
labelAuthor (chains)
base
or this PR is not chained to another PRchained
or is not chained to another PRAuthor (reindex, API changes)
r
tag to commit title or the changes introduced by this PR will not require reindexing of any deploymentreindex:dev
or the changes introduced by it will not require reindexing ofdev
reindex:anvildev
or the changes introduced by it will not require reindexing ofanvildev
reindex:anvilprod
or the changes introduced by it will not require reindexing ofanvilprod
reindex:prod
or the changes introduced by it will not require reindexing ofprod
reindex:partial
and its description documents the specific reindexing procedure fordev
,anvildev
,anvilprod
andprod
or requires a full reindex or carries none of the labelsreindex:dev
,reindex:anvildev
,reindex:anvilprod
andreindex:prod
API
or this PR does not modify a REST APIa
(A
) tag to commit title for backwards (in)compatible changes or this PR does not modify a REST APIapp.py
or this PR does not modify a REST APIAuthor (upgrading deployments)
make docker_images.json
and committed the resulting changes or this PR does not modifyazul_docker_images
, or any other variables referenced in the definition of that variableu
tag to commit title or this PR does not require upgrading deploymentsupgrade
or does not require upgrading deploymentsdeploy:shared
or does not modifydocker_images.json
, and does not require deploying theshared
component for any other reasondeploy:gitlab
or does not require deploying thegitlab
componentdeploy:runner
or does not require deploying therunner
imageAuthor (hotfixes)
F
tag to main commit title or this PR does not include permanent fix for a temporary hotfixanvilprod
andprod
) have temporary hotfixes for any of the issues connected to this PRAuthor (before every review)
develop
, squashed old fixupsmake requirements_update
or this PR does not modifyrequirements*.txt
,common.mk
,Makefile
andDockerfile
R
tag to commit title or this PR does not modifyrequirements*.txt
reqs
or does not modifyrequirements*.txt
make integration_test
passes in personal deployment or this PR does not modify functionality that could affect the IT outcomePeer reviewer (after approval)
PR is marked as approvedSystem administrator (after approval)
demo
orno demo
no demo
no sandbox
N reviews
label is accurateOperator (before pushing merge the commit)
reindex:…
labels andr
commit title tagno demo
develop
_select dev.shared && CI_COMMIT_REF_NAME=develop make -C terraform/shared apply_keep_unused
or this PR is not labeleddeploy:shared
_select dev.gitlab && CI_COMMIT_REF_NAME=develop make -C terraform/gitlab apply
or this PR is not labeleddeploy:gitlab
_select anvildev.shared && CI_COMMIT_REF_NAME=develop make -C terraform/shared apply_keep_unused
or this PR is not labeleddeploy:shared
_select anvildev.gitlab && CI_COMMIT_REF_NAME=develop make -C terraform/gitlab apply
or this PR is not labeleddeploy:gitlab
deploy:gitlab
deploy:gitlab
System administrator
dev.gitlab
are complete or this PR is not labeleddeploy:gitlab
anvildev.gitlab
are complete or this PR is not labeleddeploy:gitlab
Operator (before pushing merge the commit)
_select dev.gitlab && make -C terraform/gitlab/runner
or this PR is not labeleddeploy:runner
_select anvildev.gitlab && make -C terraform/gitlab/runner
or this PR is not labeleddeploy:runner
sandbox
label or PR is labeledno sandbox
dev
or PR is labeledno sandbox
anvildev
or PR is labeledno sandbox
sandbox
deployment or PR is labeledno sandbox
anvilbox
deployment or PR is labeledno sandbox
sandbox
deployment or PR is labeledno sandbox
anvilbox
deployment or PR is labeledno sandbox
sandbox
or this PR does not remove catalogs or otherwise causes unreferenced indices indev
anvilbox
or this PR does not remove catalogs or otherwise causes unreferenced indices inanvildev
sandbox
or this PR is not labeledreindex:dev
anvilbox
or this PR is not labeledreindex:anvildev
sandbox
or this PR is not labeledreindex:dev
anvilbox
or this PR is not labeledreindex:anvildev
p
if the PR is also labeledpartial
Operator (chain shortening)
develop
or this PR is not labeledbase
chained
label from the blocked PR or this PR is not labeledbase
base
base
label from this PR or this PR is not labeledbase
Operator (after pushing the merge commit)
dev
anvildev
dev
dev
anvildev
anvildev
_select dev.shared && make -C terraform/shared apply
or this PR is not labeleddeploy:shared
_select anvildev.shared && make -C terraform/shared apply
or this PR is not labeleddeploy:shared
dev
anvildev
Operator (reindex)
dev
or this PR is neither labeledreindex:partial
norreindex:dev
anvildev
or this PR is neither labeledreindex:partial
norreindex:anvildev
dev
or this PR is neither labeledreindex:partial
norreindex:dev
anvildev
or this PR is neither labeledreindex:partial
norreindex:anvildev
dev
or this PR is neither labeledreindex:partial
norreindex:dev
anvildev
or this PR is neither labeledreindex:partial
norreindex:anvildev
dev
or this PR does not require reindexingdev
anvildev
or this PR does not require reindexinganvildev
dev
or this PR does not require reindexingdev
anvildev
or this PR does not require reindexinganvildev
dev
or this PR does not require reindexingdev
anvildev
or this PR does not require reindexinganvildev
dev
or this PR does not require reindexingdev
dev
or this PR does not require reindexingdev
deploy_browser
job in the GitLab pipeline for this PR indev
or this PR does not require reindexingdev
anvildev
or this PR does not require reindexinganvildev
deploy_browser
job in the GitLab pipeline for this PR inanvildev
or this PR does not require reindexinganvildev
Operator
deploy:shared
,deploy:gitlab
,deploy:runner
,API
,reindex:partial
,reindex:anvilprod
andreindex:prod
labels to the next promotion PRs or this PR carries none of these labelsdeploy:shared
,deploy:gitlab
,deploy:runner
,API
,reindex:partial
,reindex:anvilprod
andreindex:prod
labels, from the description of this PR to that of the next promotion PRs or this PR carries none of these labelsShorthand for review comments
L
line is too longW
line wrapping is wrongQ
bad quotesF
other formatting problem