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

skip profile schemas when checking for schema migrations #5446

Merged
merged 3 commits into from
Jan 14, 2025

Conversation

ajtmccarty
Copy link
Contributor

@ajtmccarty ajtmccarty commented Jan 13, 2025

found this issue while doing some diff workflow testing locally

SchemaConstraintValidatorRequest.node_schema only accepts NodeSchema or GenericSchema, not ProfileSchema
if a branch includes a new/updated profile instance (say backbone_profile or upstream_profile from the infrastructure_edge.py script), then SchemaValidateMigrationData.constraints that is passed to schema_validate_migrations will include profile schema, which will raise a validation error and break the pipeline

I think the typing on SchemaConstraintValidatorRequest is correct b/c a profile will not require a migration. We have complete control over those schema, so there should be nothing to validate

@github-actions github-actions bot added the group/backend Issue related to the backend (API Server, Git Agent) label Jan 13, 2025
Copy link

codspeed-hq bot commented Jan 13, 2025

CodSpeed Performance Report

Merging #5446 will improve performances by 28.28%

Comparing ajtm-01132025-no-profile-migration (53f5ffb) with stable (dd1cc18)

Summary

⚡ 1 improvements
✅ 9 untouched benchmarks

Benchmarks breakdown

Benchmark stable ajtm-01132025-no-profile-migration Change
test_schemabranch_duplicate 418.9 µs 326.6 µs +28.28%

@ajtmccarty ajtmccarty marked this pull request as ready for review January 13, 2025 17:27
@LucasG0
Copy link
Contributor

LucasG0 commented Jan 13, 2025

It would be good to also remove extra SchemaConstraintValidatorRequest definition within backend/infrahub/core/validators/models/violation.py

@ajtmccarty ajtmccarty requested a review from a team January 13, 2025 23:21
@ajtmccarty
Copy link
Contributor Author

It would be good to also remove extra SchemaConstraintValidatorRequest definition within backend/infrahub/core/validators/models/violation.py

oh nice find. removed it

@@ -32,11 +32,14 @@ async def schema_validate_migrations(message: SchemaValidateMigrationData) -> li
log.info(f"{len(message.constraints)} constraint(s) to validate")
# NOTE this task is a good candidate to add a progress bar
for constraint in message.constraints:
schema = message.schema_branch.get(name=constraint.path.schema_kind)
if isinstance(schema, ProfileSchema):
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

A thought could be to reverse this by saying that what we want to have is a GenericSchema or a NodeSchema. I'm mostly thinking about a future scenario if we introduce some other type of schema SomethingElseSchema (I have no idea of what that might be). If we were to do that this function might be invalid again as it would catch entries that we might not want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great suggestion. I've made this change

@ajtmccarty ajtmccarty force-pushed the ajtm-01132025-no-profile-migration branch from 27d7d06 to 53f5ffb Compare January 14, 2025 21:45
@ajtmccarty ajtmccarty merged commit 42703f5 into stable Jan 14, 2025
34 checks passed
@ajtmccarty ajtmccarty deleted the ajtm-01132025-no-profile-migration branch January 14, 2025 22:07
@dgarros dgarros added this to the Infrahub - 1.1.3 milestone Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group/backend Issue related to the backend (API Server, Git Agent)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants