Skip to content

deploy/sbx: a claim class the default StorageClass filled in no longer refuses setup.sh - #945

Merged
pdettori merged 3 commits into
rossoctl:mainfrom
webchang:pr/i935-storage-class-owner
Nov 20, 2026
Merged

pdettori merged 3 commits into
rossoctl:mainfrom
webchang:pr/i935-storage-class-owner

Conversation

@webchang

Copy link
Copy Markdown
Member

Summary

deploy/sbx/setup.sh's storage-class preflight (#887) refused the first re-run of a deployment on a cluster with a default StorageClass: with SBX_STORAGE_CLASS unset, any live claim carrying a storageClassName was refused as "set by an earlier SBX_STORAGE_CLASS run", although the cluster's DefaultStorageClass admission plugin had filled it in. This makes the claim check refuse only what the apply would actually remove.

What changes

  • check_claim_class: with the knob unset, a live class is refused only when an earlier run applied it. The claims come from the overlay, which apply_stack applies client-side (kubectl apply -k); its three-way merge removes a field only when the kubectl.kubernetes.io/last-applied-configuration annotation has it and the new config doesn't. So the check reads the annotation: a class an earlier SBX_STORAGE_CLASS run applied is there and is still refused; a class the DefaultStorageClass admission plugin filled in at create is on the claim but not in the annotation, so a knob-unset apply leaves it alone, and the run now logs that it kept it. A set knob that differs from the live class is still refused (the class is immutable either way).
  • If the annotation is there but isn't valid JSON, the run can't tell who set the class, so it refuses (fail-closed), naming the claim and the fix (SBX_STORAGE_CLASS=<live class>).
  • The StatefulSet half is unchanged: admission doesn't fill volumeClaimTemplates.
  • The header comment and the install page's SBX_STORAGE_CLASS row say so (the pre-commit Prettier hook re-aligned that table).

A read-only check on a live deployment with a default StorageClass confirmed the premise: every claim's spec.storageClassName is the cluster's default StorageClass; no field manager (kubectl-client-side-apply, kube-scheduler, kube-controller-manager) claims f:spec.f:storageClassName; and the overlay claims' last-applied-configuration has no storageClassName. So the admission-filled class is absent from last-applied, as the fix assumes.

Tests

deploy/sbx/tests/setup.test.sh, the component-claims section: the fake PVCs now look like what a client-side apply -k leaves, with the last-applied annotation carrying the class (an earlier knob run) or not (admission filled it in).

  • New: an admission-filled class with the knob unset passes (and is logged); the same claim against a differing knob is still refused; a claim whose last-applied annotation isn't valid JSON is refused before anything is applied, naming the claim, the cause and the fix.
  • Kept: a class an earlier knob run applied, with the knob unset, is refused; mismatch refused; match and classless pass; unrendered claims unread.
  • Before the fix (upstream setup.sh with the new tests): the admission-filled case fails ("a knob-unset run was refused by a claim class the default StorageClass filled in"). After: the suite passes.

Closes #935

Assisted-By: Claude Code

…r knob run applied

With SBX_STORAGE_CLASS unset, check_claim_class refused any live claim
that carried a storageClassName, as 'set by an earlier SBX_STORAGE_CLASS
run'. On a cluster with a default StorageClass, the DefaultStorageClass
admission plugin fills that class in when the claim is created, so every
deployment set up before rossoctl#887 was refused at its next setup.sh.

The claims come from the overlay, which apply_stack applies client-side
(kubectl apply -k); its three-way merge removes a field only when the
last-applied-configuration annotation has it and the new config does
not. A class admission filled in is on the claim but not in that
annotation, so a knob-unset apply leaves it alone. Refuse only when the
annotation carries the class (an earlier knob run applied it); log the
kept class otherwise; and refuse, fail-closed, when the annotation is
there but not valid JSON, since the run can't tell who set the class. A
set knob that differs is still refused. The StatefulSet half is
unchanged: admission does not fill volumeClaimTemplates.

Closes rossoctl#935

Assisted-By: Claude Code
Signed-off-by: Rong Chang <[email protected]>
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 20, 2026

@ingpaolodettori-dev ingpaolodettori-dev 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.

Review — deploy/sbx: a claim class the default StorageClass filled in no longer refuses setup.sh

