fix(datastore): resolve repository and freed bytes for remote parents (S20-A lifecycle purger plan: 20b/24, stack: 2/5)
What this MR does
This MR adds the two lookups that the remote parent reapers need to report freed bytes.
resolveReapRepositorygets three new routes:container_remote_images,maven_remote_packagesandnpm_remote_packages. Each route reads therepositories.idof the reaped row through its remote repository.sumFreedRepositoryBytesgets an npm remote size family. It counts a digest only when no row of the repository holds it innpm_remote_filesor innpm_remote_metadata_files.- Both guards move to the new last value, so the next route and the next family stay refused before any statement.
- Four new query names in
internal/datastore/query_names.go, also listed inQueryNames(). docs/dev/storage-accounting.mdchanges to match:- The statement, alias-position, doubled-alias and family counts of the probe's guard suite are recounted.
- The
NpmRemoteVersionReapergap is restated.
No reaper uses these routes or this family in this MR. The next MR in the stack connects them to the three reapers.
NpmRemoteVersionReaper still reports no freed-byte figure after this stack.
The npm remote family now has a figure, but no npm_remote_versions route resolves the reaped version's repository, and nothing connects the family to that arm.
Work item 1184 owns that gap.
Work item 942 tracked it before and is closed.
Stack
This MR is part 2 of 5. The parts split !3380 (merged), and they merge in this order:
- !3399 (merged): the Danger exemption for comment-only Go changes.
- This MR: the resolve routes and the npm remote size family.
- !3402 (merged): the three reapers report freed bytes.
- !3403 (merged): the three tombstone discovery scans.
- !3380 (merged): the three purge levels and the documentation.
When all five merge, main holds the same tree as the original !3380 (merged) rebased onto !3399 (merged).
Tests
| Test | What it holds |
|---|---|
TestResolveReapRepository_AdmitsTheRemoteParentRoutesAndNothingPast |
The three routes pass the guard, and each route dispatches to its own statement. The next value is refused. |
TestSumFreedRepositoryBytes_AdmitsTheNpmRemoteFamilyAndNothingPast |
The npm remote family passes the guard and reads both cache tables. The next value is refused. |
TestReapSizeStmts_TheRemoteParentStatementsBindThePartitionKey |
Each new statement binds namespace_id on every table alias. |
The integration tests for the statements are in the next MR, because they run through the reapers.
Database review
This MR adds four statements and no migration.
The plans for all four are in the ## Database Review Evidence section of !3380 (merged):
datastore.resolveReapRepository.container_remote_images_select_reap_repositorydatastore.resolveReapRepository.maven_remote_packages_select_reap_repositorydatastore.resolveReapRepository.npm_remote_packages_select_reap_repositorydatastore.sumFreedRepositoryBytes.blob_storage_blobs_by_namespace_select_reap_freed_size_npm_remote
E2e scenario catalogs and user documentation
No scenario row and no docs/user/ page changes. This MR changes no behavior that a client can see.
Related to #728 (closed)