Skip to content

Management command for data repairs#7322

Merged
dralley merged 1 commit intopulp:mainfrom
dralley:datarepair
Feb 16, 2026
Merged

Management command for data repairs#7322
dralley merged 1 commit intopulp:mainfrom
dralley:datarepair

Conversation

@dralley
Copy link
Contributor

@dralley dralley commented Feb 16, 2026

Create a single reusable data repair management command for data repair operations happening outside of migrations.

Specifically in this case the motivation is to resolve the repository version memoization issues, but it can be reused in the future.

re #7272

Usage (ignore the warnings):

[root@cb0f1f0e9d34 src]# pulpcore-manager datarepair 7272 --dry-run
/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py:98: RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.
  warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)

In domain "default"
	Repository "test" (type "rpm.rpm") version 2 has a mismatch between the RepositoryContent and the cached ID set
	Repository "test" (type "rpm.rpm") version 2 has a mismatch between the RepositoryContent and RepositoryVersionContentDetails

Finished. (no changes)
[root@cb0f1f0e9d34 src]# pulpcore-manager datarepair 7272
/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py:98: RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.
  warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)

In domain "default"
	Repository "test" (type "rpm.rpm") version 2 has a mismatch between the RepositoryContent and the cached ID set
	Repository "test" (type "rpm.rpm") version 2 has a mismatch between the RepositoryContent and RepositoryVersionContentDetails

Finished. (1 repository versions fixed)
[root@cb0f1f0e9d34 src]# pulpcore-manager datarepair 7272 --dry-run
/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py:98: RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported.
  warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning)


Finished. (OK)
[root@cb0f1f0e9d34 src]# 

Copy link
Member

@mdellweg mdellweg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea.
And added whatever came first to my mind.


def add_arguments(self, parser):
"""Set up arguments."""
parser.add_argument("issue", help=_("The github issue # of the issue to be fixed."))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible for plugins to add datarepair operations, and how would we avoid name clashes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be possible, but some plugins (e.g. rpm) already have their own command (rpm-datarepair) for that purpose.

Comment on lines +27 to +30
help=_(
"Don't modify anything, just show the results of what would happen if this "
"command were run."
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe another option. But wouldn't it be nice to print some info paragraph about the selected repair?
It could sum up for example after what type of upgrade the data is expected to need repair (whenever we have that detail).

Copy link
Contributor Author

@dralley dralley Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean as help text, or as part of the execution of the command, including in dry-run mode?

Generally I would expect the user to know what they're running ahead of time, this isn't really the sort of thing to be running in an exploratory way. Even, to an extent, in --dry-run mode. Probably the user is coming to rectify some specific issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help text sounds fine. I just thought that maybe assuming we know how an inconsistency arose, we could briefly describe the situation so a user knowing they didn't come that way doesn't put high expectations in this. But maybe I'm in wonderland here.
This sure is not a requirement.

Create a single reusable data repair management command for data repair
operations happening outside of migrations.

Specifically in this case the motivation is to resolve the repository
version memoization issues, but it can be reused in the future.

re pulp#7272
@dralley
Copy link
Contributor Author

dralley commented Feb 16, 2026

A progress counter / indicator would be "nice to have" here I suppose, unless someone wants to call it a "must have"

@dralley dralley merged commit 93330ec into pulp:main Feb 16, 2026
13 checks passed
@dralley dralley deleted the datarepair branch February 16, 2026 15:20
@patchback
Copy link

patchback bot commented Feb 16, 2026

Backport to 3.85: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.85/93330ecb5d1a913a56720d20f91b76afabcc3b2b/pr-7322

Backported as #7325

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@patchback
Copy link

patchback bot commented Feb 16, 2026

Backport to 3.103: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.103/93330ecb5d1a913a56720d20f91b76afabcc3b2b/pr-7322

Backported as #7324

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants