Repository navigation
sbx-mgr store: typed accessor for the live network-policy gateway read - #1016
Merged
Merged
Conversation
#714 added has_live_network_policy_gateway as a public store reader after #715 introduced the typed db::read views and #721 made the old readers non-public outside tests. It was the one reader left without a typed accessor, so production code outside the store still called it directly. Add SandboxView::live_network_policy_gateway, one call to the reader with the same id, strictness and error: whether a row has netgtw_pid IS NOT NULL AND pool_template IS NULL, false without a row. Convert the server's template network-policy update to it, under the same connection guard and with the same error mapping. Declare the reader with db_private_outside_tests!, so production code outside db can no longer reach it; the store's own transaction callers and tests still do. The accessor table checks the view and the old reader on the main row (registered gateway: true, true, false without a row, true) and on the paused row (no gateway: false in every fixture).
|
Thanks for opening this pull request! A SPACE maintainer will take a look. CONTRIBUTING.md explains how we review outside contributions. |
ac-pplx
marked this pull request as ready for review
October 27, 2026 20:13
shehan-pplx
approved these changes
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#714 added
has_live_network_policy_gatewayas a public sbx-mgr store reader and called it from the server. #715 (typeddb::readviews) and #721 (old readers non-public outside tests) landed after it without a view for it, so #721 left it public. It was the one flatcrate::dbsandbox reader that production code outside the store still called directly.SandboxView::live_network_policy_gateway()is one call to the reader, with the same id, strictness and error. It answers whether a row hasnetgtw_pid IS NOT NULL AND pool_template IS NULL, and returnsfalsewithout a row.sandbox_network_policy.rs) now callscrate::db::read::sandbox_view(&db, &sandbox.id).live_network_policy_gateway(). The connection guard, lock scope andmap_errtext are unchanged.has_live_network_policy_gatewayis declared withdb_private_outside_tests!. The store's own&txcallers inupdate_network_policy_overrideandclear_local_network_policyand its tests keep using it.store/src/db/read/tests.rschecks the view and the old reader against fixed expectations. On the main row, which has a registered gateway, they are[T, T, F, T]across Accepting, CorruptJson, MissingRow and PreviousWithoutCurrent. On the paused row, which has none, they are[F, F, F, F].Validation
At
b43d9dc6:bash ci/scripts/run-rust-checks.sh fmtbash ci/scripts/run-rust-checks.sh clippy, including all three sbx-mgr production feature setscargo arch, with the base baseline, renames and architecture frommainSPACE_CI_REQUIRE_TEST_DEPS=1 cargo nextest run --lockedoverpplx-space-sbx-mgr,-sbx-mgr-store,-db-migrate,-db-migrator,-db-test-fixtures#[ignore]dtransfer_directory::tests::distinct_service_uids_can_exchange_downloads)Ok(true)live_network_policy_gateway without a gateway on Accepting(True vs False)Ok(false)live_network_policy_gateway on Accepting(False vs True)test-support) with the server call reverted tocrate::db::has_live_network_policy_gatewayE0603 function has_live_network_policy_gateway is private; passes again once restoredKind was not run.
Severity and risk
Severity: does not apply (an API-boundary cleanup). Risk: low. The production read runs the same statement on the same connection guard. Roll back by reverting this commit.
AI assistance: Claude Code drafted the code, tests and this description.