Repository navigation
fix: Clear a project's infra from the file registry when the project is deleted - #7228
tushar-mahalya wants to merge 2 commits into
Conversation
…is deleted `feast teardown` removes the online store but the file registry kept the project's infra objects. The next `feast apply` diffed the desired infra against that stale record, reported "No changes to infrastructure" and never recreated the sqlite tables, so `feast materialize` failed with "no such table". The SQL registry already deletes the managed infra row in delete_project; do the same for the file registry, limited to objects named after the deleted project. Signed-off-by: tushar-mahalya <tusharmahalya@gmail.com>
There was a problem hiding this comment.
Devin Review found 2 potential issues.
5 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
Deleting a project from the file registry also removed its infra records, but `feast projects delete` only removes registry metadata and leaves the online store tables in place. A later apply could then no longer drop obsolete tables, because diff_infra_protos only deletes objects that are both recorded and no longer desired. The prefix match could also remove another project's records (`a` vs `a_b`). Revert the change to Registry.delete_project and clear the tracked infra in FeatureStore.teardown instead, right after the provider has torn the infra down and before the projects are deleted so the registry does not re-create the project. SQL registries already drop the managed infra row in delete_project. Signed-off-by: tushar-mahalya <tusharmahalya@gmail.com>
| # re-create it), otherwise the next apply diffs against stale infra and | ||
| # skips re-creating the tables. SQL registries drop this record in | ||
| # delete_project; the file registry keeps it in the registry proto. | ||
| self.registry.update_infra(Infra(), self.project, commit=True) |
There was a problem hiding this comment.
The two added tests cover distinct behaviors, so keeping both seems reasonable.
However, update_infra(Infra(), self.project) clears infrastructure tracking globally; tearing down one project can leave another project’s obsolete tables untracked.
Could we preserve records for surviving tables and extend the teardown test to cover projects sharing a registry with separate databases?
franciscojavierarceo
left a comment
There was a problem hiding this comment.
we need to address the existing cross-project infrastructure tracking finding. Registry.update_infra copies into the single cached_registry_proto.infra field; its project argument does not scope that replacement. teardown_infra removes the current project's resources, so replacing the entire record with Infra() also forgets tables in other projects or databases. a later apply cannot reconcile those surviving tables. we should retain their infra records and cover teardown with two projects sharing a file registry and separate online databases.
What this PR does / why we need it:
With the local provider and the sqlite online store, running
feast apply,feast teardownand thenfeast applyagain leaves the online store with no tables.feast teardowndrops the tables and deletes the project from the file registry, butRegistry.delete_projectleft the project's infra objects in the registry. The nextfeast applydiffs the desired infra against that stale record, prints "No changes to infrastructure" and creates nothing, sofeast materializefails withno such table. Thetest_workflow.pygenerated byfeast initends withfeast teardown, so this is easy to run into.FeatureStore.teardownnow clears the tracked infra withregistry.update_infra(Infra(), project)right after the provider has torn it down, and before the projects are deleted. If it ran after the delete loop, the file registry would re-create the project.Registry.delete_projectis unchanged, sofeast projects delete, which only removes registry metadata and leaves the tables, keeps the infra record and later applies can still drop obsolete tables. For the SQL registries the extra write is harmless, sincedelete_projectremoves the managed infra row anyway.I added two tests in
tests/unit/local_feast_tests/test_local_feature_store.py:_apply_diffspath the CLI uses, tears down, applies again, and checks that the sqlite tables are recreated. It fails without the change.I also ran the reproducer from the issue end to end: on master the second apply reports no changes and materialize fails, and with this change the tables are recreated and materialize succeeds.
Which issue(s) this PR fixes:
Fixes #7227
Checks
git commit -s)Testing Strategy
Misc
The first commit cleared the infra in
Registry.delete_projectinstead. The second commit moves it toteardownafter review feedback, sincedelete_projectis also used for registry-only deletion.Two tests in
tests/unit/local_feast_tests/test_local_feature_store.pythat need Java (PySpark) fail on my machine with or without this change. Registry, CLI, diff and local feature store unit tests pass, andruffandmypyare clean on the changed files.Found and fixed with help from Claude Code; I reproduced and tested it myself.