Skip to content

feat(database): add SQLite as a second backend (SPEC-028) - #108

Merged
uw-sc merged 2 commits into
mainfrom
feature/598-database---sqlite-13-database-layer-and-migrations
Nov 6, 2026
Merged

uw-sc merged 2 commits into
mainfrom
feature/598-database---sqlite-13-database-layer-and-migrations

Conversation

@uw-sc

@uw-sc uw-sc commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Part 1 of 3 of the SQLite epic (cobaltcore-dev/cloud-storage#595): adds SQLite as a second database backend behind a backend-neutral contract, so a single-node deployment can keep all state in one file on the node instead of running a separate PostgreSQL server. PostgreSQL stays the default and is unchanged. The database.url scheme selects the backend at startup — postgres://… or sqlite:///absolute/path.

What's in it

Backend-neutral contract. internal/database.DB is an interface over the method set the code calls on pgx; the 736 call sites change types only. PostgreSQL keeps pgxpool and passes SQL through untouched.

SQLite backend. modernc.org/sqlite (pure Go, CGO-free). One WAL-mode file, synchronous=FULL, 0600, immediate transactions; single node only (VXLAN refused). A translation layer rewrites the PostgreSQL SQL the code already writes — casts, = ANY($n), LIMIT NULL, FOR UPDATE, ~ — and registers now(), gen_random_uuid() and no-op advisory locks; times, JSON, lists and []byte convert at the boundary. TestSQLConstructs fails the build on anything only PostgreSQL runs.

Migrations. One folder read through a per-backend view; SQLite starts at a generated baseline (073). Migration 074 adds volumes/snapshots.reserved_by on both backends. TestSchemaParity proves the 72 tables match.

Behavioural changes (holding one file per node means never holding a transaction across slow work):

  • Cinder volume/snapshot creates reserve a creating row, build the backing outside any transaction, then finalise; a per-node startup sweep sets crash-interrupted creates to error, and deleting them reclaims their files, as upstream Cinder does.
  • Nova rechecks binding quota under an advisory lock and answers 403 (Quota exceeded) instead of 413, matching upstream.

Testing

  • Unit + DB-backed tests on both backends (LIGHTSTACK_TEST_DB_URL selects; CI runs both).
  • Host-tested in real mode (libvirt + iptables) on a SQLite file per docs/specs/028-sqlite-database-layer/HOST_TESTING.md §2: fresh start, server boot on a network, image-backed volume attach/detach and over-quota 403 pass. The kill-mid-copy restart step (§2.5) changed with the review fixes — the interrupted volume now turns error about a minute after the restart and keeps its partial file until it is deleted — and awaits a re-run on the current head.

Notes

  • Go 1.27.2.
  • Refs cobaltcore-dev/cloud-storage#598; epic cobaltcore-dev/cloud-storage#595. Part 2 (chart/compose, #599) and part 3 (backup/integrity/restore, #600) follow.
  • Also carries a small docs(nova) comment fix (278d106).

🤖 Generated with Claude Code

@uw-sc
uw-sc force-pushed the feature/598-database---sqlite-13-database-layer-and-migrations branch 5 times, most recently from 43ff11e to 58509cf Compare October 28, 2026 04:47
@uw-sc
uw-sc requested a review from senolcolak October 28, 2026 05:03
@uw-sc uw-sc self-assigned this Oct 28, 2026
@uw-sc
uw-sc force-pushed the feature/598-database---sqlite-13-database-layer-and-migrations branch 2 times, most recently from b19ef6a to a61ab8d Compare October 28, 2026 09:23
@uw-sc
uw-sc added this pull request to stack #110 October 28, 2026 14:05
@uw-sc
uw-sc force-pushed the feature/598-database---sqlite-13-database-layer-and-migrations branch from a61ab8d to 3af777a Compare October 30, 2026 08:30
@uw-sc
uw-sc requested a balanced review from Copilot October 30, 2026 09:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved critical issues let overlapping pods reclaim live reservations’ backing storage and cause toolchain installation to fail because the Go archive checksum is stale.

4 open issues
What changed in this PR

Adds SQLite as a single-node alternative to PostgreSQL behind Lightstack’s shared database interface. This is the database-layer foundation for the three-part SQLite epic.

Changes:

  • Adapts services, migrations, error handling, and database tests for both backends.
  • Adds interrupted storage-create recovery and tests Nova’s updated quota refusal behavior.
  • Updates deployment configuration, operational documentation, and Go toolchain settings.
File Description
tools/​go.mod Raises the tooling Go version.
test/​quota_test.sh Checks Nova’s 403 quota response.
test/​error_handling_test.sh Updates quota error-envelope expectations.
test/​contract/​README.md Documents backend-aware fixture configuration.
test/​contract/​nova/​quota_refusal_test.go Adds isolated quota-refusal contract coverage.
test/​contract/​nova/​boot_network_failure_test.go Shares fresh-project authentication helpers.
test/​contract/​neutron/​trunks_test.go Uses backend-neutral fixture seeding.
test/​contract/​neutron/​l3_agents_test.go Replaces shell-based database fixtures.
test/​contract/​helpers.go Adds shared database fixture execution.
test/​contract/​cinder/​manage_test.go Uses portable volume fixtures.
test/​benchmark/​database_bench_test.go Adopts the database opening API.
scripts/​deploy-single-node.sh Updates the pinned Go version.
README.md Removes fixed binary-size claims.
pkg/​storage/​ceph_rbd.go Makes missing-backing deletion idempotent.
pkg/​paths/​paths.go Adds the node-local database directory.
pkg/​paths/​paths_test.go Tests database-directory layout.
migrations/​074_reservation_node.up.sql Adds storage reservation ownership.
migrations/​074_reservation_node.down.sql Reverts reservation ownership columns.
migrations/​073_baseline.sqlite.down.sql Reverts the SQLite baseline.
migrations/​037_keystone_domains.down.sql Preserves earlier domain schema during rollback.
migrations/​028_keystone_groups.down.sql Preserves earlier group tables during rollback.
migrations/​019_keystone_groups.down.sql Limits rollback to migration-owned objects.
migrations/​010_keystone_user_enhancements.down.sql Preserves earlier domain columns during rollback.
Makefile Updates migration and deployment-test commands.
internal/​teardown/​teardown.go Opens either backend without creating missing databases.
internal/​nova/​volume_attachment.go Uses backend-neutral database types and errors.
internal/​nova/​testrouter_test.go Supports injected databases and request contexts.
internal/​nova/​state_reconciler.go Uses portable DELETE alias syntax.
internal/​nova/​state_reconciler_test.go Binds timestamps instead of SQL intervals.
internal/​nova/​server_update.go Uses backend-neutral not-found handling.
internal/​nova/​server_list_filters_test.go Adds IP and backend regex coverage.
internal/​nova/​server_filter_test.go Updates filter helper calls.
internal/​nova/​selfheal.go Uses backend-neutral not-found handling.
internal/​nova/​quota_usage_failure_test.go Uses portable database failure injection.
internal/​nova/​operator_surfaces_test.go Binds portable timestamp fixtures.
internal/​nova/​maindb_test.go Shares dual-backend test setup.
internal/​nova/​lifecycle_precondition_test.go Replaces SQL interval arithmetic in fixtures.
internal/​nova/​keypairs.go Uses backend-neutral not-found handling.
internal/​nova/​interface_attach.go Adapts database helpers and errors.
internal/​nova/​flavors.go Uses backend-neutral uniqueness checks.
internal/​nova/​failure_injection_db_test.go Tests database read-failure responses.
internal/​nova/​diagnostics.go Adapts action-history error handling.
internal/​nova/​console_test.go Binds console-expiry timestamps.
internal/​nova/​aggregates.go Merges metadata transactionally without JSONB operators.
internal/​nova/​aggregate_metadata_db_test.go Tests concurrent metadata merging.
internal/​nova/​address_batching_test.go Tests cross-project IP filtering.
internal/​nova/​action_history_lookup_failure_test.go Uses portable failure injection.
internal/​neutron/​vxlan_coordinator.go Uses the database interface and portable VNI SQL.
internal/​neutron/​vni_allocation_db_test.go Tests VNI gaps and range boundaries.
internal/​neutron/​update_statement_test.go Binds portable array fixtures.
internal/​neutron/​teardown.go Generalizes single-column database reads.
internal/​neutron/​subnet_pools.go Uses backend-neutral not-found handling.
internal/​neutron/​subnet_ownership_test.go Binds DNS-list fixtures.
internal/​neutron/​subnet_listing_test.go Binds portable pagination timestamps.
internal/​neutron/​security_group_default.go Uses backend-neutral transactions and errors.
internal/​neutron/​router_snat_db_test.go Tests gateway SNAT behavior on both backends.
internal/​neutron/​reconciler.go Replaces DISTINCT ON with a window query.
internal/​neutron/​reconciler_test.go Tests first-subnet redirect selection.
internal/​neutron/​quota_usage_failure_test.go Uses portable failure injection.
internal/​neutron/​qos.go Uses backend-neutral not-found handling.
internal/​neutron/​port_forwarding.go Adapts database error handling.
internal/​neutron/​network_selectability_test.go Uses portable fixtures and failure injection.
internal/​neutron/​network_db_test.go Shares dual-backend test setup.
internal/​neutron/​listing_page_size_test.go Uses portable bulk-fixture SQL.
internal/​neutron/​floatingip.go Uses backend-neutral not-found handling.
internal/​neutron/​error_envelope_test.go Binds JSON fixtures directly.
internal/​neutron/​concurrency_db_test.go Exercises concurrent networking transactions.
internal/​neutron/​auto_allocated_topology.go Uses backend-neutral not-found handling.
internal/​neutron/​address_scopes.go Uses backend-neutral not-found handling.
internal/​metadata/​service_db_test.go Shares database setup and leak checks.
internal/​keystone/​uuid_middleware.go Canonicalizes UUID path parameters.
internal/​keystone/​uuid_middleware_test.go Tests UUID path normalization.
internal/​keystone/​services.go Uses backend-neutral not-found handling.
internal/​keystone/​s3tokens.go Canonicalizes project IDs before lookup.
internal/​keystone/​role_assignment_filter_test.go Tests dash-free project-ID filtering.
internal/​keystone/​pool_injection_test.go Adapts injected-pool tests to either backend.
internal/​keystone/​maindb_test.go Shares dual-backend test setup.
internal/​keystone/​identity_surface_test.go Accepts the database interface in test routers.
internal/​keystone/​identity_errors.go Uses backend-neutral identity errors.
internal/​keystone/​identity_errors_test.go Updates not-found sentinel coverage.
internal/​keystone/​identity_domain_alias_test.go Tests duplicate-user conflict responses.
internal/​keystone/​groups.go Uses portable uniqueness and not-found checks.
internal/​keystone/​ec2_credentials.go Uses backend-neutral not-found handling.
internal/​keystone/​domain_resolve.go Adapts domain resolution to the database interface.
internal/​keystone/​domain_resolve_test.go Adds an interface-based outage test double.
internal/​keystone/​credentials.go Uses backend-neutral not-found handling.
internal/​keystone/​bootstrap_test.go Uses the shared not-found sentinel.
internal/​keystone/​application_credentials.go Adapts credential lookup errors.
internal/​health/​health.go Supports readiness checks on either backend.
internal/​glance/​import.go Uses backend-neutral not-found handling.
internal/​glance/​images_db_test.go Shares dual-backend test setup.
internal/​database/​url.go Adds backend selection, validation, and URL redaction.
internal/​database/​tx.go Generalizes the transaction helper.
internal/​database/​sqlite_values_helpers_test.go Supports SQLite scan-conversion tests.
internal/​database/​postgres_open_test.go Tests unreachable PostgreSQL opening.
internal/​database/​postgres_internal_test.go Verifies PostgreSQL pool settings remain intact.
internal/​database/​parity_test.go Compares backend schemas and seed data.
internal/​database/​migrate_lock.go Adds cross-process SQLite migration locking.
internal/​database/​migrate_lock_other.go Refuses SQLite migrations off Unix.
internal/​database/​leg_db_test.go Opens backend-selected test databases.
internal/​database/​errors.go Adds backend-neutral error classifiers.
internal/​database/​errors_test.go Tests PostgreSQL error classification.
internal/​database/​describe.go Reports database location, version, and settings.
internal/​database/​describe_internal_test.go Tests credential-free location formatting.
internal/​database/​describe_db_test.go Tests database descriptions and unmigrated state.
internal/​console/​store.go Uses the shared database contract.
internal/​console/​store_test.go Binds expiry timestamps in fixtures.
internal/​console/​maindb_test.go Shares dual-backend test setup.
internal/​console/​helpers_test.go Makes expiry fixtures portable.
internal/​console/​cli_test.go Uses portable expiry updates.
internal/​compute/​node_registry.go Accepts the shared database interface.
internal/​common/​project.go Canonicalizes project UUIDs for text-backed lookup.
internal/​common/​project_test.go Tests alternate UUID spellings.
internal/​common/​pgerror.go Removes PostgreSQL-only uniqueness handling.
internal/​common/​nodename.go Resolves storage reservation owner names.
internal/​common/​nodename_test.go Tests configured and hostname-based ownership.
internal/​common/​maindb_test.go Shares dual-backend test setup.
internal/​common/​image.go Adapts image visibility queries.
internal/​common/​fixed_ips.go Adds a shared fixed-address representation.
internal/​common/​error_helpers.go Uses backend-neutral database errors.
internal/​cinder/​volume_types.go Adapts volume-type lookup errors.
internal/​cinder/​transfer_state_test.go Supports SQLite concurrency testing.
internal/​cinder/​sweep.go Recovers interrupted storage reservations at startup.
internal/​cinder/​sweep_db_test.go Tests recovery ownership and backing cleanup.
internal/​cinder/​quota_usage_failure_test.go Uses portable failure injection.
internal/​cinder/​quota_denial_test.go Uses the shared transaction interface.
internal/​cinder/​qos_specs.go Uses backend-neutral not-found handling.
internal/​cinder/​groups.go Uses backend-neutral not-found handling.
internal/​cinder/​boot_volume_test.go Supplies reservation ownership to services.
internal/​cinder/​backups.go Refuses backups of creating volumes.
go.mod Adds SQLite dependencies and raises the Go version.
docs/​specs/​028-sqlite-database-layer/​contracts/​compute-quota.md Defines quota responses and concurrency guarantees.
docs/​specs/​028-sqlite-database-layer/​contracts/​block-storage-reservation.md Defines reservation lifecycle and recovery behavior.
docs/​specs/​028-sqlite-database-layer/​checklists/​requirements.md Records specification validation.
docs/​security/​SBOM_TRIAGE.md Documents the toolchain security update.
docs/​MULTIARCH.md Updates builder guidance and size wording.
docs/​DOCKER_DEPLOYMENT.md Documents SQLite deployment and backups.
docs/​adr/​README.md Links the pluggable-backend decision.
docs/​adr/​ADR-001-database-dependency-injection.md Explains the database-interface amendment.
deployments/​docker-compose.test.yml Tracks the stable Go image.
deployments/​docker-compose-kvm.yml Mounts the state root and exposes database selection.
cmd/​lightstack-migrate/​main.go Validates backend configuration and baseline targets.
charts/​lightstack/​tests/​tls_test.yaml Accounts for the always-present node-name variable.
charts/​lightstack/​tests/​teardown_test.yaml Tests database-secret propagation to cleanup.
charts/​lightstack/​tests/​node_name_test.yaml Tests reservation owner configuration.
charts/​lightstack/​tests/​extra_env_test.yaml Updates default environment expectations.
charts/​lightstack/​templates/​teardown-purge-job.yaml Passes database secrets to cleanup.
charts/​lightstack/​templates/​_helpers.tpl Shares database environment rendering and sets node ownership.
charts/​lightstack/​README.md Documents ownership and cleanup database access.
build/​package/​Dockerfile Tracks the stable Go builder image.
.github/​workflows/​security.yml Uses stable Go for security scanning.

Review effort: Balanced

Comment thread scripts/deploy-single-node.sh Resolved
Comment thread internal/keystone/domain_resolve.go Resolved
Comment thread docs/DOCKER_DEPLOYMENT.md Resolved
@uw-sc
uw-sc force-pushed the feature/598-database---sqlite-13-database-layer-and-migrations branch from 3af777a to 9b8ec06 Compare October 30, 2026 10:37

@senolcolak senolcolak left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Two actionable findings remain on head 9b8ec06: snapshot abandonment deletes backing for a surviving row (P1), and startup can reclaim another live service's reservation during an overlapping rollout (P2, existing discussion reopened with evidence). Both have deterministic service-level reproductions on SQLite.

Correction after the deeper review: the UUID-spelling item below is withdrawn and resolved. SPEC-028 explicitly requires non-canonical IDs to match nothing on SQLite outside specific identity compatibility flows; the observed snapshot behavior conforms to that contract.

The additional Nova, Neutron and startup suites passed against SQLite using a Go build overlay for the existing Linux-only netlink constant on this macOS host. This does not replace native Linux, PostgreSQL, Kubernetes rollout or real libvirt/RBD validation. No further independent defect was confirmed.

Comment thread internal/cinder/volumes.go Resolved
Comment thread internal/cinder/volumes.go Resolved
@uw-sc
uw-sc force-pushed the feature/598-database---sqlite-13-database-layer-and-migrations branch from 9b8ec06 to 76e3048 Compare November 2, 2026 05:10
senolcolak pushed a commit that referenced this pull request Nov 2, 2026
…ny/IPv6 allocation

Review findings (comprehensive review of the open senolcolak PRs):

- MEDIUM: nightly --strict was red on arrival because two known-failing cases
  are structurally unpassable (stub console 501; OSC 7.0.0 backup-show bug).
- MEDIUM: the planned '>0 new known-failing blocks' guard did not exist, so a
  regression on any of the ~26 self-healing probes passed both gates. Add a
  checked-in baseline (test/cli/baseline/known_failures.txt); coverage.sh and
  run.sh --strict now fail on any known-failing not in it and warn on stale
  entries. Live: --fast --strict 244/242 pass, full --strict 251/249 pass,
  2 baseline known-failing, exit 0; an empty baseline fails with both
  violations.
- MEDIUM: List/GetSubnetPool rendered the caller's project as tenant_id for
  shared pools; both now select and render the row's owning project.
- MEDIUM: allocateIP refused /30, /29 and all IPv6 pools as 'untenable'.
  Upstream Neutron allocates from them and fails only on exhaustion; the
  allocator now mirrors generate_pools() and never panics. Tests rewritten
  to assert allocation and a 201 from a tiny and an IPv6 pool.
- Numbering: documents (does not change) the SPEC-028 / migration-074
  collision with #108/#109 and the missing spec.md/tasks.md.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>
senolcolak pushed a commit that referenced this pull request Nov 2, 2026
Review findings (comprehensive review of the open senolcolak PRs):

- MEDIUM: CLAUDE.md gave Cinder an S3 backend and listed rbd,s3 as valid;
  only Glance supports S3 and rbd,s3 is rejected at startup.
- MEDIUM: CLAUDE.md asserted '100% Terraform compatibility' and 'zero
  modifications', contradicted by the repo's own compatibility report and
  blueprint. Hedge to the validated topology and link the report.
- MEDIUM: 'next free spec number is 028' collides with in-flight #107 and
  #108/#109. Freeze 028, name the claimants, and keep the later-merge
  renumber rule (no renumbering here). Flag #107's plan.md-only spec.
- LOW: state Go 1.27.x and defer to go.mod, so #107's 1.27.3 bump does not
  instantly stale the floor.
- LOW: registry PR citations #515-#549 are cloud-storage PRs, not this
  repo's; prefix them. SPEC-019 cites commit 0a4dde0.
- LOW: AGENTS.md pointed the DB tests at the shared postgres database;
  standardize on lightstack_test.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>
@uw-sc
uw-sc requested a balanced review from Copilot November 2, 2026 10:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Owner deregistration before in-flight creates stop allows a replacement instance to treat live reservations as abandoned and delete their backing storage.

4 open issues
3 resolved since last review

Review effort: Balanced

Comment thread internal/cinder/reservation_owner.go Resolved
Comment thread deployments/docker-compose-kvm.yml Resolved
Comment thread internal/cinder/reservation_owner.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The recovery contract overpromises immediate recovery, while the chart README retains an obsolete replica warning instead of documenting the current owner-liveness safeguards.

3 open issues
3 resolved since last review

Review effort: Balanced

Comment thread charts/lightstack/README.md Resolved
@uw-sc
uw-sc force-pushed the feature/598-database---sqlite-13-database-layer-and-migrations branch from b8a4839 to ed49249 Compare November 2, 2026 14:33
The attachment rows come from tx.Query, so they share the transaction's
connection; there is no second pooled connection. The eager Close is
needed because pgx refuses another command on a connection while a
result set is open ("conn busy"), and the tx.Exec calls that follow
would fail otherwise.

Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>
@uw-sc
uw-sc force-pushed the feature/598-database---sqlite-13-database-layer-and-migrations branch from ed49249 to 33c7367 Compare November 4, 2026 05:36

@senolcolak senolcolak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One remaining P1 issue in reservation-owner liveness: missed heartbeats can cause an active create to be reclaimed, and the owner's registration then never recovers. Reproduced on SQLite against this head using the real Cinder handler and sweep with the existing fake backing store. Details and acceptance criteria are inline.

Comment thread internal/cinder/sweep.go Resolved
@uw-sc
uw-sc force-pushed the feature/598-database---sqlite-13-database-layer-and-migrations branch from 33c7367 to 70d63d8 Compare November 4, 2026 14:37
Introduce a backend-neutral database contract in internal/database whose
method sets mirror pgx's, so the 736 call sites change types only. The
database.url scheme selects the backend at startup: postgres:// keeps the
existing pgxpool implementation and passes SQL through untouched, while
sqlite:///absolute/path opens one WAL-mode file (synchronous=FULL, 0600,
immediate transactions) for a single node — VXLAN is refused.

