Repository navigation
fix: Clear a project's infra from the file registry when the project is deleted - #7228
tushar-mahalya wants to merge 3 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?
There was a problem hiding this comment.
Thanks, you were right. Teardown no longer clears the whole record. It now drops only the records of the objects it tears down (the infra the provider plans for the torn-down views) and keeps everything else, so other projects in the same file registry keep theirs. I extended the tests with two projects sharing a file registry and separate sqlite online stores, see ebce4b1.
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.
The file registry keeps a single infra record for all of its projects, and update_infra replaces it whole. Clearing it with Infra() on teardown therefore also forgot the tables of every other project sharing the registry, so a later apply of those projects could no longer drop tables they remove. Teardown now removes only the records of the objects it tears down: the infra the provider plans for the torn-down views. Everything else is kept. This is computed before the provider teardown, because building SqliteTable objects opens a connection and would re-create a deleted database file. Add a test with two projects that share a file registry and use separate online stores: tearing one down keeps the other's records, and a later apply of the other project with a renamed view drops the old table. Signed-off-by: tushar-mahalya <tusharmahalya@gmail.com>
|
Thanks @franciscojavierarceo, addressed in ebce4b1. Two related things I noticed while testing, both also on master and not changed here:
Happy to open issues or follow-up PRs for those if that would help. |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7228 +/- ##
==========================================
+ Coverage 54.10% 54.26% +0.15%
==========================================
Files 467 467
Lines 58940 58954 +14
Branches 8688 8691 +3
==========================================
+ Hits 31890 31989 +99
+ Misses 24892 24781 -111
- Partials 2158 2184 +26
... and 9 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
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 drops the infra records of the objects it tears down, right after the provider has removed them and before the projects are deleted (if it ran after the delete loop, the file registry would re-create the project). The records to drop are the infra the provider plans for the torn-down views, so records of other projects that share the file registry are kept and a later apply of those projects can still reconcile their tables.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 three 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_project. The second moved it toteardown, sincedelete_projectis also used for registry-only deletion. The third keeps other projects' records instead of clearing the whole record, after review feedback.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.