Documentation
¶
Index ¶
- Constants
- Variables
- func CephFSDataPoolFullName(fsName, dataPoolName string) string
- func CreateCephBlockPool(ctx context.Context, kubeconfig *rest.Config, cfg CephBlockPoolConfig) error
- func CreateCephCluster(ctx context.Context, kubeconfig *rest.Config, cfg CephClusterConfig) error
- func CreateCephClusterAuthentication(ctx context.Context, kubeconfig *rest.Config, ...) error
- func CreateCephClusterConnection(ctx context.Context, kubeconfig *rest.Config, cfg CephClusterConnectionConfig) error
- func CreateCephFilesystem(ctx context.Context, kubeconfig *rest.Config, cfg CephFilesystemConfig) error
- func CreateCephStorageClass(ctx context.Context, kubeconfig *rest.Config, cfg CephStorageClassConfig) error
- func CreateLVMVolumeGroup(ctx context.Context, kubeconfig *rest.Config, name, nodeName string, ...) error
- func CreateLVMVolumeGroupWithThinPool(ctx context.Context, kubeconfig *rest.Config, name, nodeName string, ...) error
- func CreateLocalStorageClass(ctx context.Context, kubeconfig *rest.Config, cfg LocalStorageClassConfig) error
- func CreateNamespaceIfNotExists(ctx context.Context, config *rest.Config, name string) (*corev1.Namespace, error)
- func CreateStaticNodeGroup(ctx context.Context, config *rest.Config, name string) error
- func CreateStorageClass(ctx context.Context, kubeconfig *rest.Config, cfg StorageClassCreateConfig) error
- func CreateVolumeSnapshotClass(ctx context.Context, kubeconfig *rest.Config, cfg VolumeSnapshotClassConfig) error
- func DeleteCephBlockPool(ctx context.Context, kubeconfig *rest.Config, namespace, name string) error
- func DeleteCephCluster(ctx context.Context, kubeconfig *rest.Config, namespace, name string) error
- func DeleteCephClusterAuthentication(ctx context.Context, kubeconfig *rest.Config, name string) error
- func DeleteCephClusterConnection(ctx context.Context, kubeconfig *rest.Config, name string) error
- func DeleteCephFilesystem(ctx context.Context, kubeconfig *rest.Config, namespace, name string) error
- func DeleteCephStorageClass(ctx context.Context, kubeconfig *rest.Config, name string) error
- func DeleteLVMVolumeGroup(ctx context.Context, kubeconfig *rest.Config, name string) error
- func DeleteRookConfigOverride(ctx context.Context, kubeconfig *rest.Config, namespace string) error
- func DetachAndDeleteVirtualDisk(ctx context.Context, kubeconfig *rest.Config, ...) error
- func EnableAndConfigureModules(ctx context.Context, kubeconfig *rest.Config, ...) error
- func EnableModulesAndWait(ctx context.Context, kubeconfig *rest.Config, sshClient ssh.SSHClient, ...) error
- func EnableModulesWithSpecs(ctx context.Context, kubeconfig *rest.Config, sshClient ssh.SSHClient, ...) error
- func ExecInPod(ctx context.Context, kubeconfig *rest.Config, namespace, pod, container string, ...) (stdout, stderr string, err error)
- func FindSecretByName(ctx context.Context, kubeconfig *rest.Config, namespace, name string) (string, error)
- func FindUnsetEnvVars(content string) []string
- func GetDefaultStorageClassName(ctx context.Context, kubeconfig *rest.Config) (string, error)
- func GetNodeTaints(ctx context.Context, kubeconfig *rest.Config, nodeName string) ([]corev1.Taint, error)
- func GetNodes(ctx context.Context, kubeconfig *rest.Config) ([]corev1.Node, error)
- func GetSecretDataValue(ctx context.Context, kubeconfig *rest.Config, namespace, name, key string) (string, error)
- func GetStorageClass(ctx context.Context, kubeconfig *rest.Config, name string) (*storagev1.StorageClass, error)
- func GetVMIPFromBaseCluster(ctx context.Context, baseKubeconfig *rest.Config, namespace, vmName string) (string, error)
- func GetVMPodNodeAndContainerID(ctx context.Context, baseConfig *rest.Config, namespace, vmName string) (nodeName, containerID string, err error)
- func GetWorkerNodes(ctx context.Context, kubeconfig *rest.Config) ([]corev1.Node, error)
- func IsNodeCordoned(ctx context.Context, kubeconfig *rest.Config, nodeName string) (bool, error)
- func LabelNodes(ctx context.Context, kubeconfig *rest.Config, nodeNames []string, ...) error
- func ListVirtualMachineNames(ctx context.Context, kubeconfig *rest.Config, namespace string) ([]string, error)
- func NewClientsetWithRetry(ctx context.Context, config *rest.Config) (*kubernetes.Clientset, error)
- func NewDynamicClientWithRetry(ctx context.Context, config *rest.Config) (dynamic.Interface, error)
- func NewVirtualizationClient(ctx context.Context, config *rest.Config) (*virtualization.Client, error)
- func ReadFileFromDistrolessPod(ctx context.Context, kubeconfig *rest.Config, ...) (string, error)
- func ReadFileFromPod(ctx context.Context, kubeconfig *rest.Config, ...) (string, error)
- func RenderCephGlobalConfig(globals map[string]string) string
- func ResizeList(ctx context.Context, clientset *kubernetes.Clientset, namespace string, ...) error
- func SetGlobalDefaultStorageClass(ctx context.Context, kubeconfig *rest.Config, storageClassName string) error
- func SetRookConfigOverride(ctx context.Context, kubeconfig *rest.Config, namespace string, ...) error
- func WaitForAllPodsReadyInNamespace(ctx context.Context, kubeconfig *rest.Config, namespace string, ...) error
- func WaitForCephBlockPoolGone(ctx context.Context, kubeconfig *rest.Config, namespace, name string, ...) error
- func WaitForCephBlockPoolReady(ctx context.Context, kubeconfig *rest.Config, namespace, name string, ...) error
- func WaitForCephClusterAuthenticationGone(ctx context.Context, kubeconfig *rest.Config, name string, ...) error
- func WaitForCephClusterConnectionCreated(ctx context.Context, kubeconfig *rest.Config, name string, ...) error
- func WaitForCephClusterConnectionGone(ctx context.Context, kubeconfig *rest.Config, name string, ...) error
- func WaitForCephClusterGone(ctx context.Context, kubeconfig *rest.Config, namespace, name string, ...) error
- func WaitForCephClusterReady(ctx context.Context, kubeconfig *rest.Config, namespace, name string, ...) error
- func WaitForCephFilesystemGone(ctx context.Context, kubeconfig *rest.Config, namespace, name string, ...) error
- func WaitForCephFilesystemReady(ctx context.Context, kubeconfig *rest.Config, namespace, name string, ...) error
- func WaitForCephStorageClassCreated(ctx context.Context, kubeconfig *rest.Config, name string, ...) error
- func WaitForCephStorageClassGone(ctx context.Context, kubeconfig *rest.Config, name string, ...) error
- func WaitForLVMVolumeGroupDeletion(ctx context.Context, kubeconfig *rest.Config, name string, ...) error
- func WaitForLVMVolumeGroupReady(ctx context.Context, kubeconfig *rest.Config, name string, ...) error
- func WaitForLocalStorageClassCreated(ctx context.Context, kubeconfig *rest.Config, name string, ...) error
- func WaitForModuleReady(ctx context.Context, kubeconfig *rest.Config, moduleName string, ...) error
- func WaitForModulesReady(ctx context.Context, kubeconfig *rest.Config, ...) error
- func WaitForModulesReadyWithSpecs(ctx context.Context, kubeconfig *rest.Config, ...) error
- func WaitForNodesLabeled(ctx context.Context, kubeconfig *rest.Config, nodeNames []string, ...) error
- func WaitForPVCsBound(ctx context.Context, clientset *kubernetes.Clientset, ...) error
- func WaitForPVCsResized(ctx context.Context, clientset *kubernetes.Clientset, namespace string, ...) error
- func WaitForPodsStatus(ctx context.Context, clientset *kubernetes.Clientset, ...) error
- func WaitForStorageClass(ctx context.Context, kubeconfig *rest.Config, storageClassName string, ...) error
- func WaitForStorageClasses(ctx context.Context, kubeconfig *rest.Config, storageClassNames []string, ...) map[string]error
- func WaitForVirtualDiskAttached(ctx context.Context, kubeconfig *rest.Config, namespace, attachmentName string, ...) error
- func WaitForVolumeSnapshotClass(ctx context.Context, kubeconfig *rest.Config, name string, ...) error
- type ApplyClient
- func (c *ApplyClient) ApplyYAML(ctx context.Context, yamlContent string, namespace string) error
- func (c *ApplyClient) CreateYAML(ctx context.Context, yamlContent string, namespace string) error
- func (c *ApplyClient) CreateYAMLFromFileWithEnvvars(ctx context.Context, filePath string, namespace string) error
- type BlockDevice
- type CephBlockPoolConfig
- type CephBlockPoolErasureCoded
- type CephClusterAuthenticationConfig
- type CephClusterConfig
- type CephClusterConnectionConfig
- type CephCredentials
- type CephFilesystemConfig
- type CephStorageClassConfig
- type DistrolessReader
- type LocalStorageClassConfig
- type ModuleSpec
- type ReadFileOptions
- type StorageClassCreateConfig
- type TestClusterResourcesInterface
- type ThinPoolSpec
- type VirtualDiskAttachmentConfig
- type VirtualDiskAttachmentResult
- type VirtualDiskReattachmentConfig
- type VolumeSnapshotClassConfig
Constants ¶
const ( DefaultRookNamespace = "d8-sds-elastic" DefaultCephClusterName = "ceph-cluster" DefaultCephImage = "quay.io/ceph/ceph:v18.2.7" DefaultDataDirHostPath = "/var/lib/rook" DefaultOSDStorageClassSize = "10Gi" )
Defaults shared between CephClusterConfig and the testkit-level helper.
const ( // RookMonSecretName is the Secret that the Rook operator populates with // admin credentials and cluster fsid once the CephCluster is bootstrapped. RookMonSecretName = "rook-ceph-mon" // RookMonEndpointsConfigMapName is the ConfigMap the operator keeps in // sync with the current set of Ceph monitors. RookMonEndpointsConfigMapName = "rook-ceph-mon-endpoints" )
Well-known Rook resources that hold Ceph connection data.
const ( CephStorageClassTypeRBD = "RBD" CephStorageClassTypeCephFS = "CephFS" )
Supported CephStorageClass types, mirroring csi-ceph's CRD enum.
const CephBlockPoolGoneTimeout = 5 * time.Minute
CephBlockPoolGoneTimeout is the default budget for WaitForCephBlockPoolGone. Rook removes the underlying RBD pool from Ceph before lifting the finalizer; with one OSD the pool delete normally completes in seconds but can take a few minutes if the cluster is unhealthy.
const CephClusterAuthenticationGoneTimeout = 1 * time.Minute
CephClusterAuthenticationGoneTimeout is the default budget for WaitForCephClusterAuthenticationGone. The CR has no heavy finalizer.
const CephClusterConnectionGoneTimeout = 1 * time.Minute
CephClusterConnectionGoneTimeout is the default budget for WaitForCephClusterConnectionGone. The CR has no heavy finalizer.
const CephClusterGoneTimeout = 10 * time.Minute
CephClusterGoneTimeout is the default budget for WaitForCephClusterGone. Rook needs to drain mon/mgr/osd pods, remove the CRUSH map, and unset finalizers — easily 5+ minutes on a single-OSD cluster, longer on degraded ones.
const CephFilesystemGoneTimeout = 5 * time.Minute
CephFilesystemGoneTimeout is the default budget for WaitForCephFilesystemGone. MDS shutdown + pool removal usually settles in 1-2 minutes; we allow more to absorb operator restarts and slow Ceph mons.
const CephStorageClassGoneTimeout = 1 * time.Minute
CephStorageClassGoneTimeout is the default budget for WaitForCephStorageClassGone. CephStorageClass has no heavyweight finalizer (csi-ceph just deletes the backing k8s StorageClass), so this typically completes in seconds.
const DefaultDistrolessSessionTTL = 30 * time.Minute
DefaultDistrolessSessionTTL is the lifetime of the `sleep` process inside the injected ephemeral container when used as a long-lived reader session (OpenDistrolessReader / DistrolessReader.ReadFile). 30 minutes comfortably outlasts any single test cell while still guaranteeing eventual self-cleanup if the caller crashes.
const DefaultEphemeralStartupTimeout = 60 * time.Second
DefaultEphemeralStartupTimeout caps the wait for the injected ephemeral container to transition into Running. Image pull from a warm registry usually takes a couple of seconds; 60 s is a generous upper bound that still surfaces ImagePullBackOff/ErrImagePull early.
const PollGetTimeout = 30 * time.Second
PollGetTimeout caps a single Get call inside readiness pollers. Without this cap a hung TCP connect (e.g. SSH tunnel that died after a Wi-Fi flap on the developer's laptop) eats the entire parent timeout silently — the poller appears to "hang" until the per-resource ReadyTimeout fires 15-20 minutes later. With a 30s cap each Get fails fast, so we surface the network problem early via the WARN log emitted by pollResourceUntilReady.
const PollGoneProgressEvery = 30 * time.Second
PollGoneProgressEvery controls how often pollResourceUntilGone emits a progress INFO line while the resource is still alive. We don't want a log per tick (chatty) but we also don't want long stretches of silence when a finalizer is stuck for minutes — every ~30s strikes a balance.
const PollTickInterval = 5 * time.Second
PollTickInterval is the default tick interval between Get attempts when waiting for a Kubernetes resource to reach a ready state.
const RookConfigOverrideName = "rook-config-override"
RookConfigOverrideName is the well-known ConfigMap name Rook reads Ceph config overrides from (see Rook docs: "Advanced Configuration – Custom ceph.conf Settings"). Rook watches this ConfigMap in its operator namespace and injects the `config` key into `/etc/ceph/ceph.conf` of every Ceph daemon.
Variables ¶
var ( CephClusterConnectionGVR = schema.GroupVersionResource{ Group: "storage.deckhouse.io", Version: "v1alpha1", Resource: "cephclusterconnections", } CephClusterAuthenticationGVR = schema.GroupVersionResource{ Group: "storage.deckhouse.io", Version: "v1alpha1", Resource: "cephclusterauthentications", } )
GVRs of the csi-ceph cluster-scoped CRs. We use unstructured to avoid pulling github.com/deckhouse/csi-ceph/api into go.mod just for these tiny types.
var CephBlockPoolGVR = schema.GroupVersionResource{
Group: "ceph.rook.io",
Version: "v1",
Resource: "cephblockpools",
}
CephBlockPoolGVR is the GroupVersionResource of Rook's CephBlockPool.
var CephClusterGVR = schema.GroupVersionResource{
Group: "ceph.rook.io",
Version: "v1",
Resource: "cephclusters",
}
CephClusterGVR is the GroupVersionResource of Rook's CephCluster.
var CephFilesystemGVR = schema.GroupVersionResource{
Group: "ceph.rook.io",
Version: "v1",
Resource: "cephfilesystems",
}
CephFilesystemGVR is the GroupVersionResource of Rook's CephFilesystem.
var CephStorageClassGVR = schema.GroupVersionResource{
Group: "storage.deckhouse.io",
Version: "v1alpha1",
Resource: "cephstorageclasses",
}
CephStorageClassGVR points at csi-ceph's CephStorageClass CR (not to be confused with Rook's CephCluster / CephBlockPool).
var LocalStorageClassGVR = schema.GroupVersionResource{
Group: "storage.deckhouse.io",
Version: "v1alpha1",
Resource: "localstorageclasses",
}
var VolumeSnapshotClassGVR = schema.GroupVersionResource{
Group: "snapshot.storage.k8s.io",
Version: "v1",
Resource: "volumesnapshotclasses",
}
Functions ¶
func CephFSDataPoolFullName ¶
CephFSDataPoolFullName returns the full Ceph pool name that ends up referenced from CephStorageClass.spec.cephFS.pool. Rook composes the per-filesystem pool name as "<filesystem>-<dataPool.name>".
func CreateCephBlockPool ¶
func CreateCephBlockPool(ctx context.Context, kubeconfig *rest.Config, cfg CephBlockPoolConfig) error
CreateCephBlockPool creates (or updates, if already present) a CephBlockPool in the given namespace from the provided configuration. It is idempotent and safe to call on every test run.
func CreateCephCluster ¶
CreateCephCluster creates (or updates) a CephCluster in the given namespace. It is idempotent: if the resource already exists, its spec is overwritten with the freshly-rendered one so callers can tweak `CephClusterConfig` and re-apply without manual cleanup.
func CreateCephClusterAuthentication ¶
func CreateCephClusterAuthentication(ctx context.Context, kubeconfig *rest.Config, cfg CephClusterAuthenticationConfig) error
CreateCephClusterAuthentication creates (or updates) a CephClusterAuthentication CR with the given CephX credentials.
func CreateCephClusterConnection ¶
func CreateCephClusterConnection(ctx context.Context, kubeconfig *rest.Config, cfg CephClusterConnectionConfig) error
CreateCephClusterConnection creates (or updates) a CephClusterConnection CR. If the resource already exists we do *not* attempt to update spec.clusterID (which the CRD marks immutable) — only Monitors/UserID/UserKey are synced.
func CreateCephFilesystem ¶
func CreateCephFilesystem(ctx context.Context, kubeconfig *rest.Config, cfg CephFilesystemConfig) error
CreateCephFilesystem creates (or updates, if already present) a CephFilesystem in the given namespace from the provided configuration. It is idempotent and safe to call on every test run.
func CreateCephStorageClass ¶
func CreateCephStorageClass(ctx context.Context, kubeconfig *rest.Config, cfg CephStorageClassConfig) error
CreateCephStorageClass creates (or updates) a CephStorageClass CR. On success the csi-ceph controller provisions a corresponding core storage.k8s.io/v1 StorageClass in the cluster.
func CreateLVMVolumeGroup ¶
func CreateLVMVolumeGroup(ctx context.Context, kubeconfig *rest.Config, name, nodeName string, blockDeviceNames []string, actualVGName string) error
CreateLVMVolumeGroup creates an LVMVolumeGroup resource for a specific node
func CreateLVMVolumeGroupWithThinPool ¶
func CreateLVMVolumeGroupWithThinPool(ctx context.Context, kubeconfig *rest.Config, name, nodeName string, blockDeviceNames []string, actualVGName string, thinPools []ThinPoolSpec) error
CreateLVMVolumeGroupWithThinPool creates an LVMVolumeGroup resource with thin pools for a specific node
func CreateLocalStorageClass ¶
func CreateNamespaceIfNotExists ¶
func CreateNamespaceIfNotExists(ctx context.Context, config *rest.Config, name string) (*corev1.Namespace, error)
CreateNamespaceIfNotExists creates a namespace if it doesn't exist, or returns the existing one.
func CreateStaticNodeGroup ¶
CreateStaticNodeGroup creates a NodeGroup resource with Static nodeType
func CreateStorageClass ¶
func CreateStorageClass(ctx context.Context, kubeconfig *rest.Config, cfg StorageClassCreateConfig) error
CreateStorageClass creates a StorageClass from cfg, or no-ops if it already exists.
func DeleteCephBlockPool ¶
func DeleteCephBlockPool(ctx context.Context, kubeconfig *rest.Config, namespace, name string) error
DeleteCephBlockPool deletes a CephBlockPool. Safe to call if the pool does not exist. NOTE: this is fire-and-forget — the API call returns as soon as the apiserver accepts the request, but Rook may still be running its finalizer (`cephblockpool.ceph.rook.io`) for a few minutes afterwards. If you want to be certain the CR is fully gone before continuing, follow up with WaitForCephBlockPoolGone.
func DeleteCephCluster ¶
DeleteCephCluster removes a CephCluster. Tearing down the cluster this way is a *destructive* operation — Rook will leave OSD data on host disks under `dataDirHostPath` and operator-managed PVCs will not be garbage-collected automatically. The operation is still idempotent: a NotFound error is swallowed.
NOTE: this is fire-and-forget. The apiserver returns success as soon as it records the delete intent; Rook then runs its `cephcluster.ceph.rook.io` finalizer for several minutes, removing pools, mon/mgr/osd pods, and so on. If any dependent CR (CephBlockPool, CephFilesystem, ...) is still alive, Rook records `DeletionIsBlocked / ObjectHasDependents` and the CR stays in `phase=Deleting` indefinitely. Always tear down dependents first (and call WaitForCephBlockPoolGone / WaitForCephFilesystemGone on them) before invoking DeleteCephCluster, then follow up with WaitForCephClusterGone.
func DeleteCephClusterAuthentication ¶
func DeleteCephClusterAuthentication(ctx context.Context, kubeconfig *rest.Config, name string) error
DeleteCephClusterAuthentication removes a CephClusterAuthentication. NotFound is treated as success. Pair with WaitForCephClusterAuthenticationGone when teardown order matters.
func DeleteCephClusterConnection ¶
DeleteCephClusterConnection removes a CephClusterConnection. NotFound is treated as success. Pair with WaitForCephClusterConnectionGone when teardown order matters.
func DeleteCephFilesystem ¶
func DeleteCephFilesystem(ctx context.Context, kubeconfig *rest.Config, namespace, name string) error
DeleteCephFilesystem deletes a CephFilesystem. Safe to call if the filesystem does not exist. NOTE: fire-and-forget — Rook's `cephfilesystem.ceph.rook.io` finalizer takes time to detach the MDS daemons and remove the metadata/data pools. Pair with WaitForCephFilesystemGone if you need to know the CR has actually been GC'd before doing something else (e.g. deleting the parent CephCluster).
func DeleteCephStorageClass ¶
DeleteCephStorageClass removes a CephStorageClass. NotFound is treated as success. The underlying k8s StorageClass is removed by the csi-ceph controller as a side effect. Use WaitForCephStorageClassGone to confirm the CR is fully GC'd.
func DeleteLVMVolumeGroup ¶
DeleteLVMVolumeGroup deletes an LVMVolumeGroup resource by name
func DeleteRookConfigOverride ¶
DeleteRookConfigOverride removes the `rook-config-override` ConfigMap. It is safe to call when the ConfigMap does not exist.
func DetachAndDeleteVirtualDisk ¶
func DetachAndDeleteVirtualDisk(ctx context.Context, kubeconfig *rest.Config, namespace, attachmentName, diskName string) error
DetachAndDeleteVirtualDisk deletes the VirtualMachineBlockDeviceAttachment and then the VirtualDisk. Use this for cleanup after a test. Errors are logged but not returned for "not found" (idempotent).
func EnableAndConfigureModules ¶
func EnableAndConfigureModules(ctx context.Context, kubeconfig *rest.Config, clusterDef *config.ClusterDefinition, sshClient ssh.SSHClient) error
EnableAndConfigureModules enables and configures modules based on cluster definition It builds a dependency graph and processes modules level by level using topological sort After configuring each level, it waits for all modules in that level to become Ready before proceeding to the next level
func EnableModulesAndWait ¶
func EnableModulesAndWait(ctx context.Context, kubeconfig *rest.Config, sshClient ssh.SSHClient, clusterDef *config.ClusterDefinition, modules []ModuleSpec, timeout time.Duration) error
EnableModulesAndWait is a convenience function that enables modules and waits for them to become ready in one call.
Parameters:
- ctx: context for cancellation
- kubeconfig: kubernetes client config
- sshClient: SSH client for cluster access
- clusterDef: cluster definition (can be nil for existing clusters)
- modules: list of module specifications to enable
- timeout: maximum time to wait for all modules to become ready
func EnableModulesWithSpecs ¶
func EnableModulesWithSpecs(ctx context.Context, kubeconfig *rest.Config, sshClient ssh.SSHClient, clusterDef *config.ClusterDefinition, modules []ModuleSpec) error
EnableModulesWithSpecs enables and configures the specified modules in the test cluster. It handles dependencies automatically through topological sort and waits for each level of modules to become Ready before proceeding to the next level.
func ExecInPod ¶
func ExecInPod( ctx context.Context, kubeconfig *rest.Config, namespace, pod, container string, cmd []string, ) (stdout, stderr string, err error)
ExecInPod runs cmd inside container of pod namespace/pod via the apiserver's pods/exec subresource and returns stdout and stderr separately, plus any transport- or exec-level error.
The container must ship every binary referenced by cmd; ExecInPod does NOT inject any helper. For distroless containers without cat / sh, see ReadFileFromDistrolessPod.
func FindSecretByName ¶
func FindSecretByName(ctx context.Context, kubeconfig *rest.Config, namespace, name string) (string, error)
FindSecretByName finds a secret by name, trying multiple matching strategies This helps with issues where secret names might have hidden Unicode characters 1. Exact match 2. Case-insensitive match 3. Fuzzy match (ignoring common Unicode issues like non-breaking spaces) Returns the actual secret name found (which may differ from the requested name due to Unicode issues)
func FindUnsetEnvVars ¶
FindUnsetEnvVars finds all ${VAR} patterns in content and returns those that are not set
func GetDefaultStorageClassName ¶
GetDefaultStorageClassName returns the name of the current default StorageClass (annotated with storageclass.kubernetes.io/is-default-class=true), or "" if none exists.
func GetNodeTaints ¶
func GetNodeTaints(ctx context.Context, kubeconfig *rest.Config, nodeName string) ([]corev1.Taint, error)
GetNodeTaints returns the taints of the named node.
func GetSecretDataValue ¶
func GetSecretDataValue(ctx context.Context, kubeconfig *rest.Config, namespace, name, key string) (string, error)
GetSecretDataValue retrieves a specific data value from a secret by name It uses FindSecretByName to handle potential Unicode character issues
func GetStorageClass ¶
func GetStorageClass(ctx context.Context, kubeconfig *rest.Config, name string) (*storagev1.StorageClass, error)
GetStorageClass returns the StorageClass with the given name, or (nil, nil) if it does not exist.
func GetVMIPFromBaseCluster ¶
func GetVMIPFromBaseCluster(ctx context.Context, baseKubeconfig *rest.Config, namespace, vmName string) (string, error)
GetVMIPFromBaseCluster returns the IP address of a VirtualMachine in the base cluster (namespace). Used to SSH to the VM (e.g. cloud@ip) from the jump host to run lsblk on nested nodes.
func GetVMPodNodeAndContainerID ¶
func GetVMPodNodeAndContainerID(ctx context.Context, baseConfig *rest.Config, namespace, vmName string) (nodeName, containerID string, err error)
GetVMPodNodeAndContainerID returns the base cluster node name and the first container ID for the Pod that runs the given VM (e.g. virt-launcher-<vmName>-*). Used to run nsenter into the VM container from the base cluster node.
func GetWorkerNodes ¶
GetWorkerNodes returns all worker nodes in the cluster. A worker node is any node that does NOT have the "node-role.kubernetes.io/control-plane" label.
func IsNodeCordoned ¶
IsNodeCordoned checks whether a node has NoSchedule or NoExecute taints that would prevent DaemonSet pods from scheduling.
func LabelNodes ¶
func LabelNodes(ctx context.Context, kubeconfig *rest.Config, nodeNames []string, labelKey, labelValue string) error
LabelNodes adds a label to each of the specified nodes. If a node already has the label with the desired value, it is skipped. Uses retry with re-fetch to handle optimistic concurrency conflicts.
func ListVirtualMachineNames ¶
func ListVirtualMachineNames(ctx context.Context, kubeconfig *rest.Config, namespace string) ([]string, error)
ListVirtualMachineNames returns names of VirtualMachines in the given namespace. Used to pick a VM when attaching a VirtualDisk (e.g. in alwaysUseExisting mode).
func NewClientsetWithRetry ¶
NewClientsetWithRetry creates a new Kubernetes clientset with retry logic for transient network errors. While kubernetes.NewForConfig itself does not make network calls, this wrapper provides a centralized factory with retry that validates the connection by performing a lightweight server version check. This ensures the cluster is reachable before returning the clientset.
func NewDynamicClientWithRetry ¶
NewDynamicClientWithRetry creates a new Kubernetes dynamic client with retry logic for transient network errors. Similar to NewClientsetWithRetry, this provides a centralized factory for dynamic clients with built-in retry.
func NewVirtualizationClient ¶
func ReadFileFromDistrolessPod ¶
func ReadFileFromDistrolessPod( ctx context.Context, kubeconfig *rest.Config, namespace, pod, targetContainer, path string, opts ReadFileOptions, ) (string, error)
ReadFileFromDistrolessPod reads `path` from inside `targetContainer` of pod `namespace/pod` even when targetContainer ships no shell, no cat and no tar — i.e. a distroless or scratch image like csi-controller. It does so by injecting a short-lived ephemeral container (TargetContainerName=targetContainer, which gives it a shared PID namespace with the target) and then catting /proc/1/root<path>. /proc/1 is PID 1 inside the target container's PID namespace, and /proc/<pid>/root is the well-known kernel-exposed view of that process's filesystem root.
Why this does NOT restart the target pod or any of its containers:
- Ephemeral containers are added through the dedicated /pods/<name>/ephemeralcontainers subresource (UpdateEphemeralContainers in client-go). The apiserver explicitly allows this mutation on a running pod; the ordinary pod PUT/PATCH path that would trigger re-creation is bypassed entirely. Without this dedicated path, adding a container to a live pod would be flat-out forbidden.
- metadata.generation, spec.containers, the pod sandbox UID and the ReplicaSet/DaemonSet observation all stay intact. The kubelet simply launches the new container in the existing pod sandbox without disturbing existing containers. Workload-controller rollouts and pod-template `checksum/...` annotations are not affected, so e2e suites that subsequently assert on rollout state see a clean signal — the FS read does not contaminate it.
- Ephemeral containers are forbidden from declaring ports, probes, lifecycle hooks or resources, which guarantees the inject is a cheap no-op for the pod's lifecycle.
Caveat: ephemeral containers cannot be removed once added. The cat process exits with the container after `sleep`, but the entry remains in pod.spec.ephemeralContainers and pod.status.ephemeralContainerStatuses (state=Terminated). For long-running suites those entries simply pile up until the next pod recycle. Each invocation here generates a unique container name, so repeat calls against the same pod are safe.
For polling loops or any scenario that reads the same pod multiple times, prefer OpenDistrolessReader: each ReadFileFromDistrolessPod call pays the full ephemeral-container cold-start cost (~10–20 s for kubelet to launch a new container in the existing pod sandbox), and that cost dominates the runtime of a Eventually-style poll.
func ReadFileFromPod ¶
func ReadFileFromPod( ctx context.Context, kubeconfig *rest.Config, namespace, pod, container, path string, ) (string, error)
ReadFileFromPod cat's `path` from inside `container` of pod `namespace/pod`. Equivalent to `kubectl exec -c container -- cat path`, with stderr surfaced as part of the error if non-empty.
Requires the container image to ship cat. For distroless / scratch images, use ReadFileFromDistrolessPod.
func RenderCephGlobalConfig ¶
RenderCephGlobalConfig renders a `[global]` section for ceph.conf from the provided key/value pairs. Keys are sorted so the rendered output is stable across calls with logically-equivalent maps (avoids unnecessary CM updates).
func ResizeList ¶
func ResizeList(ctx context.Context, clientset *kubernetes.Clientset, namespace string, pvcNames []string, newSize string) error
ResizeList resizes multiple PVCs to a new size in parallel
func SetGlobalDefaultStorageClass ¶
func SetGlobalDefaultStorageClass(ctx context.Context, kubeconfig *rest.Config, storageClassName string) error
SetGlobalDefaultStorageClass updates the "global" ModuleConfig to set spec.settings.storageClass to the given name, making it the cluster default.
func SetRookConfigOverride ¶
func SetRookConfigOverride(ctx context.Context, kubeconfig *rest.Config, namespace string, globals map[string]string) error
SetRookConfigOverride creates or updates the `rook-config-override` ConfigMap in the given Rook operator namespace so that Ceph daemons pick up the provided global settings.
The ConfigMap format expected by Rook is:
apiVersion: v1
kind: ConfigMap
metadata:
name: rook-config-override
namespace: <rook-namespace>
data:
config: |
[global]
key1 = value1
key2 = value2
`globals` is rendered under `[global]`. Keys are sorted for a stable output. Passing an empty/nil `globals` map produces an empty `[global]` section, which effectively clears previously-set overrides.
func WaitForAllPodsReadyInNamespace ¶
func WaitForAllPodsReadyInNamespace(ctx context.Context, kubeconfig *rest.Config, namespace string, timeout time.Duration) error
WaitForAllPodsReadyInNamespace waits for all pods in a namespace to be in Ready condition
func WaitForCephBlockPoolGone ¶
func WaitForCephBlockPoolGone(ctx context.Context, kubeconfig *rest.Config, namespace, name string, timeout time.Duration) error
WaitForCephBlockPoolGone polls until the CephBlockPool is fully GC'd by Kubernetes (GET returns NotFound). Use this after DeleteCephBlockPool to be sure the parent CephCluster won't be blocked by `ObjectHasDependents` when it gets deleted next.
func WaitForCephBlockPoolReady ¶
func WaitForCephBlockPoolReady(ctx context.Context, kubeconfig *rest.Config, namespace, name string, timeout time.Duration) error
WaitForCephBlockPoolReady blocks until the CephBlockPool reports `status.phase == "Ready"`. Rook transitions the pool from Progressing to Ready once the Ceph OSDs have accepted the new pool and its CRUSH rule.
Per-call deadlines and loud (WARN) logging on consecutive network failures are inherited from pollResourceUntilReady, so a dropped SSH tunnel surfaces in seconds instead of after the parent timeout.
func WaitForCephClusterAuthenticationGone ¶
func WaitForCephClusterAuthenticationGone(ctx context.Context, kubeconfig *rest.Config, name string, timeout time.Duration) error
WaitForCephClusterAuthenticationGone polls until the CephClusterAuthentication is fully GC'd by Kubernetes (GET returns NotFound).
func WaitForCephClusterConnectionCreated ¶
func WaitForCephClusterConnectionCreated(ctx context.Context, kubeconfig *rest.Config, name string, timeout time.Duration) error
WaitForCephClusterConnectionCreated polls until the CephClusterConnection status reports phase=Created. csi-ceph's controller flips the status from Pending to Created once it has verified the supplied fsid / monitors / CephX credentials against the real Ceph cluster.
func WaitForCephClusterConnectionGone ¶
func WaitForCephClusterConnectionGone(ctx context.Context, kubeconfig *rest.Config, name string, timeout time.Duration) error
WaitForCephClusterConnectionGone polls until the CephClusterConnection is fully GC'd by Kubernetes (GET returns NotFound).
func WaitForCephClusterGone ¶
func WaitForCephClusterGone(ctx context.Context, kubeconfig *rest.Config, namespace, name string, timeout time.Duration) error
WaitForCephClusterGone polls until the CephCluster is fully GC'd by Kubernetes (GET returns NotFound). The poller logs the deletionTimestamp/finalizers progress periodically so a stuck finalizer (typical e2e failure: orphan dependent CR, broken Ceph health) is immediately visible in the test log instead of being hidden behind a silent timeout.
func WaitForCephClusterReady ¶
func WaitForCephClusterReady(ctx context.Context, kubeconfig *rest.Config, namespace, name string, timeout time.Duration) error
WaitForCephClusterReady blocks until the CephCluster status reports that Ceph is up and healthy. Rook exposes the cluster state through two status fields:
- `status.state` — overall lifecycle phase ("Creating", "Created", "Updating", "Error");
- `status.ceph.health` — the Ceph health summary ("HEALTH_OK", "HEALTH_WARN", "HEALTH_ERR"). On a single-OSD test cluster Ceph often sits in HEALTH_WARN (PGs undersized, no replicas), which we still treat as "good enough" as long as `status.state == "Created"`.
We return success once `state == "Created"`. HEALTH_ERR is reported in the log and does not short-circuit (Rook may recover).
Network errors are logged loud (WARN) after a few consecutive failures so a dropped SSH tunnel surfaces in seconds instead of getting buried in Debug output. See pollResourceUntilReady for the per-call deadline rationale.
func WaitForCephFilesystemGone ¶
func WaitForCephFilesystemGone(ctx context.Context, kubeconfig *rest.Config, namespace, name string, timeout time.Duration) error
WaitForCephFilesystemGone polls until the CephFilesystem is fully GC'd by Kubernetes (GET returns NotFound). Use this after DeleteCephFilesystem to be sure the parent CephCluster's deletion won't be blocked by `ObjectHasDependents`.
func WaitForCephFilesystemReady ¶
func WaitForCephFilesystemReady(ctx context.Context, kubeconfig *rest.Config, namespace, name string, timeout time.Duration) error
WaitForCephFilesystemReady blocks until the CephFilesystem reports `status.phase == "Ready"`. As a fallback (some Rook revisions populate `status.conditions` first) the function also accepts a Ready=True condition.
Per-call deadlines and loud (WARN) logging on consecutive network failures are inherited from pollResourceUntilReady.
func WaitForCephStorageClassCreated ¶
func WaitForCephStorageClassCreated(ctx context.Context, kubeconfig *rest.Config, name string, timeout time.Duration) error
WaitForCephStorageClassCreated polls until the CephStorageClass status reports phase=Created (the csi-ceph controller flips this once the backing k8s StorageClass has been provisioned).
func WaitForCephStorageClassGone ¶
func WaitForCephStorageClassGone(ctx context.Context, kubeconfig *rest.Config, name string, timeout time.Duration) error
WaitForCephStorageClassGone polls until the CephStorageClass is fully GC'd by Kubernetes (GET returns NotFound).
func WaitForLVMVolumeGroupDeletion ¶
func WaitForLVMVolumeGroupDeletion(ctx context.Context, kubeconfig *rest.Config, name string, timeout time.Duration) error
WaitForLVMVolumeGroupDeletion waits for an LVMVolumeGroup to be deleted
func WaitForLVMVolumeGroupReady ¶
func WaitForLVMVolumeGroupReady(ctx context.Context, kubeconfig *rest.Config, name string, timeout time.Duration) error
WaitForLVMVolumeGroupReady waits for an LVMVolumeGroup to become Ready
func WaitForLocalStorageClassCreated ¶
func WaitForLocalStorageClassCreated(ctx context.Context, kubeconfig *rest.Config, name string, timeout time.Duration) error
WaitForLocalStorageClassCreated waits for the LocalStorageClass CR status to indicate that the controller has created the corresponding StorageClass.
func WaitForModuleReady ¶
func WaitForModuleReady(ctx context.Context, kubeconfig *rest.Config, moduleName string, timeout time.Duration) error
WaitForModuleReady waits for a module to reach the Ready phase It continues waiting even if the module is temporarily in Error phase, as modules can recover. Only fails if the timeout is exceeded and the module is still not Ready.
func WaitForModulesReady ¶
func WaitForModulesReady(ctx context.Context, kubeconfig *rest.Config, clusterDef *config.ClusterDefinition, timeout time.Duration) error
WaitForModulesReady waits for all modules specified in cluster definition to be ready It builds a dependency graph and waits for modules level by level using topological sort
func WaitForModulesReadyWithSpecs ¶
func WaitForModulesReadyWithSpecs(ctx context.Context, kubeconfig *rest.Config, clusterDef *config.ClusterDefinition, modules []ModuleSpec, timeout time.Duration) error
WaitForModulesReadyWithSpecs waits for the specified modules to become ready. This is typically called after EnableModulesWithSpecs to ensure all modules are operational.
Parameters:
- ctx: context for cancellation
- kubeconfig: kubernetes client config
- clusterDef: cluster definition (can be nil for existing clusters)
- modules: list of module specifications to wait for
- timeout: maximum time to wait for all modules
func WaitForNodesLabeled ¶
func WaitForNodesLabeled(ctx context.Context, kubeconfig *rest.Config, nodeNames []string, labelKey, labelValue string) error
WaitForNodesLabeled waits for all specified nodes to have the given label with the expected value. It polls each node in parallel every 10 seconds until all nodes have the label or the context times out. Parameters:
- ctx: context with timeout/cancellation
- kubeconfig: Kubernetes REST config
- nodeNames: list of node names to check
- labelKey: the label key to look for (e.g., "storage.deckhouse.io/node-ready-for-iscsi")
- labelValue: the expected label value (e.g., "true")
func WaitForPVCsBound ¶
func WaitForPVCsBound(ctx context.Context, clientset *kubernetes.Clientset, namespace, labelSelector string, expectedCount int, maxAttempts int, interval time.Duration) error
WaitForPVCsBound waits for PVCs matching the label selector to be in Bound state
func WaitForPVCsResized ¶
func WaitForPVCsResized(ctx context.Context, clientset *kubernetes.Clientset, namespace string, pvcNames []string, targetSize string, maxAttempts int, interval time.Duration) error
WaitForPVCsResized waits for PVCs to be resized to the target size
func WaitForPodsStatus ¶
func WaitForPodsStatus(ctx context.Context, clientset *kubernetes.Clientset, namespace, labelSelector, status string, expectedCount int, maxAttempts int, interval time.Duration) error
WaitForPodsStatus waits for pods to reach a specific status
func WaitForStorageClass ¶
func WaitForStorageClass(ctx context.Context, kubeconfig *rest.Config, storageClassName string, timeout time.Duration) error
WaitForStorageClass waits for a storage class to become available
func WaitForStorageClasses ¶
func WaitForStorageClasses(ctx context.Context, kubeconfig *rest.Config, storageClassNames []string, timeout time.Duration) map[string]error
WaitForStorageClasses waits for multiple storage classes to become available in parallel Returns map of storage class names to errors (nil if successful, error if failed/not found)
func WaitForVirtualDiskAttached ¶
func WaitForVirtualDiskAttached(ctx context.Context, kubeconfig *rest.Config, namespace, attachmentName string, pollInterval time.Duration) error
WaitForVirtualDiskAttached waits for the VirtualMachineBlockDeviceAttachment to reach the Attached phase. It polls the attachment status until it's attached or the context is cancelled/times out. The pollInterval parameter specifies how often to check the status (recommended: 10 seconds).
Types ¶
type ApplyClient ¶
type ApplyClient struct {
// contains filtered or unexported fields
}
ApplyClient handles applying YAML manifests to a Kubernetes cluster
func NewApplyClient ¶
func NewApplyClient(config *rest.Config) (*ApplyClient, error)
NewApplyClient creates a new ApplyClient Includes retry logic for transient network errors during client creation
func (*ApplyClient) ApplyYAML ¶
ApplyYAML applies YAML manifest(s) to the cluster The yamlContent can contain multiple YAML documents separated by "---" namespace parameter is optional - if empty, uses namespace from manifest or "default"
func (*ApplyClient) CreateYAML ¶
CreateYAML creates resources from YAML manifest(s) Unlike ApplyYAML, this will fail if resources already exist
func (*ApplyClient) CreateYAMLFromFileWithEnvvars ¶
func (c *ApplyClient) CreateYAMLFromFileWithEnvvars(ctx context.Context, filePath string, namespace string) error
CreateYAMLFromFileWithEnvvars reads a YAML file, validates environment variables, substitutes them, and creates resources Returns error if file cannot be read, any ${VAR} is not set, or resource creation fails
type BlockDevice ¶
type BlockDevice = storage.BlockDeviceInfo
BlockDevice represents a block device in the cluster (re-export for public API)
func GetConsumableBlockDevices ¶
GetConsumableBlockDevices returns all consumable BlockDevices from the cluster
func GetConsumableBlockDevicesByNode ¶
func GetConsumableBlockDevicesByNode(ctx context.Context, kubeconfig *rest.Config, nodeName string) ([]BlockDevice, error)
GetConsumableBlockDevicesByNode returns consumable BlockDevices for a specific node.
type CephBlockPoolConfig ¶
type CephBlockPoolConfig struct {
// Name of the CephBlockPool CR (also becomes the Ceph pool name).
Name string
// Namespace the Rook operator watches (typically "d8-sds-elastic").
Namespace string
// FailureDomain is the CRUSH failure domain: "host" or "osd" (default: "host").
FailureDomain string
// ReplicaSize is the number of object copies. Default: 1.
ReplicaSize int
// RequireSafeReplicaSize toggles Ceph's safeguard against single-replica
// pools. When nil, it is set to `false` for ReplicaSize==1 (unsafe single
// replica, accepted for e2e test clusters) and left unset otherwise.
RequireSafeReplicaSize *bool
// ErasureCoded, when non-nil, produces an EC pool instead of a replicated
// one. Its fields map to `spec.erasureCoded.{dataChunks,codingChunks}`.
ErasureCoded *CephBlockPoolErasureCoded
}
CephBlockPoolConfig describes a minimal replicated or erasure-coded Ceph RBD pool managed by Rook. Exactly one of ReplicaSize or ErasureCoded must be set; leaving both zero defaults to a single-replica pool suitable for single-node test clusters.
type CephBlockPoolErasureCoded ¶
CephBlockPoolErasureCoded configures a Ceph erasure-coded RBD pool.
type CephClusterAuthenticationConfig ¶
type CephClusterAuthenticationConfig struct {
// Name of the CephClusterAuthentication CR.
Name string
// UserID is the Ceph user (typically "admin").
UserID string
// UserKey is the CephX key of UserID.
UserKey string
}
CephClusterAuthenticationConfig describes CephX credentials that csi-ceph reuses for every StorageClass that references the authentication.
type CephClusterConfig ¶
type CephClusterConfig struct {
// Name of the CephCluster (default: "ceph-cluster").
Name string
// Namespace where Rook watches (default: "d8-sds-elastic").
Namespace string
// CephImage is the Ceph container image tag.
// Default: "quay.io/ceph/ceph:v18.2.7".
CephImage string
// AllowUnsupportedCephVersion flips spec.cephVersion.allowUnsupported.
// Default: true (e2e clusters are allowed to run any version Ceph ships).
AllowUnsupportedCephVersion *bool
// MonCount / MgrCount are the Rook mon/mgr replica counts. Defaults:
// 1 / 1, which is appropriate for single-node / tiny test clusters.
MonCount int
MgrCount int
// AllowMultipleMonPerNode allows multiple mons on the same node
// (required for single-node clusters). Default: true.
AllowMultipleMonPerNode *bool
// DataDirHostPath is where Rook persists mon/OSD data on each node.
// Default: "/var/lib/rook".
DataDirHostPath string
// NetworkProvider selects the Rook networking mode. Supported values:
// "" — default CNI pod network (suitable for in-cluster e2e);
// "host" — host networking (matches the Flant wiki production layout).
NetworkProvider string
// PublicNetworkCIDRs / ClusterNetworkCIDRs are the public/cluster CIDRs
// plumbed into `spec.network.addressRanges` when NetworkProvider is
// non-empty. They are ignored for the default (CNI) mode.
PublicNetworkCIDRs []string
ClusterNetworkCIDRs []string
// OSDStorageClass is the name of a k8s StorageClass able to hand out
// block-mode PVCs. Those PVCs are used by Rook's
// `storage.storageClassDeviceSets` to back OSDs.
OSDStorageClass string
// OSDCount is the number of OSDs to provision (default: 1).
OSDCount int
// OSDSize is the size of each OSD PVC (default: "10Gi").
OSDSize string
// OSDDeviceSetName is the `storageClassDeviceSets[].name` (default:
// "set1"). Changing it is useful mostly for debugging.
OSDDeviceSetName string
}
CephClusterConfig describes a Rook-managed Ceph cluster suitable for e2e testing. It is intentionally narrower than Rook's native CephCluster CRD: knobs that don't matter for our scenarios are hidden behind hard-coded defaults (mirroring the values from the internal Flant wiki instruction on deploying sds-elastic + Rook + Ceph on LVM).
type CephClusterConnectionConfig ¶
type CephClusterConnectionConfig struct {
// Name of the CephClusterConnection CR.
Name string
// ClusterID is the Ceph fsid. Immutable after creation.
ClusterID string
// Monitors is the list of `ip:port` monitor endpoints.
Monitors []string
// UserID is the Ceph user (typically "admin").
UserID string
// UserKey is the CephX key of UserID.
UserKey string
}
CephClusterConnectionConfig describes a csi-ceph CephClusterConnection CR. Its spec.clusterID (== Ceph fsid) is immutable once created.
type CephCredentials ¶
type CephCredentials struct {
// FSID is the Ceph cluster unique identifier.
FSID string
// AdminUser is the Ceph user name (typically "admin").
AdminUser string
// AdminKey is the CephX key for AdminUser.
AdminKey string
// Monitors is the list of monitor endpoints in "IP:PORT" form, sorted
// alphabetically to make the output stable across runs.
Monitors []string
}
CephCredentials holds the information a Ceph CSI client needs to connect to a cluster bootstrapped by Rook.
func WaitForCephCredentials ¶
func WaitForCephCredentials(ctx context.Context, kubeconfig *rest.Config, namespace string, timeout time.Duration) (*CephCredentials, error)
WaitForCephCredentials blocks until all pieces of information required to connect to the Rook-managed Ceph cluster are populated:
- Secret `rook-ceph-mon` exists and has `fsid`, `ceph-username`, `ceph-secret`.
- ConfigMap `rook-ceph-mon-endpoints` exists and has at least one reachable monitor.
The returned CephCredentials is suitable for wiring csi-ceph CRs (CephClusterConnection, CephClusterAuthentication).
type CephFilesystemConfig ¶
type CephFilesystemConfig struct {
// Name of the CephFilesystem CR.
Name string
// Namespace the Rook operator watches (typically "d8-sds-elastic").
Namespace string
// FailureDomain is the CRUSH failure domain: "host" or "osd"
// (default: "osd" when MetadataPoolReplicas == DataPoolReplicas == 1,
// "host" otherwise).
FailureDomain string
// MetadataPoolReplicas is the metadata pool replication factor. Default: 1.
MetadataPoolReplicas int
// DataPoolName is the (Rook-side) data pool name. The full Ceph pool
// name is "<Name>-<DataPoolName>" — see CephFSDataPoolFullName.
// Default: "data0".
DataPoolName string
// DataPoolReplicas is the data pool replication factor. Default: 1.
DataPoolReplicas int
// MetadataServerActiveCount is the number of active MDS daemons.
// Default: 1.
MetadataServerActiveCount int
// RequireSafeReplicaSize toggles Ceph's safeguard against single-replica
// pools. When nil, it is set to false for replicas==1 (unsafe single
// replica, accepted for e2e test clusters) and left unset otherwise.
RequireSafeReplicaSize *bool
}
CephFilesystemConfig describes a minimal Rook CephFilesystem with one metadata pool and exactly one data pool. Defaults are tuned for tiny single-node test clusters and mirror CephBlockPoolConfig conventions.
type CephStorageClassConfig ¶
type CephStorageClassConfig struct {
// Name of the CephStorageClass CR (becomes the k8s StorageClass name).
Name string
// ClusterConnectionName points at a CephClusterConnection CR.
ClusterConnectionName string
// ClusterAuthenticationName points at a CephClusterAuthentication CR.
ClusterAuthenticationName string
// ReclaimPolicy mirrors StorageClass.ReclaimPolicy ("Delete" / "Retain").
// Default: "Delete".
ReclaimPolicy string
// Type is "RBD" (default) or "CephFS".
Type string
// RBDPool is the Ceph pool name (e.g. "ceph-rbd-r1").
RBDPool string
// RBDDefaultFSType picks the filesystem mkfs on volume attach.
// Default: "ext4".
RBDDefaultFSType string
// --- CephFS options (Type == "CephFS") ---
CephFSName string // Name of the CephFilesystem.
CephFSPool string // Pool to use inside that filesystem.
}
CephStorageClassConfig is an intentionally narrow shape tailored for the e2e scenarios we care about today — an RBD StorageClass backed by a single block pool. CephFS variant is supported but requires FSName+FSPool to be set by the caller.
type DistrolessReader ¶
type DistrolessReader struct {
// contains filtered or unexported fields
}
DistrolessReader is a long-lived ephemeral-container reader session against a single distroless pod. Open one with OpenDistrolessReader, then call ReadFile as many times as you need — each ReadFile is just an exec into the already-running ephemeral container (cheap), so a polling loop pays the ephemeral-container cold start ONCE instead of per-iteration.
The session expires when the ephemeral container's `sleep` (opts.SessionTTL, default DefaultDistrolessSessionTTL) elapses; there is no Close — Kubernetes does not allow removing an ephemeral container — but the inert "Terminated" status entry has no effect on the pod. Callers that need fresh sessions across pod identities (e.g. after a workload rollout) should re-open against the new pod.
func OpenDistrolessReader ¶
func OpenDistrolessReader( ctx context.Context, kubeconfig *rest.Config, namespace, pod, targetContainer string, opts ReadFileOptions, ) (*DistrolessReader, error)
OpenDistrolessReader injects a long-lived ephemeral container into the target pod and waits for it to become Running. The returned DistrolessReader can then be used for arbitrarily many cheap ReadFile calls until opts.SessionTTL elapses (default 30 minutes).
Failure modes (returned as errors): pod not found, ephemeral container terminates before Running, image pull failure, startup timeout. On any of these no usable reader is returned.
See ReadFileFromDistrolessPod for the rationale on why this does not restart the target pod or any of its existing containers.
func (*DistrolessReader) EphemeralName ¶
func (r *DistrolessReader) EphemeralName() string
EphemeralName returns the auto-generated name of the injected ephemeral container, mostly for logging.
func (*DistrolessReader) PodName ¶
func (r *DistrolessReader) PodName() string
PodName returns the name of the pod this reader is bound to. Useful for callers that need to detect rollouts (the pod name changes when the workload-controller recycles the pod) and re-open the session.
type LocalStorageClassConfig ¶
type LocalStorageClassConfig struct {
Name string
LVMVolumeGroups []string // LVMVolumeGroup resource names
LVMType string // "Thick" or "Thin"
ThinPoolName string // required when LVMType is "Thin"
ReclaimPolicy string // "Delete" or "Retain" (default: "Delete")
VolumeBindingMode string // "WaitForFirstConsumer" or "Immediate" (default: "WaitForFirstConsumer")
}
type ModuleSpec ¶
type ModuleSpec struct {
// Name is the name of the module (e.g., "snapshot-controller", "csi-hpe")
Name string
// Version is the module config version (typically 1)
Version int
// Enabled indicates whether the module should be enabled
Enabled bool
// Settings contains module-specific settings
Settings map[string]interface{}
// Dependencies lists module names that must be enabled before this one
Dependencies []string
// ModulePullOverride overrides the module pull branch/tag (e.g., "main", "pr123")
// Only used for dev registries (registries starting with "dev-")
ModulePullOverride string
}
ModuleSpec defines a module to be enabled in the cluster. This is a simplified version of config.ModuleConfig that provides a clean API for test writers.
type ReadFileOptions ¶
type ReadFileOptions struct {
// DebugImage is the ephemeral container image (required). Use a minimal
// image that ships cat and sleep, e.g. busybox from your cluster registry.
DebugImage string
// StartupTimeout caps the wait for the ephemeral container to reach
// state.Running. Defaults to DefaultEphemeralStartupTimeout.
StartupTimeout time.Duration
// SessionTTL controls how long the injected ephemeral container's
// `sleep` process stays alive. Defaults to DefaultDistrolessSessionTTL.
// Used by OpenDistrolessReader; ReadFileFromDistrolessPod does not
// rely on this value (the entry's status flip after the cat exits
// has no effect on the pod).
SessionTTL time.Duration
}
ReadFileOptions tunes ReadFileFromDistrolessPod and OpenDistrolessReader.
type StorageClassCreateConfig ¶
type StorageClassCreateConfig struct {
Name string
Provisioner string
Parameters map[string]string
VolumeBindingMode storagev1.VolumeBindingMode
ReclaimPolicy corev1.PersistentVolumeReclaimPolicy
AllowExpansion bool
MakeDefault bool
AdditionalLabels map[string]string
AdditionalAnnot map[string]string
}
StorageClassCreateConfig describes a StorageClass to create via CreateStorageClass.
type TestClusterResourcesInterface ¶
type TestClusterResourcesInterface interface {
GetKubeconfig() *rest.Config
GetSSHClient() ssh.SSHClient
GetClusterDefinition() *config.ClusterDefinition
}
TestClusterResourcesInterface defines the interface for accessing test cluster resources This avoids circular imports with the cluster package
type ThinPoolSpec ¶
type ThinPoolSpec struct {
Name string // Thin pool name
Size string // Size of the thin pool (e.g., "50%" or "10Gi")
AllocationLimit string // Allocation limit (optional)
}
ThinPoolSpec represents a thin pool specification for LVMVolumeGroup
type VirtualDiskAttachmentConfig ¶
type VirtualDiskAttachmentConfig struct {
// VMName is the name of the VirtualMachine to attach the disk to
VMName string
// Namespace is the namespace where the VM and disk resources are located
Namespace string
// DiskName is the name for the new VirtualDisk (optional, auto-generated if empty)
DiskName string
// DiskSize is the size of the disk (e.g., "200Gi")
DiskSize string
// StorageClassName is the storage class to use for the disk
StorageClassName string
}
VirtualDiskAttachmentConfig holds configuration for attaching a virtual disk to a VM
type VirtualDiskAttachmentResult ¶
type VirtualDiskAttachmentResult struct {
// DiskName is the name of the created VirtualDisk
DiskName string
// AttachmentName is the name of the created VirtualMachineBlockDeviceAttachment
AttachmentName string
}
VirtualDiskAttachmentResult holds the result of attaching a virtual disk
func AttachVirtualDiskToVM ¶
func AttachVirtualDiskToVM(ctx context.Context, kubeconfig *rest.Config, config VirtualDiskAttachmentConfig) (*VirtualDiskAttachmentResult, error)
AttachVirtualDiskToVM creates a VirtualDisk and attaches it to the specified VM using VirtualMachineBlockDeviceAttachment. The disk is created as a blank disk with the specified size and storage class. Returns the names of created resources for later use (e.g., waiting for attachment or cleanup).
func ReattachVirtualDiskToVM ¶
func ReattachVirtualDiskToVM(ctx context.Context, kubeconfig *rest.Config, config VirtualDiskReattachmentConfig) (*VirtualDiskAttachmentResult, error)
ReattachVirtualDiskToVM attaches an existing VirtualDisk to the specified VM. It creates a VirtualMachineBlockDeviceAttachment using the provided disk and attachment names.
type VirtualDiskReattachmentConfig ¶
type VirtualDiskReattachmentConfig struct {
// AttachmentName is the name of the VirtualMachineBlockDeviceAttachment to create.
AttachmentName string
// VMName is the name of the VirtualMachine to attach the disk to.
VMName string
// Namespace is the namespace where the VM and disk resources are located.
Namespace string
// DiskName is the name of an existing VirtualDisk to attach.
DiskName string
}
VirtualDiskReattachmentConfig holds configuration for reattaching an existing virtual disk to a VM.
Source Files
¶
- apply.go
- blockdevice.go
- cephblockpool.go
- cephcluster.go
- cephclusterconnection.go
- cephcredentials.go
- cephfilesystem.go
- cephstorageclass.go
- client.go
- localstorageclass.go
- lvmvolumegroup.go
- modules.go
- namespace.go
- nodegroup.go
- nodes.go
- pod.go
- pod_exec.go
- poll.go
- pvc.go
- rookconfigoverride.go
- secrets.go
- storageclass.go
- virtclient.go
- virtualdisk.go
- vmpod.go
- volumesnapshotclass.go