SQLite support:
- modernc.org/sqlite (pure Go, CGO-free); golang-migrate database/sqlite
  and source/iofs.
- A translation layer rewrites the PostgreSQL SQL the code already writes:
  casts, = ANY($n), LIMIT NULL, FOR UPDATE and ~, and registers now(),
  gen_random_uuid() and no-op advisory locks. Times, JSON, lists and []byte
  are converted at the boundary. TestSQLConstructs fails the build on any
  construct only PostgreSQL runs.
- Migrations live in one folder read through a per-backend view; SQLite
  starts at a generated baseline (073). Migration 074 adds
  volumes/snapshots.reserved_by on both backends, and TestSchemaParity
  proves the 72 tables match.

Behavioural changes forced by holding one file per node:
- No transaction is held across storage, libvirt, network or HTTP work.
  Cinder volume and snapshot creates reserve a creating row, build the
  backing outside any transaction, then finalise; a per-node startup sweep
  sets creates interrupted by a crash to error and reclaims their files.
- Nova rechecks binding quota under an advisory lock and answers 403
  (Quota exceeded) instead of 413, matching upstream Nova.

Go 1.27.2. Adds a host-testing runbook and contracts under
docs/specs/028-sqlite-database-layer/.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>
@uw-sc
uw-sc force-pushed the feature/598-database---sqlite-13-database-layer-and-migrations branch from 70d63d8 to 2bc6349 Compare November 4, 2026 15:01

