Skip to content

test(e2e): isolate S3 bucket per kubernetes scenario - #1417

Merged
kalbasit merged 2 commits into
mainfrom
test-e2e-isolate-s3-bucket-per
Jun 23, 2026
Merged

kalbasit merged 2 commits into
mainfrom
test-e2e-isolate-s3-bucket-per

Conversation

@kalbasit

Copy link
Copy Markdown
Owner

Summary

Fixes the e2e-nightly kubernetes leg, which has failed every scheduled run since 2026-06-11 on the CDC scenarios (single-s3-postgres-cdc, ha-s3-postgres-cdc, ha-s3-postgres-cdc-lifecycle) with PostgreSQL database is empty (0 chunks).

Root cause (confirmed via local Kind e2e + pod logs + bucket-empty proof): the kubernetes harness isolates a database per scenario but shared a single Garage bucket (ncps-bucket) across every scenario and never cleaned it. Earlier non-CDC scenarios reuse the same test narinfo hashes and leave whole-file .nar.xz objects in store/nar/. When a CDC scenario then runs with a fresh database against that dirty bucket, ncps (since #1393 treats a stored .nar.xz as a present Compression:none NAR) sees the residual whole file as already present, skips the upstream download + eager chunking, and BackgroundMigrateNarToChunks fails with error fetching nar from store: not found — so zero chunk rows are created and validation fails. Pre-#1393 the path only checked .nar.zst, missed the residual, re-downloaded and eager-chunked (the last green run produced 4 chunks). cdc-lifecycle passes because it uses local per-pod storage with no shared residue.

What changed (test harness only — no ncps / chart / CDC behavior change)

  • harness_config.scenario_bucket_name() — single source of truth deriving ncps-<scenario>.
  • config.nix — each scenario's generated Helm values use its own bucket.
  • k8s_tests.py — garage setup creates + grants a bucket per S3 scenario (idempotent); test-config carries the per-scenario bucket.
  • k8s_tests_tester.py — S3 storage validation reads the per-scenario bucket.

A per-scenario bucket (not prefix) isolates the NAR, narinfo, and chunk stores at once — the chunk store ignores the configured S3 prefix, so a per-scenario prefix would leave chunks colliding.

Test plan

  • nix eval confirms each S3 scenario renders a distinct ncps-<name> bucket; local scenarios get none
  • New harness unit test (test_s3_bucket_isolation.py); e2e-harness-unit net green (66 passed)
  • task fmt, task lint, task test (0 failures) green
  • Live Kind run: single-s3-postgres (non-CDC) then all three CDC scenarios → 4/4 pass, 4 chunks each (cross-scenario isolation proven)
  • e2e-nightly workflow_dispatch on this branch goes green (kubernetes leg)

The e2e-nightly kubernetes leg failed every scheduled run since
2026-06-11 on the CDC scenarios (single-s3-postgres-cdc,
ha-s3-postgres-cdc, ha-s3-postgres-cdc-lifecycle) with
"PostgreSQL database is empty (0 chunks)".

Why: the kubernetes harness isolated a database per scenario but shared
one Garage bucket (ncps-bucket) across every scenario and never cleaned
it. Earlier non-CDC scenarios reuse the same test narinfo hashes and
leave whole-file .nar.xz objects in store/nar/. When a CDC scenario then
runs with a fresh database against that dirty bucket, ncps (since #1393
treats a stored .nar.xz as a present Compression:none NAR) sees the
residual whole file as already present, skips the upstream download and
eager chunking, and BackgroundMigrateNarToChunks fails with "error
fetching nar from store: not found" -- so zero chunk rows are created
and validation fails. Pre-#1393 the path only checked .nar.zst, missed
the residual, re-downloaded and eager-chunked. cdc-lifecycle passes
because it uses local per-pod storage with no shared residue.

How: isolate the S3 bucket per scenario, mirroring the per-scenario
database isolation. A shared scenario_bucket_name helper derives
ncps-<scenario> (the single source of truth); config.nix renders it into
each scenario's Helm values; garage setup creates and grants each
per-scenario bucket idempotently; and the S3 storage validation reads
the per-scenario bucket. A bucket isolates NAR, narinfo, and chunk
stores at once (the chunk store ignores the configured prefix, so a
per-scenario prefix would be incomplete). Test-harness only; no ncps,
chart, or CDC behavior change.

Verified: nix eval shows distinct ncps-<name> buckets per S3 scenario;
new harness unit test; task fmt/lint/test green; and a live Kind run of
single-s3-postgres (non-CDC) followed by all three CDC scenarios passes
4/4 with non-zero chunk counts.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@kalbasit

kalbasit commented Jun 23, 2026 •

Copy link
Copy Markdown
Owner Author

This change is part of the following stack:

Change managed by git-spice.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 23, 2026
@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4ea1ea59-c2b7-484b-a2d2-715b7734c5cd

📥 Commits

Reviewing files that changed from the base of the PR and between 1e76ead and 4e80be8.

📒 Files selected for processing (3)
  • nix/e2e-tests/config.nix
  • nix/e2e-tests/src/harness_config.py
  • nix/e2e-tests/src/k8s_tests.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • nix/e2e-tests/src/harness_config.py
  • nix/e2e-tests/src/k8s_tests.py
  • nix/e2e-tests/config.nix

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • New Features

    • Updated Kubernetes e2e harness to isolate S3 storage per scenario using a deterministic per-scenario bucket name.
  • Bug Fixes

    • Prevented cross-scenario CDC failures caused by leftover S3 objects from prior scenarios.
  • Tests

    • Added unit tests to verify per-scenario bucket naming and that different scenarios map to different valid bucket names.
  • Documentation

    • Added design, proposal, specs, and task notes covering the per-scenario S3 isolation approach.

Walkthrough

The e2e test harness is updated to replace a single shared Garage S3 bucket (ncps-bucket) with deterministic per-scenario buckets named ncps-<scenario-name>. A new helper scenario_bucket_name centralizes the naming convention, Garage setup now provisions one bucket per S3 scenario, Helm values and deployment configs are wired to the scenario-specific bucket, and S3 validation prefers the per-deployment bucket. Unit tests and openspec documentation are added.

Changes

Per-scenario S3 bucket isolation in e2e harness

Layer / File(s) Summary
scenario_bucket_name helper contract
nix/e2e-tests/src/harness_config.py, nix/e2e-tests/src/k8s_tests.py
Adds scenario_bucket_name(scenario_name: str) -> str returning ncps-<name> with isolation rationale in docstring; imports it into k8s_tests.py.
Garage setup: per-scenario bucket provisioning
nix/e2e-tests/src/k8s_tests.py
Replaces single ncps-bucket creation/grant with a loop over Nix permutations that creates one bucket per S3 scenario and grants the shared access key owner/read/write on each; updates config file default and adds fallback comment to get_cluster_creds.
Helm values and deployment config wiring
nix/e2e-tests/config.nix, nix/e2e-tests/src/k8s_tests.py, nix/e2e-tests/src/k8s_tests_tester.py
config.nix sets bucket to ncps-${perm.name} instead of the inherited s3.bucket; k8s_tests.py injects scenario_bucket_name(perm["name"]) into each S3 deployment's storage config; k8s_tests_tester.py reads deployment_config.storage.bucket first, falling back to s3_config["bucket"].
Unit tests for bucket isolation
nix/e2e-tests/tests/test_s3_bucket_isolation.py
Adds two tests: one asserting distinct scenarios produce distinct expected bucket names, another validating S3 naming constraints (lowercase, no underscores, length 3–63).
Spec and design documentation
openspec/specs/unified-e2e-harness/spec.md, openspec/changes/archive/2026-06-22-isolate-e2e-s3-bucket-per-scenario/*
Updates the live harness spec with per-scenario S3 isolation requirements and acceptance criteria; archives proposal, design (including rejected alternatives and migration plan), tasks checklist, and sub-spec.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

bug, helm, size:M

Poem

🐇 Hop hop, no more sharing a pail!
Each scenario gets its own S3 trail.
ncps-<name> carved fresh in the store,
CDC chunks won't trip on leftovers anymore.
Clean buckets for all — the nightly shall sail! 🪣✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: isolating S3 buckets per scenario in the e2e kubernetes tests. It is concise and clearly reflects the primary objective of the PR.
Description check ✅ Passed The description provides substantial context about the root cause, the fix implemented, and validation steps performed. It is directly related to the changeset and explains the problem being solved.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request isolates S3 storage per scenario in the Kubernetes e2e test harness to prevent cross-scenario data contamination, which previously caused CDC scenarios to fail due to residual whole-file NARs. It introduces per-scenario bucket creation, updates Helm value generation and validation, and adds unit tests. The review feedback highlights a potential path mismatch for the config file, a potential AttributeError when parsing permutations, and suggests normalizing bucket names in both Python and Nix to ensure strict S3 compatibility.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread nix/e2e-tests/src/k8s_tests.py Resolved
Comment thread nix/e2e-tests/src/k8s_tests.py Resolved
Comment thread nix/e2e-tests/src/harness_config.py Resolved
Comment thread nix/e2e-tests/config.nix Resolved
Addresses gemini-code-assist review feedback on PR #1417:

- Fix stale default config path in K8sTestsCLin.__init__: the fallback
  pointed at the removed nix/k8s-tests/config.nix; correct it to
  nix/e2e-tests/config.nix (thread PRRT_kwDONV6tZs6LfFt9).
- Guard the garage per-scenario bucket loop against a permutation whose
  storage is explicitly null: (perm.get("storage") or {}).get("type")
  (thread PRRT_kwDONV6tZs6LfFuB).

Declined the two bucket-name normalization suggestions (threads
PRRT_kwDONV6tZs6LfFuI, PRRT_kwDONV6tZs6LfFuM) and documented why:
scenario names are kebab-case by the catalog contract (already valid S3
bucket names), and plain Nix has no toLower builtin -- the suggested
builtins.toLower does not exist -- so normalizing only one side would
desync the Python and Nix bucket names. Both sides are kept verbatim
ncps-<name> so they stay byte-for-byte identical; clarified the comments
on both sides to say so.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@kalbasit

Copy link
Copy Markdown
Owner Author

Addressed review feedback in 4e80be8:

  • config_file default path + null-storage guard — fixed as suggested.
  • Bucket-name normalization (both threads) — respectfully declined. Scenario names are kebab-case by the catalog contract (the unified-e2e-harness spec mandates a stable kebab-case name), so ncps-<name> is already a valid S3 bucket name. Also, builtins.toLower is not a Nix builtin, so the suggested Nix normalization wouldn't evaluate; normalizing only the Python side would risk the Python and Nix bucket names drifting apart. Both sides are kept verbatim so they stay byte-for-byte identical (verified via nix eval vs the Python helper: 0 mismatches across all 11 S3 scenarios). Comments on both sides now document this.

@kalbasit
kalbasit merged commit 2bba9d8 into main Jun 23, 2026
45 of 57 checks passed
@kalbasit
kalbasit deleted the test-e2e-isolate-s3-bucket-per branch June 23, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant