dataio

package
v0.33.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTTL                = "2m"
	PersistentVolumeClaimKind = "PersistentVolumeClaim"
	VolumeSnapshotKind        = "VolumeSnapshot"
	VirtualDiskKind           = "VirtualDisk"
	VirtualDiskSnapshotKind   = "VirtualDiskSnapshot"
	Namespace                 = "d8-storage-volume-data-manager"
)
View Source
const (
	// ConditionTypeReady is the readiness condition both producers set.
	ConditionTypeReady = "Ready"

	// ConditionTypeExpired is the standalone expiry condition storage-volume-data-manager sets.
	// storage-foundation dropped it in favour of ReasonExpired on Ready.
	ConditionTypeExpired = "Expired"

	// ReasonExpired is the Ready-condition reason both producers use for idle expiry.
	ReasonExpired = "Expired"
)

Condition types and reasons shared by DataExport and DataImport.

View Source
const (
	ProbeTimeout = 3 * time.Second
)

Variables

View Source
var ErrAutoDetectWithHint = errors.New("cannot auto-detect publish mode, specify --publish=true or --publish=false")
View Source
var (
	ErrUnsupportedVolumeMode = errors.New("invalid volume mode")
)

Functions

func AskYesNoWithTimeout

func AskYesNoWithTimeout(prompt string, timeout time.Duration) bool

func DetectPublish added in v0.29.8

func DetectPublish(
	ctx context.Context,
	rtClient ctrlrtclient.Client,
	sClient *safeClient.SafeClient,
	log *slog.Logger,
) (bool, error)

DetectPublish decides default publish mode when user did not set --publish.

Detection strategy:

  1. Read Service default/kubernetes via the normal kubeconfig endpoint.
  2. Read the same Service via https://<ClusterIP>:443 with ServerName override.
  3. Compare UIDs of both objects.

Decision matrix:

  • same UID: internal path is reachable -> publish=false
  • UID mismatch: ClusterIP reached a different cluster (e.g. local minikube/kind) -> publish=true
  • network-unreachable on probe: internal path is not reachable -> publish=true
  • TLS/auth rejection on probe: ClusterIP reached a different server -> publish=true
  • any other probe error (transient 5xx, cancellation, deserialization): ambiguous -> fail fast with hint

func IsExpired added in v0.33.14

func IsExpired(conditions []metav1.Condition) bool

IsExpired reports whether the conditions say the DataExport or DataImport has terminally idle-expired, so the caller must recreate it rather than keep polling. After expiry the producer's garbage collector only removes the object once its retention TTL runs out, so waiting it out would stall for as long as that retention lasts.

Both spellings of expiry are accepted, because the producers do not agree on one and a client that reads only its own producer's spelling silently waits forever against the other:

  • storage-volume-data-manager raises a standalone Expired condition (and also reports it as a Ready reason);
  • storage-foundation has no Expired condition type at all and reports it only as Ready=False with reason Expired.

The two cannot be confused for one another: neither producer uses either spelling to mean anything but expiry.

func KindToGroup added in v0.32.5

func KindToGroup(kind string) (string, error)

KindToGroup resolves the API group for a supported DataExport target kind. The kind is sent verbatim as targetRef.kind; only the group needs deriving here (the controller resolves the served version via its RESTMapper). These groups match the producer's DataExportTargetRefSpec contract in storage-volume-data-manager/api/v1alpha1/data_export.go. Returns an error for unrecognised kinds.

func NotReady added in v0.33.14

func NotReady(conditions []metav1.Condition) *metav1.Condition

NotReady returns the Ready condition when it is present and not True, and nil otherwise — including when the object carries no Ready condition at all, which callers treat as "nothing said yet" rather than as a failure.

func ParseArgs

func ParseArgs(args []string) (string, string, error)

func ResolvePublish added in v0.29.8

func ResolvePublish(
	ctx context.Context,
	publishFlag PublishFlag,
	rtClient ctrlrtclient.Client,
	sClient *safeClient.SafeClient,
	log *slog.Logger,
) (bool, error)

ResolvePublish returns explicit publish value if user set the flag, otherwise runs autodetection.

func ShouldCleanup added in v0.29.16

func ShouldCleanup(cleanup, cleanupExplicit bool) bool

ShouldCleanup decides whether to delete an auto-created DataExport. When the --cleanup flag was explicitly set by the user, its value is used directly. Otherwise the decision is delegated to an interactive prompt with a timeout.

Types

type PublishFlag added in v0.29.8

type PublishFlag struct {
	Explicit bool
	Value    bool
}

PublishFlag represents the three-state publish flag:

  • Explicit=true, Value=true: user explicitly requested public (published) access
  • Explicit=true, Value=false: user explicitly requested internal (in-cluster) access
  • Explicit=false: auto-detect mode (Value is meaningless)

func ParsePublishFlag added in v0.29.8

func ParsePublishFlag(flags *pflag.FlagSet) (PublishFlag, error)

ParsePublishFlag reads --publish as a three-state value. Explicit is true only when user provided --publish/--publish=true/--publish=false.

Directories

Path Synopsis
Package dataapi resolves which of the two API groups a cluster serves DataExport and DataImport under, and which of them the calling user is actually authorized to use.
Package dataapi resolves which of the two API groups a cluster serves DataExport and DataImport under, and which of them the calling user is actually authorized to use.
dataexport
cmd
dataimport
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL