[data] Resolve the DataExport/DataImport API group at runtime - #457
Merged
Conversation
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
force-pushed
the
feat/svdm-legacy-api-fallback
branch
from
August 31, 2026 15:36
da56980 to
b36d5eb
Compare
AleksZimin
marked this pull request as ready for review
August 31, 2026 21:02
ldmonster
approved these changes
Sep 1, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
d8 data export|importwas pinned to a single API group. Commit e4cd67a switched it fromstorage.deckhouse.io/v1alpha1(served by storage-volume-data-manager) tostorage-foundation.deckhouse.io/v1alpha1(served by storage-foundation), which broke thecommands 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:
Both questions are answerable by an ordinary user:
system:discoveryandsystem:basic-userarebound 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 onstorage-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 datamust 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/downloadandd8 data import create/delete/uploadworkunchanged 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:
create dataexports/downloadin
storage.deckhouse.io, but none of its roles grant that verb — the download returns 403until a role is added. That is a gap in that module, to be fixed separately.