The premise checks out, and the fix makes the check test exactly what the apply tests. With the knob unset, write_overlay emits no storageClassName patch and base sets none, so a claim's last-applied configuration carries no class; the DefaultStorageClass admission plugin then fills the class in at create, on the claim but not in last-applied, and kc apply -k's three-way merge removes a field only when last-applied had it. So the admission-filled class survives, and the old refusal was over-broad.

  • claim_class_owner reads the same source the merge reads. No annotation → {} → none; a class in last-applied → run, still refused; unparsable → unknown, refused fail-closed naming the claim, the cause and the fix. The \u0000 sentinel is compared inside jq and only run/none/unknown reach the shell, so it cannot reproduce the literal-NUL class of bug.
  • A set knob still takes the forward check first, so a differing class is refused even when admission filled it — immutable either way — and the new test pins that.
  • The run case still dies with the right message, and the unknown advice (set the knob to the live class, which is then a match and therefore safe) is the correct move for an operator who cannot tell who set it.
  • The tests now look like what apply -k leaves: annotation and managedFields split by who set the class, the admission-filled case passing with the log line, the differing knob still refused, and the unparsable case asserting that nothing was applied before the refusal.
  • The install row and the header say which case is kept rather than only what is refused.

The inline comment is a nit about the mechanism named in the new header sentence, not about the check: the StatefulSet half's refusal holds, but the apply that would drop the field is the overlay's client-side merge, not a server-side apply.

Note on CI: no workflow run has been created for this head sha — only DCO has reported, and the other open PRs from the same fork ran normally, so it looks like a missed trigger rather than a failure. This review is from reading the code and the test diff; re-run or push to get the suite green before merging.

Author: webchang (MEMBER — maintainer). One commit, signed off.

Comment thread deploy/sbx/setup.sh Outdated
# where the live object has one and the knob is unset: the server-side
# apply would DROP the field its manager owns) is refused before
# an earlier knob run applied while the knob is now unset: the apply
# would DROP it -- the StatefulSet's server-side apply the field its

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit (accuracy of the comment, not of the check). The redis StatefulSet is in the overlay too — deploy/k8s/base/redis.yaml, pulled in through ocp-single — and apply_stack applies the whole overlay with kc apply -k, i.e. the same client-side three-way merge as the claims, not a server-side apply with a field manager. The refusal is right either way (the merge drops storageClassName from volumeClaimTemplates when last-applied had it and the new config does not), but the sentence reads the server-side mechanism as the reason, and that is not what this script does. check_sts_class's reverse comment says the same thing, and the claim comment just below still names apply_manifest, a function that no longer exists in the script — worth one sweep so the mechanism matches the code.

…ge for the StatefulSet too

The redis StatefulSet comes from the overlay too (deploy/k8s/base/
redis.yaml through ocp-single), and apply_stack applies the whole overlay
client-side (kubectl apply -k): the StatefulSet's refusal reason is the
same three-way merge dropping storageClassName from volumeClaimTemplates,
not a server-side field manager (setup.sh's server-side applies are its
Secrets and ConfigMaps). The header, check_sts_class's reverse comment
and the claim comment, which still named the removed apply_manifest, now
say so. Comments only.

Assisted-By: Claude Code
Signed-off-by: Rong Chang <[email protected]>
…ss-owner

Signed-off-by: Rong Chang <[email protected]>

# Conflicts:
#	docs/operate/sandbox-service/install.md
@pdettori
pdettori merged commit 97e726f into rossoctl:main Nov 20, 2026
17 checks passed
@pdettori pdettori added this to the v0.11.0 milestone Nov 20, 2026
webchang added a commit to webchang/moca that referenced this pull request Nov 20, 2026
Carries rossoctl#941-rossoctl#946, rossoctl#948, rossoctl#950 and rossoctl#338's rossoctl#949/rossoctl#951 (API 1.33.0).
One conflict: docs/operate/sandbox-service/install.md's settings
table; upstream's table kept (its rossoctl#945 SBX_STORAGE_CLASS wording,
the OIDC and proxy-hop rows) plus the fork's SBX_GATE_RECORD_SCHEMA
row. The fork-only set is unchanged: the same 30 files.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deploy/sbx: setup.sh's storage-class check refuses existing claims that a default StorageClass filled in

3 participants