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

Ensure that deleted nodes are removed from the schema_branch #5183

Merged
merged 3 commits into from
Dec 13, 2024

Conversation

ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Dec 10, 2024

The root cause here is that when we delete a nodeschema it will be removed from the current SchemaBranch object on the API worker that handled the request. On other workers in the system the old deleted nodes are still cached in the SchemaBranch within the registry and never cleared out (until the worker is restarted).

Within infrahub/core/merge.py I also completely removed the get_schema_diff() method that appeared to be dead code that wasn't reached by any path.

Initially I added all modified nodes to SchemaBranchDiff (the current compare function only looks add added nodes from one side), however this was a bit problematic as we couldn't see which ones were added and as such it was complicated to remove nodes as it wasn't clear about what action to take.

This PR modifies the SchemaBranchDiff object to specifically include a section for specific actions on nodes and generics, i.e. added/changed/removed. This changed forced some additional changes around the logic of this object.

I've added a test to validate that this works. However for now that pipeline is disabled due to problems related to starting the actual containers. The tests work locally though (however we have to switch back and forth between which environment variables are active when doing so), as a follow up to enable that pipeline I've opened #5205.

Fixes #4836

@github-actions github-actions bot added the group/backend Issue related to the backend (API Server, Git Agent) label Dec 10, 2024
Copy link

codspeed-hq bot commented Dec 10, 2024

CodSpeed Performance Report

Merging #5183 will not alter performance

Comparing pog-schema-sync-deleted-nodes-IFC-887 (3164949) with stable (83b3c5a)

Summary

✅ 10 untouched benchmarks

@ogenstad ogenstad force-pushed the pog-schema-sync-deleted-nodes-IFC-887 branch from a579bf6 to bd482ce Compare December 10, 2024 15:01
generics=[
key for key, value in other.generics.items() if key not in self.generics or self.generics[key] != value
],
removed_generics=[key for key in self.generics if key not in other.generics],
)
Copy link
Contributor

Choose a reason for hiding this comment

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

it might be cleaner if these used sets instead of lists for this logic, but I understand if it is out of scope for this small change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean all of the objects in SchemaBranchDiff? If so perhaps we can do that once it's brought back into develop?

@ogenstad ogenstad force-pushed the pog-schema-sync-deleted-nodes-IFC-887 branch from a446ed5 to 74e0e16 Compare December 12, 2024 15:49
@github-actions github-actions bot added the group/ci Issue related to the CI pipeline label Dec 12, 2024
@ogenstad ogenstad force-pushed the pog-schema-sync-deleted-nodes-IFC-887 branch 8 times, most recently from 47d71d3 to b07cc0b Compare December 12, 2024 19:04
@ogenstad ogenstad force-pushed the pog-schema-sync-deleted-nodes-IFC-887 branch from b07cc0b to 3164949 Compare December 13, 2024 09:13
@github-actions github-actions bot removed the group/ci Issue related to the CI pipeline label Dec 13, 2024
@ogenstad ogenstad marked this pull request as ready for review December 13, 2024 10:09
@ogenstad ogenstad requested a review from a team December 13, 2024 10:09
@ogenstad ogenstad merged commit f35cc55 into stable Dec 13, 2024
31 checks passed
@ogenstad ogenstad deleted the pog-schema-sync-deleted-nodes-IFC-887 branch December 13, 2024 12:10
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.

bug: schema out of sync on workers after deleting a node from the schema
3 participants