Skip to content

[data] Resolve the DataExport/DataImport API group at runtime - #457

Merged
ldmonster merged 1 commit into
mainfrom
feat/svdm-legacy-api-fallback
Sep 1, 2026
Merged

[data] Resolve the DataExport/DataImport API group at runtime#457
ldmonster merged 1 commit into
mainfrom
feat/svdm-legacy-api-fallback

Conversation

@AleksZimin

@AleksZimin AleksZimin commented Aug 26, 2026

Copy link
Copy Markdown
Member

Description

d8 data export|import was pinned to a single API group. Commit e4cd67a switched it from
storage.deckhouse.io/v1alpha1 (served by storage-volume-data-manager) to
storage-foundation.deckhouse.io/v1alpha1 (served by storage-foundation), which broke the
commands in every cluster where storage-foundation is not installed.

The group is now resolved at runtime, per invocation, as the AND of two independent answers:

  • discovery — is the resource served at all (RBAC-independent);
  • SelfSubjectAccessReview — may this user use it (discovery-independent).

Both questions are answerable by an ordinary user: system:discovery and system:basic-user are
bound to system:authenticated. No ModuleConfig read is involved — end users cannot read it.

Candidates are tried lazily in preference order (storage-foundation first, then
storage-volume-data-manager), so a healthy cluster costs one discovery call. A failing discovery
is reported as an error, never treated as proof of absence. If no group is usable, the error names
what was found: nothing served, or served but forbidden — and which groups.

No change to d8 snapshot: it stays on storage-foundation.deckhouse.io.

No impact on cluster components — client-side only.

Why do we need it, and what problem does it solve?

The upcoming CSE edition ships this CLI but not storage-foundation or state-snapshotter, so
d8 data must keep working against storage-volume-data-manager. Today it fails there outright.
Users may also hold rights on only one of the two groups; the client now follows the rights it
actually has instead of assuming.

What is the expected result?

d8 data export create/list/delete/download and d8 data import create/delete/upload work
unchanged where storage-foundation is present, and work again where only
storage-volume-data-manager is present — including the case where both groups are served but the
user is authorized on just one.

Verified on a live cluster in three configurations (both groups served with rights on
storage-foundation; both served with rights only on the legacy group; storage-foundation disabled
and its CRDs removed), for a PVC and for a VirtualDisk, downloading from inside and outside the
cluster and comparing checksums.

Two things a reviewer should know, neither introduced here:

  • storage-volume-data-manager's exporter authorizes downloads via create dataexports/download
    in storage.deckhouse.io, but none of its roles grant that verb — the download returns 403
    until a role is added. That is a gap in that module, to be fixed separately.
  • The equivalent fix for the previous release branch is out of scope for this PR.

@AleksZimin AleksZimin self-assigned this Aug 26, 2026
Two modules serve the same pair of CRDs under different API groups: storage-foundation
under storage-foundation.deckhouse.io, and storage-volume-data-manager under
storage.deckhouse.io. `d8 data` was built against the first one only, so on a cluster
that ships the second one alone every `d8 data export` and `d8 data import` subcommand
failed outright.

The group is now resolved per invocation, from two questions the API server is asked
before the command does any work:

- discovery: which of the two groups serves the resource. RBAC does not affect the
  answer, so permission alone cannot tell an installed module from an uninstalled one;
- SelfSubjectAccessReview: whether the caller may read it in the target namespace.
  Discovery does not affect the answer, so a served group alone cannot tell an
  authorized user from one whose grants were left behind by a previous edition.

Keeping the two apart is what lets the error name the one thing that has to change: a
group nothing serves means the module is not enabled, while a served group the caller is
not authorized for means an RBAC grant is missing. Both questions are answerable by any
authenticated user, which matters because `d8 data` is run by ordinary users who cannot
read ModuleConfig and whose RBAC may cover only one of the two groups.

storage-foundation wins whenever it is both served and permitted; otherwise the older
group is used. Resolution is lazy — the second candidate is never consulted once the
first qualifies — so a command never depends on the health of a group it would not have
addressed anyway.

Request shapes differ too, and are written per resolved backend:

- DataExport: one shape serves both, because targetRef.group is pruned by the older CRD
  rather than rejected;
- DataImport: the two shapes are structurally different and mutually exclusive.
  storage-foundation requires spec.mode plus a root spec.pvcTemplate and declares no
  targetRef; storage-volume-data-manager requires spec.targetRef carrying the same
  template and declares no mode. Exactly one is filled per request, because sending both
  would survive only as long as neither producer grows the other's key;
- expiry: both spellings are recognised. storage-volume-data-manager raises a standalone
  Expired condition — its exporter pod raises it before the controller mirrors it onto
  Ready — while storage-foundation reports Ready=False with reason Expired. A client
  reading only one spelling polls a dead exporter for the producer's whole retention TTL.

`d8 snapshot` is unchanged and stays pinned to storage-foundation, which it requires
anyway.

Fixed along the way: rebuilding an expired DataExport resolved the target API group after
deleting the old object, so a target kind this CLI cannot classify cost the user the
object. The group is resolved first now, and an unknown kind falls back to the group
already recorded on the object instead of failing. storage-foundation puts no enum on
targetRef.kind, so such an object is legitimate rather than corrupt.

Signed-off-by: Aleksandr Zimin <alexandr.zimin@flant.com>
@AleksZimin
AleksZimin force-pushed the feat/svdm-legacy-api-fallback branch from da56980 to b36d5eb Compare August 31, 2026 15:36
@AleksZimin
AleksZimin marked this pull request as ready for review August 31, 2026 21:02
@AleksZimin
AleksZimin requested a review from ldmonster as a code owner August 31, 2026 21:02
@ldmonster
ldmonster merged commit 3509691 into main Sep 1, 2026
8 of 9 checks passed
@ldmonster
ldmonster deleted the feat/svdm-legacy-api-fallback branch September 1, 2026 09:24
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.

2 participants