Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
14d2f39a
Commit
14d2f39a
authored
7 months ago
by
Erwan Rouchet
Committed by
Bastien Abadie
7 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove configurations before cleaning up archived workers
parent
7202709f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2432
Remove configurations before cleaning up archived workers
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/documents/management/commands/cleanup.py
+4
-0
4 additions, 0 deletions
arkindex/documents/management/commands/cleanup.py
arkindex/documents/tests/commands/test_cleanup.py
+14
-0
14 additions, 0 deletions
arkindex/documents/tests/commands/test_cleanup.py
with
18 additions
and
0 deletions
arkindex/documents/management/commands/cleanup.py
+
4
−
0
View file @
14d2f39a
...
@@ -304,6 +304,10 @@ class Command(BaseCommand):
...
@@ -304,6 +304,10 @@ class Command(BaseCommand):
continue
continue
self
.
stdout
.
write
(
f
"
Removing worker
{
worker
.
name
}
(
{
worker
.
id
}
)
"
)
self
.
stdout
.
write
(
f
"
Removing worker
{
worker
.
name
}
(
{
worker
.
id
}
)
"
)
# worker.delete would only try to set configurations to None on the WorkerRuns instead of deleting them,
# which could cause errors on unique constraints. We delete those runs instead, and do so with _raw_delete
# so that we don't update or delete anything more than worker runs.
WorkerRun
.
objects
.
filter
(
configuration__worker
=
worker
).
_raw_delete
(
using
=
"
default
"
)
worker
.
delete
()
worker
.
delete
()
deleted
+=
1
deleted
+=
1
...
...
This diff is collapsed.
Click to expand it.
arkindex/documents/tests/commands/test_cleanup.py
+
14
−
0
View file @
14d2f39a
...
@@ -1124,6 +1124,20 @@ class TestCleanupCommand(FixtureTestCase):
...
@@ -1124,6 +1124,20 @@ class TestCleanupCommand(FixtureTestCase):
removable_worker
.
archived
=
datetime
.
now
(
timezone
.
utc
)
-
timedelta
(
days
=
11
)
removable_worker
.
archived
=
datetime
.
now
(
timezone
.
utc
)
-
timedelta
(
days
=
11
)
removable_worker
.
save
()
removable_worker
.
save
()
# Create a process where a worker version is used both with and without a configuration from this worker
# This could lead to integrity errors with the default Django removal, as the configuration would be removed
# from the WorkerRuns, so there would be 2 runs with the same version and no configuration when they should be unique
process
=
self
.
corpus
.
processes
.
create
(
mode
=
ProcessMode
.
Workers
,
creator
=
self
.
superuser
)
version
=
removable_worker
.
versions
.
first
()
process
.
worker_runs
.
create
(
version
=
version
)
process
.
worker_runs
.
create
(
version
=
version
,
configuration
=
removable_worker
.
configurations
.
create
(
name
=
"
Some configuration
"
,
configuration
=
{},
),
)
# This worker cannot be cleaned up because it is used in ML results
# This worker cannot be cleaned up because it is used in ML results
used_worker
=
Worker
.
objects
.
get
(
slug
=
"
reco
"
)
used_worker
=
Worker
.
objects
.
get
(
slug
=
"
reco
"
)
self
.
assertTrue
(
used_worker
.
versions
.
all
().
in_use
())
self
.
assertTrue
(
used_worker
.
versions
.
all
().
in_use
())
...
...
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