@senolcolak senolcolak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

looks promising, finger crossed

@uw-sc
uw-sc merged commit f6bb131 into main Nov 6, 2026
11 checks passed
@uw-sc
uw-sc deleted the feature/598-database---sqlite-13-database-layer-and-migrations branch November 10, 2026 07:37
senolcolak added a commit that referenced this pull request Nov 26, 2026
…(SPEC-031) (#107)

* docs(specs): add SPEC-028 plan — OpenStack CLI conformance test environment (issue #105)

Analysis and implementation plan for the test-environment enhancement:
verify the built binary against the python OpenStack CLI in all cases,
with a machine-auditable coverage matrix, a hard CI gate, and Terraform
conformance in CI. Also fixes the broken contract-test runner (portable
paths, nova added to the service loop, strict mode) and marks the three
superseded test-status snapshots as historical.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* test(cli): add the OpenStack CLI conformance harness core (SPEC-028 phase 1)

New test/cli/: osc() wrapper (always -f json, auto-retry for formatter-less
mutation commands, timeout, rc/stdout/stderr capture), jq assertions,
t_begin/t_end case lifecycle with known-failure and skip states, JSON+JUnit
reporting, idempotent fixtures with a crash-safe cli-conf-* prefix sweep,
and bin/run.sh (external server, or binary-test compose stack that runs the
built bin/lightstack artifact). bin/coverage.sh cross-references the
per-service manifests with recorded results — the machine-checkable
definition of 'all cases'; it fails on untested/failed/skipped tier A+B
commands, allows but counts known-failures. Smoke suite verified live:
11/11 pass, rerun-safe, warnings-clean.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix(glance): honor the standard v2 image list filters and persist tags on create

ListImages silently ignored name, disk_format, container_format, size_min,
size_max, owner and tag, returning unfiltered results. The exact-match
name filter is what terraform-provider-openstack's image data source
relies on server-side (no client-side matching), so any server holding
more than one image broke data lookups with 'Your query returned more
than one result' — found by the SPEC-028 terraform conformance run. The
same gap made 'openstack image list --tag/--disk-format' vacuous.

CreateImage echoed the requested tags in its 201 response but never wrote
the image_tags rows, so a follow-up show returned tags: [] —
'openstack image create --tag' silently dropped them.

Found by the SPEC-028 CLI conformance suites (issue #105).

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix(nova): four conformance gaps found by the SPEC-028 CLI suite

- os-server-groups: accept the microversion 2.64+ 'policy' string (and
  the legacy 'policies' array) and answer with both fields. The server
  advertises compute 2.90, so every 2.64+ client — OSC 7 included — was
  rejected with 400 on server group create.
- os-aggregates: a non-UUID path reference (openstacksdk's find_aggregate
  probes by name first) hit the uuid cast error and answered 500 instead
  of the 404 the client needs to continue its lookup.
- createBackup: name the backup image exactly the requested name
  (upstream passes it through verbatim); the -<type>-<timestamp> suffix
  broke every client that looks the image up afterwards. Rotation still
  finds candidates via image_tags.
- shelve/unshelve: unshelve now consumes the instance_snapshots row, and
  shelve reclaims any stale one, fixing the shelve -> unshelve -> shelve
  500 on UNIQUE(instance_id).
- server show/list detail now carry 'locked' (exposed since
  microversion 2.9 upstream); the actions maintained the column but the
  responses never surfaced it, so 'openstack server show' printed null.

Found by the SPEC-028 CLI conformance suites (issue #105).

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix(neutron): honour the admin tenant filter on network list and the standard floating-ip list filters

GET /v2.0/networks?tenant_id=<project> ANDed the caller's read scope
into the tenant filter, so an administrator could never see another
project's private networks — 'network list --project <id>' answered []
even though the project owned networks. Real Neutron honours the
filter for admin tokens: when the caller is an admin, the tenant
filter is now the authoritative owner scope. Non-admin callers keep
the scope intersection (their own, plus shared/external).

GET /v2.0/floatingips ignored every list filter — floating_network_id,
port_id, router_id, status, fixed_ip_address, floating_ip_address,
description — so 'floating ip list --network <net>' returned addresses
from every network. All standard exact-match filters are now applied
after the project scope; a non-UUID value on a UUID column answers the
same empty list an unknown id does, not a 500.

Found by the SPEC-028 CLI conformance suites (issue #105).

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix(keystone): seven conformance gaps found by the SPEC-028 CLI suite

- user show/list now select email and description; both were accepted on
  create/set but silently dropped on read, so 'user show' printed
  email: null for a user created with one.
- role create maps the UNIQUE(name) violation to 409 instead of 500.
- role assignment list honours include_names=true, embedding user.name,
  user/project domain names and project names — openstacksdk's consumer
  dies with KeyError 'name' on the bare-id shape, so 'role assignment
  list --names' exited 1.
- domain create/show responses carry links.self; the pinned OSC 7
  formatter aborts with KeyError 'links' without it.
- application credentials: a role given by name only panicked on a nil
  type assertion (gin recovered it as 500 after the row was already
  committed); roles are now resolved by id or name before anything is
  written, an unresolvable role is a 400, the duplicate (user_id, name)
  answers 409 instead of 500, and list/show always carry the roles key.
- migration 074 finally creates application_credential_roles, which the
  handlers have referenced since 029 introduced the feature: every roles
  lookup failed, the error was swallowed, and the roles key vanished
  from the responses.
- token revoke validates the subject token and answers 404 when it
  names nothing revocable (204 for every request hid typos and expired
  ids); a valid token is still acknowledged with 204 — JWTs expire
  naturally, there is no session to destroy.

Found by the SPEC-028 CLI conformance suites (issue #105).

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix(cinder): seven conformance gaps found by the SPEC-028 CLI suite

- volume set accepts the legacy v2 field names (display_name /
  display_description) that python-cinderclient still PUTs for
  --name/--description; the v3 names keep precedence when both are sent.
  Only the v3 names were bound, so the update succeeded but persisted
  nothing.
- volume show and list-detail serialize the volume's user metadata; the
  object answered {} however much was set, so 'volume show' always
  reported empty properties.
- os-set_bootable implements 'volume set --bootable/--non-bootable'
  (was: 400 unknown action); bootable is attach metadata, so it is
  accepted in any status, and malformed payloads 400.
- snapshot create/show/list carry the metadata key — OSC 7's formatter
  crashes with KeyError 'metadata' on a snapshot without one — and show
  and list-detail serialize the snapshot's actual user metadata.
- volume type objects carry their extra_specs, so 'volume type show'
  reports the properties that were set instead of {}.
- a volume type created without a description (NULL) made
  GET /v3/types fail with 500 'failed to read results' for every caller
  until the type was deleted; description is now scanned nullably.
- snapshot, volume-type and backup lookups answer 404 for a non-UUID
  reference instead of surfacing the uuid cast error as 500 — backups
  matter most: cinderclient resolves show/delete by name with no list
  fallback, so the name itself reached the lookup.

Found by the SPEC-028 CLI conformance suites (issue #105).

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* test(cli): sweep volumes with plain delete before --force

os-force-delete is not implemented server-side, so 'volume delete
--force' answers 400 for every volume — including the in-use leftovers
the sweep exists to reclaim. _delete_all now takes a list of delete
templates and tries them in order, and the volume sweep passes plain
delete first with --force as the fallback.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* ci: gate the CLI conformance suite on every PR, nightly full + terraform runs

- cli-conformance job: runs the build artifact's binary natively against
  a PostgreSQL service (no docker), pins the CLI with
  test/cli/constraints.txt, runs the fast subset with the hard coverage
  gate, and uploads the JSONL/JUnit results on any outcome. Added to the
  status-check needs so a regression fails the PR.
- nightly workflow: the full suite with workflows (tier C) under
  --strict, and an apply+destroy run of the unmodified
  terraform-provider-openstack compat module. Both jobs guard on the
  upstream repository so forks can still workflow_dispatch.
- dropped the dead pip install in integration-tests and replaced the
  stale e2e TODO with a pointer to the suites that implement it.

SPEC-028 phase 2 (issue #105).

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* test(terraform): apply/destroy the unmodified compat module against a live server

test/terraform/run.sh wraps the terraform-provider-openstack compatibility
module with a self-contained preflight and a deterministic lifecycle:
per-run tf-cirros-* image, mktemp workspace, TF_PLUGIN_CACHE_DIR,
init/validate/apply, a post-apply no-drift check, destroy, and a final
assertion that the state is empty and no tf-compat-* resources remain
(an adds-only plan proves the destroy reclaimed everything).

The compat module itself stays byte-identical — it is the fixture under
test, not the test.

SPEC-028 phase 3 (issue #105).

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* test(cli): conformance suites for compute, glance, identity, volume and cross-service workflows

Five suites plus their per-service manifests, on the harness core from
the previous commit. Tier A asserts the happy path and response shape of
every manifest command, tier B the negative paths (unknown ids, invalid
payloads, conflicts), tier C the workflows that cross services
(boot-from-volume, snapshot→image→server, attach/detach, security-group
lifecycle, floating-IP association, project isolation, quota
enforcement).

Every case is rerun-safe and self-cleaning: resources are named
cli-conf-<svc>-* and reclaimed by the case that created them; floating
IPs are released explicitly because they carry no name. Known failures
probe for their divergence and record it with evidence — they flip to
hard assertions automatically once the product closes the gap (the
compute suite's server-group, aggregate and backup cases now assert the
fixed behaviour outright).

SPEC-028 phase 1 (issue #105).

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* ci(nightly): install the pinned CLI for the terraform conformance job

The job drives 'make test-terraform', whose preflight needs the
openstack CLI on PATH; the job built the server but never installed the
CLI, so every scheduled run would have died in preflight.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix(git): track the CLI harness gate scripts

'bin/' in .gitignore matched at any depth, so test/cli/bin/run.sh and
coverage.sh were never committed — the ci.yml cli-conformance steps and
make test-cli/cli-coverage/test-all all fail on a fresh checkout. The
pattern now re-includes test/cli/bin/ (scripts, not binaries).

Found by the SPEC-028 review pass.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix(neutron,keystone,cinder): three review follow-ups from the SPEC-028 pass

- floating-ip list filters compare uuid-typed instead of ::text, so an
  upper-case filter value matches like any client expects.
- role-assignment include_names rows without a user or project (not
  creatable through the API today) no longer render a links object with
  empty path segments.
- volume-type extra_specs scans as any-valued jsonb: nothing writes a
  non-string value today, but a future writer would have failed every
  scan of that row.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix(cli): three harness defects found by the SPEC-028 review pass

- The EXIT trap flattened early failures to exit 0: _cli_cleanup ran rm
  before _standalone_exit captured $?, so an unknown option, a missing
  dependency (preflight exits 2), or any failure before run.sh installs
  its own trap exited successfully — CI would have passed. The exit
  status is now captured first and threaded through explicitly.
- _xml_escape used ${var//pat/repl} with '&' replacements: bash >= 5.2
  enables patsub_replacement by default, so '&' expanded to the matched
  text and corrupted the JUnit entities. Rewritten as a per-character
  case, portable across every bash that can run the harness.
- The keypair sweep deleted nothing: OSC's keypair list has no ID
  column, so the id extraction emitted null for every row. The sweep
  now falls back to Name when a kind has no id — which is also the
  handle 'keypair delete' takes.

Also: --strict (known-failing and skipped cases fail the run — the
nightly's stance), a usage-hint instead of bash's unbound-variable
error for value-less options, and OSC_OUT/OSC_ERR's cross-file contract
is annotated for shellcheck.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* ci: install the CLI in a venv and run the nightly suite in strict mode

ubuntu-latest is PEP 668 externally-managed, so a bare pip install of
python-openstackclient fails; both conformance jobs now build a venv
and put its bin dir on GITHUB_PATH (the harness resolves the CLI from
PATH). The cli-conformance timeout rises to 40 minutes to match the
suites' measured runtime, and the nightly's full run passes --strict:
known-failing and skipped cases fail the nightly so the debt cannot
silently grow back.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* test(terraform): preserve failure logs and tighten the residue check

The wrapper worked in a mktemp workspace that its EXIT trap removed,
so a failed run took its apply/destroy logs with it and the CI
artifact step had nothing to upload. Failure logs (and crash.log) are
now copied to test/terraform/results/ before cleanup; nothing is
written on success.

The residue check gains subnets and routers, and the nameless
floating IPs are verified precisely: their ids are captured from the
state before destroy and each is asserted gone afterwards, instead of
counting every FIP on the server (which other suites may legitimately
hold mid-run).

Also updates the apply-failure hint: the Glance ?name= filter
divergence it described is fixed by this branch.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* test(cli): assert the fixed compute/volume behaviour outright

- server lock/unlock: assert the locked flag in server show (surfaced
  by the SPEC-028 nova fix) instead of documenting its absence.
- server-group fixtures create with the current 2.64 client shape —
  the 2.15 microversion pin was a workaround for the fixed policies
  binding.
- aggregate purge comment no longer cites a fixed known failure.
- volume snapshot create asserts status 'creating' — upstream Cinder
  also answers 202 'creating'; the transition to 'available' is
  asserted via the list, as before.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix(neutron): nine CLI-conformance divergences found by the network suite

Every case the new network suite recorded as known-failing, fixed:

- GET/PUT /v2.0/ports/{name} answered 500 (uuid cast) instead of 404,
  which breaks openstacksdk's name fallback for 'port show/set/delete'.
- Same 500-not-404 on GET/PUT /v2.0/subnetpools/{name}.
- add_router_interface ignored port_id entirely ('router add port' read
  the empty subnet_id and answered 500); the port path now attaches a
  caller-owned, unclaimed port and derives the subnet from its fixed IP.
- A duplicate interface was a 500 on the (router_id, subnet_id) unique
  constraint that LEAKED the port it had already inserted — which then
  blocked network deletion with a 409 only 'port delete' could recover
  from. The pre-check refuses with 409 before anything is written, and
  the record insert takes its port back if it fails.
- DELETE /v2.0/subnets/{id} succeeded while a router interface held the
  subnet, orphaning the interface port; now upstream's 409 SubnetInUse,
  via jsonb containment on the holding ports' fixed_ips.
- networks/subnet_pools had no description column (migration 075), so
  'network/subnet pool set --description' was a 400 'no updates
  provided'; the column is bound on create and update and emitted on
  every read path.
- 'subnet set --no-dhcp' PUT enable_dhcp, which the update handler had
  no binding for: a 200 that persisted nothing.
- POST /v2.0/security-groups omitted security_group_rules, so OSC
  rendered null and its table formatter crashed ('NoneType' object is
  not iterable); upstream reports [].
- POST /v2.0/subnetpools stored a malformed prefix as-is ('not-a-cidr'
  -> 201); now the caller's 400, as subnets already were.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* test(cli): network suite — 41 cases, all green against the fixed server

30 manifest commands across networks, subnets, ports, routers,
security groups (and rules), subnet pools, RBAC policies and floating
IPs; 41 cases (29 tier A happy-path/shape, 12 tier B negative .neg).
All resources are cli-conf-nt-* and released on every path, including
the nameless floating IPs.

The nine cases that recorded product divergences as known-failing
probes now assert the fixed behaviour outright; two consecutive
standalone runs are 41/41 pass with zero cli-conf-nt-* residue.

One probe fix along the way: jq's alternative operator treats false
as falsy, so '.enable_dhcp // empty' printed nothing exactly when the
flag was off — the one answer the probe existed to detect. tostring,
not // empty.

Commands the CLI itself cannot drive are excluded with reasons in the
manifest description (address group / network flavor: no routes;
'floating ip show': OSC 7.0.0 formatter crash; 'network rbac set':
openstacksdk client-side crash; 'network agent show': no agents in
the deployment).

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* docs(cli): document run.sh --strict in the Running section

Distinct from coverage.sh --strict (which additionally requires tier C):
run.sh --strict makes known-failing and skipped cases fail the run —
the nightly's stance, so the debt cannot silently grow back.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix(keystone): two more CLI-conformance findings from the full run

- GET /v3/domains items lacked links.self. The direct by-id GET had it
  (added earlier this branch), but the CLI resolves a domain BY NAME
  through the list (show/delete fall back to ?name= after the by-id GET
  404s), so 'domain show <name>' and 'domain delete <name>' aborted
  with KeyError 'links' anyway. Every list item carries it now.
- Keystone's error envelope was the compute shape
  ({"forbidden": {"message": ...}}). openstacksdk tolerates that, but
  the identity client is keystoneauth1, whose from_response parses only
  {"error": {code, message, title}} (or the API-SIG {"errors": [...]}):
  every other body degrades to 'Unrecognized schema in response body.',
  discarding the reason — 'domain delete <enabled>' told the operator
  nothing about disabling it first. The identity engine now marks its
  requests (the same pattern as Neutron's envelope, SPEC-024) and
  renders upstream's shape; every keystone error reason now reaches
  OSC, keystoneauth and openstacksdk clients alike.

Also re-attributes the one remaining volume known-failure to its real
owner: 'volume backup show <name>' is a pinned-OSC-7.0.0 client bug
(raw sdk get_backup, no name fallback — delete uses find_backup), fixed
client-side in OSC 7.3.0; the server's 404-for-a-name matches real
Cinder. The probe self-heals when the pin is raised.

Full-suite effect: keystone 76/76 (domain.show healed), volume 37/38
with the one documented client-side divergence.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix: review round 2 — CI terraform job, residue gate, rollbacks, stale docs

The final pre-PR review's findings, all fixed:

- nightly.yml terraform-conformance installed the CLI into the system
  python — PEP 668 kills that on ubuntu-latest, every night. It now uses
  the same venv pattern as the other two install sites.
- test/terraform run.sh's floating-IP residue check probed with
  'floating ip show', which the pinned OSC 7.0.0 fails client-side on
  EVERY invocation ('Invalid formatter provided.') — the check could
  never fail, so a leaked FIP read as a clean destroy. Resolved through
  'floating ip list' + grep-by-id now.
- AddRouterInterface left the caller's port claimed (device_id set, no
  interface row) when the interface-record insert failed; the rollback
  now un-claims it, restoring the pre-call state.
- Glance answered 500 (VARCHAR(255) overflow) for an over-long image
  tag where upstream's schema answers 400; validated on both the create
  and tag-PUT paths, before any write, with a contract test.
- Harness robustness: coverage.sh value-taking options now guard
  against a missing argument (set -u made it an unbound-variable error
  naming $2, not the option) and the dead STRICT variable is gone;
  report.sh pins LC_NUMERIC=C so printf '%.3f' cannot emit a decimal
  comma into the JUnit XML; suites can register an EXIT-trap cleanup
  hook (suite_cleanup), and compute.sh's temp public-key file uses it
  instead of leaking on a mid-flight kill.
- Stale docs and dead code this branch itself made stale: the network
  suite's inverted 'port survives' comment (router remove port deletes
  it — upstream too), the by-name 500 references in network.sh
  (now 404s), the manifest description still listing the nine fixed
  divergences as known-failing, keystone.sh's 'domain create aborts
  client-side' comment, the terraform README's fixed Glance ?name=
  divergence, the no-op probe block in the keystone envelope test, and
  a leftover stacked doc comment in neutron's network list filter.

Re-verified after the fixes: full run 249 pass / 0 fail / 2
known-failing (console stub-mode, pinned-OSC backup show-by-name),
coverage gate PASSED in both plain and --strict modes, glance/keystone/
neutron/common packages green.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix: review round 3 — last stale-doc stragglers and a test-comment claim

The delta review of 9592cfe confirmed every functional fix correct and
found one leftover plus three nits, all doc-level:

- network.sh's subnetpool-create negative case still said the by-name
  GET 'answers 500 instead of 404' — fixed since ccc4574; now says 404.
  (The four t_known_failure reason strings that still describe the old
  500s are the self-healing probes' diagnostic payloads: they only fire
  again — accurately — if the fix regresses. Left in place, and the
  manifest now says exactly that instead of 'plain assertions'.)
- the terraform wrapper's apply-failure hint pointed at README 'Known
  divergences', which now reads 'None currently' — a circular pointer.
  The hint is self-contained; the pointer is gone, and the README now
  says the hint was reworded rather than removed.
- TestImageTagLengthValidated claimed 'a maximal tag stays legal on
  both paths' but only asserted the PUT; the create path asserts 201
  at 255 chars now too (with cleanup).

Terraform conformance re-verified against the rebuilt binary after
round 2: 9 added / 9 destroyed, zero tf-compat-* residue, PASS —
exercising the reworked FIP residue check live.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix: comprehensive review round 4 — scoping, atomicity, timeouts, harness polish

All thirteen findings from the fresh full-PR review, fixed:

- nightly cli-conformance-full ran on a 30-minute budget while the
  SMALLER per-PR --fast job had 40 — a strict superset with less room.
  60 minutes now (terraform-conformance: 45).
- the terraform wrapper overwrote a caller's OS_PROJECT_DOMAIN_NAME
  with the user-domain fallback (copy-paste of the line above); it now
  falls back user-domain -> Default only when unset.
- GetNetwork kept the caller's read scope unconditionally, so an admin
  could list another project's private network (--project, fixed
  earlier this branch) and then get a 404 showing the id it just
  listed. Upstream's get_network policy is admin_or_owner or shared or
  external; the admin carve-out matches the list filter, with a
  contract test (TestGetNetworkAdminCarveOut_DB).
- AddRouterInterface's subnet lookup was unscoped: a router owner
  could attach an interface to another project's private subnet by id,
  while the port path was already project-scoped. The subnet row must
  now be the caller's or sit on a shared/external network — 404
  otherwise, keeping its existence private
  (TestAddRouterInterfaceSubnetScope_DB).
- UpdateSubnet applied name/gateway and the DHCP flag in two separate
  statements; a failure between them left a half-applied update. All
  supplied columns land in one UPDATE now (SQLUpdate), preserving the
  documented empty-update 200 semantics.
- NULL email/description serialized as "" where every OpenStack API
  emits null (keystone users/projects across list/show/update paths,
  cinder volume types); new common.NullString renders sql.NullString
  the upstream way.
- run.sh trapped INT/TERM directly, so a killed run could exit 0 — the
  signal traps now re-exit with 130/143 so the EXIT trap propagates
  the right status.
- image.sh's temp dir leaked on early exit; it registers the
  suite_cleanup hook (like compute.sh's key file) instead of an
  end-of-file rm.
- the postgres pin in the CI workflows drifted from the repo's
  deployments (18.3 vs 18.4); all four CI references and
  docker-compose.binary-test.yml now say 18.4-alpine, matching what is
  deployed.
- stale annotations this branch itself outgrew: workflows manifest
  still advertising the fixed admin tenant filter as known-failing;
  keystone.sh's user-set case not asserting the --email round-trip it
  can now perform (and dropping the comment that said it couldn't);
  volume.sh's snapshot/type helper comments and the type-create nodesc
  case header still describing fixed 500s.
- gofmt on the three files the reviewer's -l flagged.

Verified: go vet + all internal packages green (-p 1), gofmt clean,
bash -n/shellcheck/YAML clean; full CLI run + coverage gate re-run on
the rebuilt binary (in flight at commit time, zero failures through
the volume suite).

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix(neutron): keep the admin carve-out out of the project-scoped cache

Round-5 delta review of a1e0ea6: all thirteen fixes verified correct,
but the GetNetwork admin carve-out introduced a new hole of its own.

The network cache key names only (project, network), and the lookup
precedes any visibility check — safe while every cached entry had
passed the project's read scope, which is purely project-based. The
carve-out made visibility role-dependent and left the unconditional
TrySet in place: an admin fetching another project's PRIVATE network
(the exact flow the carve-out enables) cached it under the project's
key for the TTL, and a plain member of that project then read the full
body — owner, subnets and all — as a 200 where the uncached answer is
404. Any cache-enabled deployment (the default compose sets
LIGHTSTACK_CACHE_ENABLED) was exposed.

GetNetwork now caches only rows the project is entitled to by the read
scope (owner OR shared OR external); an admin's read of a foreign
private network is served but never cached, so the key's documented
invariant holds again. The guard is written test-first:
TestGetNetworkCacheDoesNotCrossRoles_DB runs against a real local
Redis (skipped when absent), reproduces the poisoning as a failing
member GET before the fix, and passes after — while proving the
entitlement-positive path still caches (two member reads of the
project's own network).

Also from the same review: AddRouterInterface's new subnet predicate
omitted the network-owner disjunct that subnetReadScope and the
subnet update/delete entitlements grant — the owner of a network could
not attach a subnet an admin created on it, inconsistent with every
other subnet surface. 'n.project_id = $2' joins the predicate, with
the case pinned in TestAddRouterInterfaceSubnetScope_DB.

Verified: go vet + all internal packages green (-p 1), gofmt clean;
live server rebuilt from HEAD and smoke-checked (auth, network and
router list).

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* ci: run the cache regression test in CI; pin its cache-hit claim

Round-5 follow-ups on f4b9ebb, both non-blocking:

- TestGetNetworkCacheDoesNotCrossRoles_DB skipped everywhere but a
  developer machine with local Redis: the unit-tests job had no redis
  service. One redis:7-alpine service (127.0.0.1:6379, redis-cli ping
  health check) makes the poisoning regression actually run in CI.
- The test's 'still caches' half was weak — two 200s would pass with
  the TrySet deleted outright. It now also reads the entry back
  through the cache and checks it holds the right network id, so the
  guard is pinned from both sides: foreign-private rows never cached,
  entitled rows always cached.

Verified: go vet, gofmt clean, full neutron package green against the
local DB and Redis (test runs, not skips).

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* test(cli): drop a dead known-failure probe in the token-revoke neg case

Final PR-state review: keystone.token.revoke.neg still carried a
conditional t_known_failure claiming 'DELETE /v3/auth/tokens always
returns 204, so the CLI exits 0' — but RevokeToken has answered 404
for an unknown token since cfacd1b (the 204 no-op remains only for
valid tokens, the documented divergence). The branch could never fire;
the case now asserts the non-zero exit the way every other neg case
does (_ke_assert_failed).

Verified by the full run at this HEAD: 249 pass / 0 fail /
2 known-failing / 0 skipped; coverage gate PASSED (233 rows,
0 untested).

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* test(cli): fail closed on corrupt results; keep standalone suites runnable

Round-7 harness review found the coverage gate and the failure reporter
could pass vacuously: an empty or truncated results.json (a partial write
from a killed runner) or an unparseable manifest made every jq iterate
over nothing and print 'Coverage gate PASSED'. Every jq feeding the gate
is now exit-checked, a zero-row gate is an error, results.json is written
atomically (tmp+mv on success), and report_failed counts a missing or
unparseable results file as a failing run. Fixing the last exposed a
long-standing ordering bug: run.sh's EXIT trap deleted the results file
BEFORE consulting it, so exit-time failure detection was dead code —
report_failed now runs before the cleanup rm and genuinely gates the exit.

Standalone suite runs after a teardown sweep re-ensure the shared
fixtures via fixtures_require (three cheap show calls; the full
sweep-then-create ensure only when something is missing), so
volume/compute/image/workflows no longer fail their fixture-dependent
cases with confusing missing-project errors — verified by a standalone
volume run right after a sweep: 38 cases, 37 pass, 1 known-failing,
exit 0.

Also: --fast --suite combinations that select nothing now die instead of
exiting 0 green (the vacuous-green class this harness exists to prevent);
the workflows FIP-bound assertion requires the row to exist instead of
passing on absence; the nightly's job guard actually allows the manual
fork dispatches its comment promises; the terraform wrapper's residue
comments no longer claim router/FIP coverage the compat module doesn't
have (the checks stay as forward-looking defenses) and its README lists
subnets; assorted doc-accuracy fixes (fixtures_sweep scope, md5sum
requirement, --suite/--no-cleanup wording). The usage-list case documents
why it deliberately has no length guard: every case before it deletes its
server, so an empty listing is the legitimate steady state.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix: comprehensive review round 7 — scoping symmetry, NULL scans, caches, races

Fresh-eyes review of the product diff; every finding was reproduced
against the live server before the fix.

Router interfaces (neutron):
- add_router_interface 500'd on a subnet with no gateway: the lookup
  scanned gateway_ip into a plain string and NULL cannot land in one.
  It now scans *string and falls back to the same allocator CreatePort
  uses (upstream attaches with an allocated address, never 500s).
- The port claim is now conditional (WHERE device_id IS NULL): two
  concurrent attaches of one port to different routers both passed the
  read-check and both claims won. A unique-violation on the interface
  insert answers the same 409 as the pre-check instead of a 500, and
  the rollback now also serves that race (it had already claimed the
  port when it loses).

Admin scoping symmetry (neutron): the GetNetwork admin carve-out
stopped at networks — an admin could show a foreign private network
and then 404 on the subnet ids its own body lists. GetSubnet/GetPort
carry the same carve-out; the subnet/port/network listings drop the
read scope for an admin filtering by tenant (and by network/device,
both explicit cross-project pointers), their markers resolve under the
listing's own scope (an admin's tenant-filtered walk used to 404
mid-page on the rows it just returned); the floating-ip and router
listings honor the admin tenant filter (previously silently ignored —
the admin's rows were presented as the target project's).

Cinder: volume list --all-projects/--project implement cinder's
cross-project semantics (admin-only; ignored for non-admins, as nova's
all_tenants is). A NULL volume description renders as JSON null, the
value upstream emits, instead of "".

Glance: image add/remove tag now evict the image and list caches —
GetImage caches the object including its tags, so a tag added with the
dedicated PUT stayed invisible to image show for the cache's whole
TTL. CreateImage wraps image+tags in one transaction (a tag failure
used to 500 with the image committed; the client's retry duplicated
it) and validates name length (VARCHAR(255) overflow was a 500).

Nova: a duplicate server-group name answered 200 with a second row
(upstream 409, and show-by-name became ambiguous). The handler
pre-checks and maps unique violations to 409; migration 076 folds any
existing duplicates (merging members into the earliest survivor) and
adds the constraint migration 031 always intended but never applied
(its CREATE TABLE IF NOT EXISTS has been a no-op since 017 created
the table). createBackup validates the backup name for the same
VARCHAR(255) reason.

Keystone: the identity error-envelope marker is applied at ENGINE
level too — NoRoute/NoMethod under :35357 rendered the compute
envelope and keystoneauth1 degraded it to 'Unrecognized schema'.

Input hardening: the port listing's uuid-typed filters and the
networks tenant filter compare as ::text, so a non-UUID query value
narrows to nothing instead of failing the cast with a 500 (the guard
the floating-ip loop already carried).

Deliberately unchanged: migration 075's TEXT description columns (a
lenient superset of upstream's VARCHAR(255), with no failure mode) and
snapshot descriptions (every writer binds a string, NULL is
unreachable and "" echoes storage).

Verified at this HEAD: full run 249 pass / 0 fail / 2 known-failing /
0 skipped; coverage gate PASSED; full internal Go suite green; four
new DB-backed contract tests pin the router-interface NULL gateway,
the subnet/port carve-out, the admin tenant filter (neutron router +
cinder volume), and the server-group 409.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* test(cli): round-8 delta polish — exit before leasing, subnet probe, caller checks

Delta review of the round-7 harness fixes found four minors, all fixed:

- The zero-suite exit 2 fired AFTER the compose stack could have been
  started — the selection (pure flag logic) now runs BEFORE server
  selection, so an empty selection dies without leaking a stack.
- fixtures_require now probes the subnet too: the sweep deletes subnets
  before networks, so an interrupted sweep leaves exactly 'network
  present, subnet missing' — a state the three probes called healthy
  while compute's server cases failed later. FIX_SUBNET_ID is populated
  on the fast path.
- Both report_write callers check its return (a failed aggregate no
  longer relies on report_failed's fail-closed backstop alone), and the
  JUnit XML is written atomically like results.json. A failed
  results.json write already skips the JUnit block (return 1 first).
- Doc accuracy: the teardown docstring's covered list matches the sweep
  (FIPs are nameless and NOT swept; snapshots, backups, server groups,
  flavors, users, groups are); each suite's fixture comment names
  exactly what that suite references; the zero-suite error prints the
  actual selection () instead of an unset variable.

The delta review's verdict was SHIP with these as fast-follows; its
verification of all eight round-7 fix areas is recorded in the PR.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix: round-8 delta review — ownership labels, show carve-outs, panic guard

The round-8 delta review verified every round-7 product fix correct at
runtime (placeholder counts, scope decisions, migration 076 on a scratch
DB, tests proven to bite on revert) and found four more, all fixed:

- cinder's detail listing stamped every row with the CALLER's project —
  correct by coincidence before the cross-project listing existed, but
  the admin's --project/--all-projects walk now labeled project X's
  volumes as the admin's (os-vol-tenant-attr:tenant_id is consumed by
  `volume list --long --all-projects`). The listing and GetVolume now
  select and render the row's own project, and GetVolume carries the
  admin show carve-out so the walk's rows don't dead-end their
  follow-up show with 404.
- neutron ports had the same caller-as-tenant_id labeling in list and
  show; both render the row's own project now.
- GetRouter and GetFloatingIP carry the admin show carve-out too (the
  same class: their listings cross projects for admins since round 7).
- allocateIP PANICS on a non-positive rand bound: IPv4 /29-/30 and
  every IPv6 subnet with hostBits >= 64 (where the int64 shift
  overflows to 0) turned a NULL-gateway router attach — and any
  CreatePort on such a subnet — into a 500 via the recovery
  middleware. Tenable pools are refused with the empty string the
  callers already treat as 'no usable address'.

Also removed the dead `images:*` eviction patterns (only
image:<project>:<scope>:<id> keys are ever written — imageCacheKey;
four no-op TryDeletePattern calls, two of them added in round 7).

New pins: Redis-backed add/delete-tag cache-eviction tests, the
glance name-length 400, the allocateIP guard (pure), tenant_id
assertions on the cross-project cinder and port responses, and the
router/volume show carve-outs (admin 200 / member 404).

Verified at this HEAD: full run 249 pass / 0 fail / 2 known-failing /
0 skipped, exit 0; coverage gate PASSED; full internal Go suite green.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix: round-9 review — dead failure check, vacuous pin, unshelve restarts its guest

Round 9 reviewed the round-8 fixes themselves and found two real defects
in them, a product gap the round-8 guard newly exposed, and one product
bug a full run caught by losing a race — all fixed:

- run.sh's report_write failure check was dead code: '|| failed=1' wrote
  a GLOBAL (the 'local failed=0' came later and re-initialized it), so
  an unwritable results dir with a healthy JSONL still exited 0 green.
  The declaration is hoisted above the call and verified with an
  isolated replica of the exact structure.
- TestAddImageTagEvictsCache was vacuous: the tag was a substring of
  the image name, so the assertion matched every response, tagged or
  not — proven by deleting the eviction and watching the test pass.
  The tag is now distinct and the assertion is the exact tags array;
  both eviction pins now fail with the eviction removed.
- CreatePort persisted fixed_ips with a BLANK ip_address for pools the
  round-8 allocateIP guard refuses (/29-/30, the IPv6 overflow) — the
  500 had become silent bad data. It is a clean 400 now, pinned by a
  test that also asserts nothing was persisted.
- unshelve never restarted the guest shelve stopped: the record said
  ACTIVE over a stopped guest, and the state reconciler (whose job is
  exactly that correction) flipped it back to SHUTOFF within one 30s
  sweep — 'server unshelve' observably did nothing, and the conformance
  case failed whenever the sweep won the race. Unshelve now starts the
  guest BEFORE writing ACTIVE (winning the reconciler's compare-and-set
  by construction: a SHELVED row is never a candidate), self-healing
  via reviveGuest like os-start when the domain is gone. Pinned by
  TestUnshelveRestartsGuest; the full run now logs zero guest-off
  corrections where it logged one.
- Migration 077 makes volumes.project_id and ports.project_id NOT NULL:
  both are scanned into plain strings by the ownership labels round 8
  added, and no writer can produce NULL — which is exactly why the
  invariant belongs in the schema. One metadata test fixture inserted
  a NULL port directly; it binds the seeded project now.
- Harness polish from the same round: a half-started compose stack no
  longer outlives a failed startup (teardown before the exit 2 — the
  trap is not installed yet at that point), the zero-suite error no
  longer interpolates an array that is necessarily empty, the cache
  tests' Redis cleanup actually matches its keys (DeletePattern
  prepends the prefix — a prefixed pattern doubled it and matched
  nothing), and neutron's dead 'networks:*' eviction patterns are gone
  (only network:<project>:<id> keys are ever written).

Verified at this HEAD: full run 249 pass / 0 fail / 2 known-failing /
0 skipped, exit 0, zero reconciler corrections; coverage gate PASSED;
full internal Go suite green.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix: round-10 review — self-heal persists the revived domain, 078, partial-up teardown

Round 10 reviewed the round-9 fixes and found one medium plus two small
follow-ups, all fixed:

- The unshelve SELF-HEAL left the row naming the dead domain while the
  revived guest ran under a new one: the reconciler then selected the
  row, asked about the stale id, and flipped ACTIVE back to SHUTOFF
  within one sweep — the exact bug the round-9 restart exists to fix,
  reborn on the self-heal path — and the next os-start self-heal could
  undefined the running guest in real mode (DomainCreate on an
  already-active domain fails and the error path undefines it). The
  ACTIVE update now writes the revived domain id, the way os-start's
  persistRunState always did. Pinned by TestUnshelveSelfHealPersistsRevivedDomain
  (shelve → guest vanishes → unshelve → the row's domain names a RUNNING
  guest), seeded with a root volume so the heal has stored state.
- Migration 078 extends 077's NOT NULL hardening to networks, routers
  and floating_ips — the remaining tables whose project_id is scanned
  into a plain string and rendered as tenant_id by the cross-project
  reads. Every writer binds the auth-context project (verified), so the
  constraint makes an existing invariant structural.
- run.sh marks the compose stack as started BEFORE 'up -d', not after:
  a partially-started project (up fails midway) previously left
  containers and ports behind — the failed-startup exit path only
  tears down a marked stack, and 'down -v' on an unstarted project is a
  harmless no-op.

Accepted as pre-existing (reviewer: informational): a shelve→unshelve
issued inside shelve's async stop window can still end SHUTOFF (upstream
serializes per-instance actions); a client disconnect mid-start leaves
the record SHELVED with the guest up, which a retry resolves.

Verified at this HEAD: full run 249 pass / 0 fail / 2 known-failing /
0 skipped, exit 0; coverage gate PASSED; full internal Go suite green.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix: resolve conformance lint failures

Signed-off-by: Senol Colak <senol.colak@sap.com>

* fix(ci): repair conformance jobs and validate coverage evidence

Signed-off-by: Senol Colak <senol.colak@sap.com>

* fix(ci): pin compatible Helm and patched Go toolchains

Signed-off-by: Senol Colak <senol.colak@sap.com>

* fix(test): require reliable Terraform cleanup evidence

Signed-off-by: Senol Colak <senol.colak@sap.com>

* fix(ci): avoid overlapping Go cache restores

Signed-off-by: Senol Colak <senol.colak@sap.com>

* fix(cinder): retain project filter with all-tenants requests

Signed-off-by: Senol Colak <senol.colak@sap.com>

* fix(cli): baseline known failures; fix shared-pool attribution and tiny/IPv6 allocation

Review findings (comprehensive review of the open senolcolak PRs):

- MEDIUM: nightly --strict was red on arrival because two known-failing cases
  are structurally unpassable (stub console 501; OSC 7.0.0 backup-show bug).
- MEDIUM: the planned '>0 new known-failing blocks' guard did not exist, so a
  regression on any of the ~26 self-healing probes passed both gates. Add a
  checked-in baseline (test/cli/baseline/known_failures.txt); coverage.sh and
  run.sh --strict now fail on any known-failing not in it and warn on stale
  entries. Live: --fast --strict 244/242 pass, full --strict 251/249 pass,
  2 baseline known-failing, exit 0; an empty baseline fails with both
  violations.
- MEDIUM: List/GetSubnetPool rendered the caller's project as tenant_id for
  shared pools; both now select and render the row's owning project.
- MEDIUM: allocateIP refused /30, /29 and all IPv6 pools as 'untenable'.
  Upstream Neutron allocates from them and fails only on exhaustion; the
  allocator now mirrors generate_pools() and never panics. Tests rewritten
  to assert allocation and a 201 from a tiny and an IPv6 pool.
- Numbering: documents (does not change) the SPEC-028 / migration-074
  collision with #108/#109 and the missing spec.md/tasks.md.

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>

* fix: repair conformance branch after main integration

Signed-off-by: Senol Colak <senol.colak@sap.com>

* fix(database): align server-group unique indexes across backends

Signed-off-by: Senol Colak <senol.colak@sap.com>

* fix: preserve resources and fail closed in conformance workflows

Signed-off-by: Senol Colak <senol.colak@sap.com>

* fix: preserve response metadata and tighten conformance evidence

Signed-off-by: Senol Colak <senol.colak@sap.com>

* fix: address PR 107 review feedback

Signed-off-by: Senol Colak <senol.colak@sap.com>

* test: align baseline gate message assertions

Signed-off-by: Senol Colak <senol.colak@sap.com>

* fix(neutron): reserve gateways from default pools

Signed-off-by: Senol Colak <senol.colak@sap.com>

* fix(neutron): preserve gateway allocation conflicts

Signed-off-by: Senol Colak <senol.colak@sap.com>

* fix(test): repair PR 107 CLI failure assertions

Signed-off-by: senol.colak <senol.colak@sap.com>

* fix(keystone): enforce token revocation

Signed-off-by: senol.colak <senol.colak@sap.com>

* fix(test): force CLI target onto checkout binary

Signed-off-by: senol.colak <senol.colak@sap.com>

* fix(middleware): import HTTP status constants

Signed-off-by: senol.colak <senol.colak@sap.com>

* docs: note token revocation migration

Signed-off-by: senol.colak <senol.colak@sap.com>

---------

Signed-off-by: Uwe Schwaeke <uwe.schwaeke@sap.com>
Signed-off-by: Senol Colak <senol.colak@sap.com>
Signed-off-by: senol.colak <senol.colak@sap.com>
Co-authored-by: Uwe Schwaeke <uwe.schwaeke@sap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants