Skip to content

S3 e2e: fix test-side failures from run 45100042373 - #1703

Open
mxsrc wants to merge 5 commits into
feat/pnfs-e2efrom
fix/s3-e2e-failures
Open

mxsrc wants to merge 5 commits into
feat/pnfs-e2efrom
fix/s3-e2e-failures

Conversation

@mxsrc

@mxsrc mxsrc commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes the test-side causes of the S3 e2e failures in run 45100042373. The product-side fixes are in simplyblock/simplyblock-operator#962, and two cases here depend on it: TC-S3-014 needs its metrics port, and TC-S3-002 needs its finalizer.

One commit per test:

Test Problem Fix
TC-S3-015/016 The operator restart selected control-plane=controller-manager and fell back to restarting mongodb-kubernetes-operator. The PV check ran once, about 0.8s before csi-provisioner deleted the PV. Selects app=simplyblock-operator, falls back only to the exactly named Deployment, and asserts the pod UID changed. Polls 120s each for the PVC, PV and NFSExport to disappear.
TC-S3-014 The scrape used the wrong selector and ran curl inside a pod image that has no curl. Its phase-gauge check asserted once, but the operator rebuilds that gauge only every 30 s. Uses a ServiceAccount token and a port-forward to the operator pod's metrics port, which the e2e and stress workflows now enable with operatorMetrics.enabled=true. The scrape fails unless exactly one operator pod is running. A failed scrape is reported separately from missing samples. The phase-gauge check now re-scrapes for up to two collector intervals.
TC-S3-021 Only accepted a replacement pod on the killed pod's node, which anti-affinity rules out. Accepts any new Ready gateway pod. When the replacement lands on a new node, expects the bucket to be delivered there.
TC-S3-006 Parsed the multi-line bao status JSON one line at a time, so it never parsed. The unseal Secret name was wrong, and the auto-unsealer was left running. The workflow's AppRole setup also failed silently, with no BAO_ADDR, no token, an endpoint outside the certificate, and no CA, so CI's S3 runs never had gateway IAM. Parses the whole output, sets BAO_ADDR, reads openbao-unseal-keys, and scales openbao-unsealer to 0 for the duration of the case. The workflow's S3 step now uses openbao.vault.svc with the root token from openbao-init.txt, and writes simplyblock-s3-iam with that endpoint and OpenBao's CA.
TC-S3-002 Expected the bucket to degrade, which the design never specified. Asserts the decided behavior: the ObjectStore delete is held while buckets reference it, and completes after they are deleted.

Testing

  • py_compile and ruff pass on every changed file. The workflow YAML parses, and the S3 step passes bash -n and shellcheck.
  • The rewritten AppRole block was run against a live OpenBao (cluster91) and wrote a working simplyblock-s3-iam.
  • Full S3 suite on cluster91 against fix(objectstore): S3 e2e failures from run 45100042373 simplyblock-operator#962 (3 storage nodes, stripe 1+0, branch gateway image): 17 of 18 passed, and all 8 cases that failed in run 45100042373 passed their original assertion. The one failure was TC-S3-014's phase-gauge race, which this PR now fixes. Full log: cluster91 logbook (local).
  • Not yet re-run on the CI lab.

🤖 Generated with Claude Code

`_restart_operator` looked for pods labelled
`control-plane=controller-manager`. That is kubebuilder's scaffold label.
The chart's operator Deployment (`simplyblock-operator`) labels its pods
`app=simplyblock-operator` and `control-plane=simplyblock-operator`, so the
selector matched nothing in `simplyblock` and the fallback ran: restart the
first Deployment whose name contains "operator". Run 45100042373 shows what
that picked:

  kubectl rollout restart deploy/mongodb-kubernetes-operator -n simplyblock
  [TC-S3-015] killed the operator at phase=Pending (pods ['mongodb-kubernetes-operator'])

Twice, once per case. TC-S3-015 then "passed" across a restart that never
touched the operator, and TC-S3-016 tested a delete that was never
interrupted.

Select by `app=simplyblock-operator`. When no pod carries it, read the
selector off the Deployment named exactly `simplyblock-operator`, and raise
when there is none, so no other operator can stand in for this one. After
the delete, wait for a Ready pod whose UID did not exist before: a pod that
was never deleted is Ready too, so readiness alone could not prove the kill.

TC-S3-017 read the operator log with the same wrong label, so its "no
forbidden verbs" verdict came from an empty log. It uses the same selector
now.

TC-S3-016's leak check looked once, immediately after the S3Bucket was
gone, and failed on

  [TC-S3-016] ... but PV pvc-97fcaef2-5fd4-4ea9-804a-eb9effd71620 survive.

The PV has reclaim policy Delete and csi-provisioner removes it
asynchronously after the PVC goes; it was gone 0.8s after the check. The
PVC, PV, and NFSExport now each get 120s to disappear before one is called
a leak.
`scrape_operator_metrics` had three independent defects, and any one of
them returned an empty string:

- it found the operator pod by `control-plane=controller-manager`, which
  no pod in `simplyblock` carries (the operator is
  `app=simplyblock-operator`);
- it ran `curl` inside that pod, and the operator image is ubi-minimal,
  which ships no curl;
- the endpoint is controller-runtime's secure serving on 8443, which
  requires a bearer token authorized for GET on the nonResourceURL
  `/metrics`, and the scrape sent none.

The empty string then read as "this metric has no samples". Run
45100042373:

  [TC-S3-014] histogram: {}
  [TC-S3-014] simplyblock_objectstore_bucket_provisioning_seconds has no
  samples after 6 buckets reached Ready.

That is a product finding the harness made up. TC-S3-005 took the same
empty string and passed on it -- `deliveries 0.0 -> 0.0 (expected +6),
failures 0.0` -- so its "no failed deliveries" check has never checked
anything either, and neither have the gauge reads in the stress lane.

Scrape from the test host instead. The scraper applies a ServiceAccount
`e2e-metrics-scraper` bound to the chart's
`simplyblock-operator-metrics-reader` ClusterRole, mints a token with
`kubectl create token`, port-forwards to the operator pod's container port
`metrics`, and GETs `/metrics` with the token and TLS verification off
(the certificate is self-signed). The port comes with a companion
operator-chart change, which serves it only with
operatorMetrics.enabled=true and puts no Service in front of it, since the
samples are one pod's own. The e2e and stress workflows now install the
operator with that value, and the scrape fails unless exactly one operator
pod is running.

A scrape that fails no longer returns an empty string. It raises
S3ProbeError naming the HTTP status and reason, the transport error, or
the port-forward's own stderr, so "the scrape failed" and "the family has
no samples" can no longer be confused. TC-S3-014's no-samples message now
says the scrape succeeded and lists the simplyblock families it did see.
The case killed one of two gateway pods and accepted a replacement only on
the victim's node (`p[1] == victim_node`). The gateway Deployment has
required pod anti-affinity on hostname and no nodeSelector, so while the
victim is still terminating its node is the one place the scheduler must
not put the replacement. Run 45100042373 deleted s3-fn-56c4d84d9b-cgjds on
vm202, a new pod s3-fn-56c4d84d9b-4qqcz was Running by 07:10:00, and the
case waited it out:

  [TC-S3-021] no replacement gateway pod became Ready on
  vm202.simplyblock2.localdomain within 10 minutes

M-01 does not ask for the same node either. Accept any new Ready gateway
pod: not the victim, and not a pod that existed before the kill.

That moves the delivery expectation with it. "The replacement sees the
bucket with no re-delivery" holds only when it lands on a node the bucket
was already delivered to. On a new node the case now waits up to 5 minutes
for `status.mountDeliveredNodes` to name that node before reading through
the pod, and fails if it never does. The DeliverBucket count across the
kill is logged as a finding only in the same-node case, where M-01 says it
must be zero. The replacement's pod and node are recorded.

