forked from pulp/pulpcore
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unencrypted task args from database
fixes pulp#4546
- Loading branch information
Showing
4 changed files
with
51 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Removed old unencrypted task arguments from database. |
48 changes: 48 additions & 0 deletions
48
pulpcore/app/migrations/0114_remove_task_args_remove_task_kwargs.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Generated by Django 4.2.4 on 2023-09-11 13:26 | ||
|
||
from django.db import migrations | ||
from django.db.models import Q | ||
from packaging.version import parse as parse_version | ||
|
||
from pulpcore.migrations import RequireVersion | ||
|
||
|
||
def encrypt_task_args_up(apps, schema_editor): | ||
Task = apps.get_model("core", "Task") | ||
batch = [] | ||
for task in Task.objects.filter(Q(args__is_null=False) | Q(kwargs__is_null=False)): | ||
task.enc_args = task.args | ||
task.enc_kwargs = task.kwargs | ||
coreversion = task.versions.get("core") | ||
if coreversion is None or parse_version(coreversion) < parse_version("3.34.0"): | ||
task.versions["core"] = "3.34.0" | ||
|
||
batch.append(task) | ||
if len(batch) >= 500: | ||
Task.bulk_update(batch, fields=["enc_args", "enc_kwargs", "versions"]) | ||
batch = [] | ||
if batch: | ||
Task.bulk_update(batch, fields=["enc_args", "enc_kwargs", "versions"]) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("core", "0113_headercontentguard"), | ||
] | ||
|
||
operations = [ | ||
RequireVersion("core", "3.34.0"), | ||
migrations.RunPython( | ||
code=encrypt_task_args_up, | ||
reverse_code=migrations.RunPython.noop, | ||
elidable=True, | ||
), | ||
migrations.RemoveField( | ||
model_name="task", | ||
name="args", | ||
), | ||
migrations.RemoveField( | ||
model_name="task", | ||
name="kwargs", | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters