Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-scrubber
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antoine Lambert
swh-scrubber
Commits
c6f711ec
Commit
c6f711ec
authored
2 years ago
by
Nicolas Dandrimont
Browse files
Options
Downloads
Patches
Plain Diff
Replace verbose logging with statsd probes
parent
708b2b2c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/scrubber/storage_checker.py
+20
-3
20 additions, 3 deletions
swh/scrubber/storage_checker.py
with
20 additions
and
3 deletions
swh/scrubber/storage_checker.py
+
20
−
3
View file @
c6f711ec
...
...
@@ -11,6 +11,7 @@ import dataclasses
import
logging
from
typing
import
Iterable
,
Union
from
swh.core.statsd
import
statsd
from
swh.journal.serializers
import
value_to_kafka
from
swh.model
import
swhids
from
swh.model.model
import
(
...
...
@@ -91,7 +92,7 @@ class StorageChecker:
for
range_start
,
range_end
in
backfill
.
RANGE_GENERATORS
[
self
.
object_type
](
self
.
start_object
,
self
.
end_object
):
logger
.
info
(
logger
.
debug
(
"
Processing %s range %s to %s
"
,
self
.
object_type
,
backfill
.
_format_range_bound
(
range_start
),
...
...
@@ -103,22 +104,38 @@ class StorageChecker:
)
objects
=
list
(
objects
)
self
.
check_object_hashes
(
objects
)
self
.
check_object_references
(
objects
)
with
statsd
.
timed
(
"
swh_scrubber_batch_duration_seconds
"
,
tags
=
{
"
object_type
"
:
self
.
object_type
},
):
self
.
check_object_hashes
(
objects
)
self
.
check_object_references
(
objects
)
def
check_object_hashes
(
self
,
objects
:
Iterable
[
ScrubbableObject
]):
"""
Recomputes hashes, and reports mismatches.
"""
count
=
0
for
object_
in
objects
:
if
isinstance
(
object_
,
Content
):
# TODO
continue
real_id
=
object_
.
compute_hash
()
count
+=
1
if
object_
.
id
!=
real_id
:
statsd
.
increment
(
"
swh_scrubber_hash_mismatch_total
"
,
tags
=
{
"
object_type
"
:
self
.
object_type
},
)
self
.
db
.
corrupt_object_add
(
object_
.
swhid
(),
self
.
datastore_info
(),
value_to_kafka
(
object_
.
to_dict
()),
)
if
count
:
statsd
.
increment
(
"
swh_scrubber_objects_hashed_total
"
,
count
,
tags
=
{
"
object_type
"
:
self
.
object_type
},
)
def
check_object_references
(
self
,
objects
:
Iterable
[
ScrubbableObject
]):
"""
Check all objects references by these objects exist.
"""
...
...
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