Skip to content

Management command for data repairs#7322

Open
dralley wants to merge 1 commit intopulp:mainfrom
dralley:datarepair
Open

Management command for data repairs#7322
dralley wants to merge 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]# 

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
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.

print()

if not number_broken:
print("Finished. (OK)")
Copy link
Member

Choose a reason for hiding this comment

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

Django want's us to use self.stdout.write here.

https://docs.djangoproject.com/en/4.2/howto/custom-management-commands/


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?

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).

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants