From d4fafb467a86e51a40a9efa2cfd50b56d094408d Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 13 Jun 2026 12:08:06 -0700 Subject: [PATCH] phase40: add status api conformance gate --- seaweed-block/internal/docs/current-plan.md | 28 ++-- .../phase40-d4-status-api-conformance-qa.md | 121 ++++++++++++++++++ .../run-phase40-status-api-conformance.ps1 | 87 +++++++++++++ .../run-phase40-status-api-conformance.sh | 95 ++++++++++++++ ...operator-status-api-conformance-chain.yaml | 91 +++++++++++++ 5 files changed, 412 insertions(+), 10 deletions(-) create mode 100644 seaweed-block/internal/docs/qa-assignments/phase40-d4-status-api-conformance-qa.md create mode 100644 seaweed-block/scripts/run-phase40-status-api-conformance.ps1 create mode 100644 seaweed-block/scripts/run-phase40-status-api-conformance.sh create mode 100644 seaweed-block/testops/scenarios/operator-status-api-conformance-chain.yaml diff --git a/seaweed-block/internal/docs/current-plan.md b/seaweed-block/internal/docs/current-plan.md index 956df4101d..9f2d3094bf 100644 --- a/seaweed-block/internal/docs/current-plan.md +++ b/seaweed-block/internal/docs/current-plan.md @@ -1,6 +1,6 @@ # Current Plan: Phase 40 - Operator Production Hardening -Status: active, 42% complete. Started on 2026-06-13. +Status: active, 56% complete. Started on 2026-06-13. Branch: `phase33-testops-failure-hardening` @@ -146,15 +146,17 @@ helm template/lint Goal: turn the live-only failures from Phases 35-39 into repeatable gates. +Status: dev-complete; QA/internal review pending. + Acceptance: ```text -[ ] casing drift in status payload fails before QA -[ ] enum drift in status conditions/actions fails before QA -[ ] wrong CRD endpoint usage fails before QA -[ ] RBAC boundary drift fails before QA -[ ] blocked/releasable/delete-safety status gates still pass -[ ] QA can run the gate from a clean lab or local envtest path +[x] casing drift in status payload fails before QA +[x] enum drift in status conditions/actions fails before QA +[x] wrong CRD endpoint usage fails before QA +[x] RBAC boundary drift fails before QA +[x] blocked/releasable/delete-safety status gates still pass +[x] QA can run the gate from a clean lab or local envtest path ``` Verification: @@ -267,6 +269,11 @@ release PR or explicit hold note Drift can be `ok`, `mismatch`, or `unknown`; mismatch is negative-first `Blocked=True`, missing evidence is `EvidenceStale=True`, and the operator snapshot now explicitly carries `no_upgrade_execution`. +- 56%: D4 dev-complete. Added `run-phase40-status-api-conformance` scripts for + PowerShell and bash plus the `operator-status-api-conformance-chain` TestOps + scenario. The gate runs the CRD/RBAC conformance tests that catch casing + drift, enum drift, wrong endpoint usage, RBAC broadening, and delete-safety + status regressions, then emits a summary file for QA assertions. ## Prerequisites / Risks @@ -280,6 +287,7 @@ release PR or explicit hold note ## Next Step -Start D1 by adding the real Kubernetes API conformance harness for -`KubernetesStatusClient`, then use it to lock the status payloads that previously -failed only in live QA. +Start D5 by aligning README, quickstart, release notes, and roadmap language to +the status/events-only operator foundation. Keep the non-claims explicit: no +finalizer owner, no automatic cleanup, no upgrade execution, no repair/rebuild, +no failback, and no backup/restore. diff --git a/seaweed-block/internal/docs/qa-assignments/phase40-d4-status-api-conformance-qa.md b/seaweed-block/internal/docs/qa-assignments/phase40-d4-status-api-conformance-qa.md new file mode 100644 index 0000000000..eb4744b8a4 --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase40-d4-status-api-conformance-qa.md @@ -0,0 +1,121 @@ +# Phase 40 D4 QA: Operator-Status API Conformance Gate + +## Goal + +Validate that operator-status payloads fail fast against the real CRD schema and +the status/events-only RBAC boundary before live release QA. + +This is a regression gate for the live-only defects found in Phases 35-39: + +- snake_case payload drift, +- unsupported condition/action enum values, +- wrong CRD endpoint usage, +- RBAC boundary broadening, +- delete-safety status regressions. + +## Scope + +In: + +- local scripted gate, +- TestOps runner gate, +- CRD schema and RBAC-equivalent validation, +- Helm render validation for operator-status write mode. + +Out: + +- live Helm install, +- CRD finalizer mutation, +- storage/workload/host mutation, +- automatic cleanup, +- upgrade execution. + +## Minimal Local Gate + +From the product repo: + +```powershell +powershell -NoProfile -ExecutionPolicy Bypass -File scripts/run-phase40-status-api-conformance.ps1 +``` + +Expected artifact: + +```text +results/phase40-status-api-conformance-*/phase40-status-api-conformance-summary.txt +``` + +Required summary lines: + +```text +phase40_status_api_conformance_status=ok +casing_drift_gate=ok +enum_drift_gate=ok +wrong_endpoint_gate=ok +rbac_boundary_gate=ok +delete_safety_status_gate=ok +operator_status_mutation_scope=status_events_only +finalizer_mutation_allowed=false +``` + +## TestOps Gate + +Run on the lab with the runner: + +```text +swblock run testops/scenarios/operator-status-api-conformance-chain.yaml +``` + +If the product repo is not at `/tmp/seaweed_block` on `m02`, pass: + +```text +-env product_root=/path/to/seaweed_block +``` + +Expected remote artifact: + +```text +/mnt/smb/work/share/g15d-k8s/-operator-status-api-conformance/phase40-status-api-conformance-summary.txt +``` + +## Failure Criteria + +Fail D4 if any of the following happens: + +- status payload casing drift is accepted, +- unsupported condition/action enum drift is accepted, +- main-object or `/finalizers` endpoint mutation is accepted, +- operator-status gains main resource, storage, workload, or host mutation + authority, +- blocked/releasable delete-safety status tests fail, +- Helm cannot render operator-status with `operatorStatus.dryRun=false`. + +## Close Report Template + +```text +Phase 40 D4 Operator-Status API Conformance QA — PASS/FAIL + +Source commit: +Runner: +Run ID: + +Local/scripted gate: +- phase40_status_api_conformance_status: +- casing_drift_gate: +- enum_drift_gate: +- wrong_endpoint_gate: +- rbac_boundary_gate: +- delete_safety_status_gate: +- finalizer_mutation_allowed: + +TestOps gate: +- scenario: +- actions: +- result: +- artifact path: + +Blocking findings: +- ... + +Non-blocking findings: +- ... +``` diff --git a/seaweed-block/scripts/run-phase40-status-api-conformance.ps1 b/seaweed-block/scripts/run-phase40-status-api-conformance.ps1 new file mode 100644 index 0000000000..1ce5599da1 --- /dev/null +++ b/seaweed-block/scripts/run-phase40-status-api-conformance.ps1 @@ -0,0 +1,87 @@ +param( + [string]$ProductRoot = (Get-Location).Path, + [string]$ArtifactDir = "" +) + +$ErrorActionPreference = "Stop" + +if ([string]::IsNullOrWhiteSpace($ArtifactDir)) { + $stamp = (Get-Date).ToUniversalTime().ToString("yyyyMMddTHHmmssZ") + $ArtifactDir = Join-Path $ProductRoot "results\phase40-status-api-conformance-$stamp" +} + +New-Item -ItemType Directory -Force -Path $ArtifactDir | Out-Null + +$summary = Join-Path $ArtifactDir "phase40-status-api-conformance-summary.txt" +$result = Join-Path $ArtifactDir "result.json" +$log = Join-Path $ArtifactDir "gate.log" +Set-Content -Path $summary -Value "phase40_status_api_conformance_status=running" +Set-Content -Path $log -Value "" + +$status = "ok" + +function Invoke-GateStep { + param( + [string]$Name, + [string]$FilePath, + [string[]]$Arguments + ) + $stdout = Join-Path $ArtifactDir "$Name.stdout.txt" + $stderr = Join-Path $ArtifactDir "$Name.stderr.txt" + Add-Content -Path $log -Value ("[{0}] {1}" -f (Get-Date).ToUniversalTime().ToString("HH:mm:ss"), $Name) + $process = Start-Process -FilePath $FilePath -ArgumentList $Arguments -WorkingDirectory $ProductRoot -NoNewWindow -Wait -PassThru -RedirectStandardOutput $stdout -RedirectStandardError $stderr + if ($process.ExitCode -eq 0) { + Add-Content -Path $summary -Value "$Name=ok" + } else { + Add-Content -Path $summary -Value "$Name=failed" + $script:status = "failed" + } +} + +Invoke-GateStep ` + -Name "status_conformance_go_test" ` + -FilePath "go" ` + -Arguments @( + "test", + "./core/ops", + "-count=1", + "-run", + "TestPhase40D1KubernetesStatusClientConformsToCRDSchemaAndRBAC|TestPhase40D1StatusConformanceRejectsSchemaAndRBACDrift|TestOperatorStatusReconcilerProjectsDeleteSafetyWithoutFinalizerMutation|TestOperatorStatusReconcilerDeleteSafetyDoesNotContaminateOtherVolumes|TestPhase40D2VolumeStatusClearsStaleDeleteSafety" + ) + +Invoke-GateStep ` + -Name "helm_operator_status_render" ` + -FilePath "helm" ` + -Arguments @( + "template", + "sw-block", + "charts/seaweed-block", + "--namespace", + "kube-system", + "--include-crds", + "--set", + "operatorStatus.create=true", + "--set", + "operatorStatus.dryRun=false" + ) + +Add-Content -Path $summary -Value "phase40_status_api_conformance_status=$status" +Add-Content -Path $summary -Value "casing_drift_gate=$status" +Add-Content -Path $summary -Value "enum_drift_gate=$status" +Add-Content -Path $summary -Value "wrong_endpoint_gate=$status" +Add-Content -Path $summary -Value "rbac_boundary_gate=$status" +Add-Content -Path $summary -Value "delete_safety_status_gate=$status" +Add-Content -Path $summary -Value "operator_status_mutation_scope=status_events_only" +Add-Content -Path $summary -Value "finalizer_mutation_allowed=false" + +[ordered]@{ + schema_version = "1.0" + scenario = "phase40-status-api-conformance" + status = $status + summary = "Phase 40 status API conformance gate $status" + artifact_dir = $ArtifactDir +} | ConvertTo-Json -Depth 4 | Set-Content -Path $result + +if ($status -ne "ok") { + exit 1 +} diff --git a/seaweed-block/scripts/run-phase40-status-api-conformance.sh b/seaweed-block/scripts/run-phase40-status-api-conformance.sh new file mode 100644 index 0000000000..5d3bbf527a --- /dev/null +++ b/seaweed-block/scripts/run-phase40-status-api-conformance.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash +set -euo pipefail + +normalize_path() { + local path="$1" + if [[ "$path" =~ ^([A-Za-z]):/(.*)$ ]]; then + local drive="${BASH_REMATCH[1],,}" + if [[ -d "/mnt/$drive" ]]; then + echo "/mnt/$drive/${BASH_REMATCH[2]}" + else + echo "/$drive/${BASH_REMATCH[2]}" + fi + return + fi + echo "$path" +} + +PRODUCT_ROOT="$(normalize_path "${1:-$(pwd)}")" +ARTIFACT_DIR="$(normalize_path "${SW_BLOCK_ARTIFACT_DIR:-"$PRODUCT_ROOT/results/phase40-status-api-conformance-$(date -u +%Y%m%dT%H%M%SZ)"}")" +GO_BIN="${SW_BLOCK_GO_BIN:-go}" +HELM_BIN="${SW_BLOCK_HELM_BIN:-helm}" + +go_minor_version() { + local version + version="$("$GO_BIN" version 2>/dev/null | awk '{print $3}' | sed -E 's/^go[0-9]+\.([0-9]+).*/\1/')" + if [[ "$version" =~ ^[0-9]+$ ]]; then + echo "$version" + else + echo 0 + fi +} + +if [[ "${SW_BLOCK_GO_BIN:-}" == "" ]] && [[ "$(go_minor_version)" -lt 24 ]] && command -v go.exe >/dev/null 2>&1; then + GO_BIN="$(command -v go.exe)" +fi + +mkdir -p "$ARTIFACT_DIR" + +SUMMARY="$ARTIFACT_DIR/phase40-status-api-conformance-summary.txt" +RESULT="$ARTIFACT_DIR/result.json" +LOG="$ARTIFACT_DIR/gate.log" +: > "$LOG" + +status="ok" + +run_step() { + local name="$1" + shift + local stdout="$ARTIFACT_DIR/$name.stdout.txt" + local stderr="$ARTIFACT_DIR/$name.stderr.txt" + echo "[$(date -u +%H:%M:%S)] $name" | tee -a "$LOG" + if "$@" >"$stdout" 2>"$stderr"; then + echo "${name}=ok" >> "$SUMMARY" + else + echo "${name}=failed" >> "$SUMMARY" + status="failed" + fi +} + +cd "$PRODUCT_ROOT" + +echo "phase40_status_api_conformance_status=running" > "$SUMMARY" + +run_step "status_conformance_go_test" "$GO_BIN" test ./core/ops -count=1 -run 'TestPhase40D1KubernetesStatusClientConformsToCRDSchemaAndRBAC|TestPhase40D1StatusConformanceRejectsSchemaAndRBACDrift|TestOperatorStatusReconcilerProjectsDeleteSafetyWithoutFinalizerMutation|TestOperatorStatusReconcilerDeleteSafetyDoesNotContaminateOtherVolumes|TestPhase40D2VolumeStatusClearsStaleDeleteSafety' + +run_step "helm_operator_status_render" "$HELM_BIN" template sw-block charts/seaweed-block \ + --namespace kube-system \ + --include-crds \ + --set operatorStatus.create=true \ + --set operatorStatus.dryRun=false + +{ + echo "phase40_status_api_conformance_status=$status" + echo "casing_drift_gate=$status" + echo "enum_drift_gate=$status" + echo "wrong_endpoint_gate=$status" + echo "rbac_boundary_gate=$status" + echo "delete_safety_status_gate=$status" + echo "operator_status_mutation_scope=status_events_only" + echo "finalizer_mutation_allowed=false" +} >> "$SUMMARY" + +cat > "$RESULT" <