Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite model check as validation check re #10079 #11646

Merged
merged 3 commits into from
Dec 3, 2024

Conversation

jacobtylerwalls
Copy link
Member

@jacobtylerwalls jacobtylerwalls commented Nov 21, 2024

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Description of Change

When trying my hand at writing a django system check in #10079, I missed a pretty major caveat, which is that if you use the database, you need to do something like:

if kwargs["databases"]:
errors.extend(cls._check_publication_in_every_language())

... to avoid db hits during commands that don't generally expect a database to be configured. (My earlier workaround was was to run subsets of checks in different places, but that was kind of a code smell. This PR removes some of those workarounds.)

But to start observing kwargs["databases"] means that these checks only run on:

- manage.py migrate
- manage.py check --database default

So, given how infrequently this would be run, better to just implement this in our validation framework and call it out in the release notes?

Testing instructions

  • Create and publish a graph
  • Enable an additional system language, without republishing any graphs
  • manage.py validate
  • expect errros
  • manage.py validate --fix
  • expect errrors fixed
  • ensure branches do not trigger the check
  • ensure languages for which a publication exists but is not currently in settings.LANGUAGES doesn't alter the comparison and cause the check to unexpectedly pass

This model check should have been skippped by checking
the `databases` kwarg provided when `check()` is called,
but that reduces the circumstances on which this check is
run to either:
- manage.py migrate
- manage.py check --databases

So, given how infrequently this would be run, better to just
implement this in our validation framework.
check=IntegrityCheck.PUBLICATION_MISSING_FOR_LANGUAGE, # 1014
queryset=(
models.GraphModel.objects.filter(
isresource=True,
Copy link
Member Author

Choose a reason for hiding this comment

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

The prior version of this was also checking branches when it shouldn't.

@@ -613,39 +613,6 @@ def save(self, *args, **kwargs):

super(GraphModel, self).save(*args, **kwargs)

@classmethod
Copy link
Member Author

Choose a reason for hiding this comment

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

Pretty sure this deletion is the main reason the coverage check is failing.

@jacobtylerwalls
Copy link
Member Author

So, given how infrequently this would be run, better to just implement this in our validation framework and call it out in the release notes?

Some more info about the original motivation here: #11342 (comment)

Copy link
Contributor

@aarongundel aarongundel left a comment

Choose a reason for hiding this comment

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

LGTM

@jacobtylerwalls jacobtylerwalls merged commit b9dc94f into dev/8.0.x Dec 3, 2024
6 of 7 checks passed
@jacobtylerwalls jacobtylerwalls deleted the jtw/harden-system-check branch December 3, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants