Documentation
¶
Index ¶
- 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 CreateNamespaceIfNotExists(ctx context.Context, config *rest.Config, name string) (*corev1.Namespace, error)
- func CreateStaticNodeGroup(ctx context.Context, config *rest.Config, name string) error
- func DeleteLVMVolumeGroup(ctx context.Context, kubeconfig *rest.Config, name string) 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 FindSecretByName(ctx context.Context, kubeconfig *rest.Config, namespace, name string) (string, error)
- func FindUnsetEnvVars(content string) []string
- func GetSecretDataValue(ctx context.Context, kubeconfig *rest.Config, namespace, name, key 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 ResizeList(ctx context.Context, clientset *kubernetes.Clientset, namespace string, ...) error
- func WaitForAllPodsReadyInNamespace(ctx context.Context, kubeconfig *rest.Config, namespace 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 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 WaitForStorageClassDeletion(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
- 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 ModuleSpec
- type TestClusterResourcesInterface
- type ThinPoolSpec
- type VirtualDiskAttachmentConfig
- type VirtualDiskAttachmentResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 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 DeleteLVMVolumeGroup ¶
DeleteLVMVolumeGroup deletes an LVMVolumeGroup resource by name
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 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 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 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 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 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 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 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 WaitForStorageClassDeletion ¶
func WaitForStorageClassDeletion(ctx context.Context, kubeconfig *rest.Config, storageClassName string, timeout time.Duration) error
WaitForStorageClassDeletion waits for a storage class to be deleted
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
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 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).