Every failure in this half now logs the gateway pods with `-o wide`, so the
placement that decided the outcome is in the log rather than reconstructed
from it.
Run 45100042373 refused the case at its first probe:

  [TC-S3-006] cannot read OpenBao's seal state from vault/openbao-0.
  This case needs Vault-backed IAM deployed

OpenBao was deployed, unsealed, and serving the control plane's KMS for the
whole run. `BaoUnsealer.sealed()` could not have said so, for two reasons
either of which is enough:

- It parsed `bao status -format=json` one line at a time. That output is a
  single indented JSON document over many lines, so no line parses and
  the method returns None on every cluster in every state.
- It ran `bao` with the pod's default address, `https://127.0.0.1:8200`,
  which is not a SAN on the server certificate. Verification against the
  chart's `BAO_CACERT` fails before any status is returned.

Neither was visible, because `exec_in_pod_container` appends
`2>/dev/null || true` and returns stdout only: the TLS error and the exit
status were both discarded, and the case could only say "cannot read".

Run `bao` with `BAO_ADDR=https://openbao.<ns>:8200/`, the address
`setup-kms.sh` uses and a SAN on the certificate, through `_exec_kubectl`
so stderr comes back. Parse the output as one document; `bao status` exits
2 when sealed and still prints it, so the exit status is not consulted.
The raw stdout and stderr of the last status are kept and quoted in the
case's probe error.

`unseal()` read `Secret/openbao-init`, which nothing creates. The workflow
stores the keys in `Secret/openbao-unseal-keys` as `KEY1`..`KEY3`; read
those, in numeric order.

Finally, the lane runs `Deployment/openbao-unsealer`, which re-unseals
within ten seconds of a seal. With it running, the case would delete the
pod, see it come back unsealed, and leave through its "auto-unseal is
configured" exit without ever testing the sealed state. The case now scales
it to zero for its duration and restores the original replica count in a
finally.
The case was written while the design left open what deleting an
ObjectStore with live buckets should do. It recorded whichever of "delete
proceeded" or "delete held" happened and failed only on outcomes it judged
plainly wrong. Run 45100042373 hit one of those:

  [TC-S3-002] S3Bucket/tc002a is still Ready after its ObjectStore was
  deleted and every gateway pod is gone. Nothing serves it, and nothing
  says so.

The design has since decided (design-objectstore.md, the deletion
paragraph): the delete is held. `kubectl delete` succeeds and sets
deletionTimestamp, the finalizer `storage.simplyblock.io/objectstore-buckets`
stays while any S3Bucket references the store, the phase is unchanged,
condition `BucketsRemaining` is True and names the buckets, the owned
Deployment and Service are not collected, and the gateway keeps serving.
When the last bucket is deleted the finalizer goes and the store and its
owned objects are collected. A new S3Bucket against a store being deleted
degrades with `ObjectStoreNotFound`.

Assert exactly that, so the run above becomes a product failure rather
than a judgement call:

- for 180s after the delete, every 15s sample must show the store present
  with deletionTimestamp, the finalizer, the phase it had before, and
  `BucketsRemaining` True naming both buckets; the owned Deployment and
  Service still present; a Ready gateway pod; both buckets Ready;
- a GET of each bucket's pre-written object through the gateway still
  matches;
- a new S3Bucket against the store reaches Degraded (Ready is forbidden)
  with `ObjectStoreNotFound` as a condition reason or an event, and is
  then deleted;
- after both buckets are deleted, the ObjectStore and every object it
  owned are gone within 300s, and no bucket PVC survives.

The finalizer and condition names are mirrored in s3_utils next to the
other operator constants. The docstring now states the decided behaviour
instead of saying the design does not decide.
@mxsrc
mxsrc force-pushed the fix/s3-e2e-failures branch from d1ed4a3 to 1701ca7 Compare November 24, 2026 00:11
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.

1 participant