cluster

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseClusterClient

type BaseClusterClient struct {
	// contains filtered or unexported fields
}

BaseClusterClient provides a base implementation of ClusterClient.

func NewBaseClusterClient

func NewBaseClusterClient() *BaseClusterClient

NewBaseClusterClient creates a new BaseClusterClient with default timeouts.

func (*BaseClusterClient) Close

func (c *BaseClusterClient) Close()

Close is a no-op in the base implementation. Provider-specific implementations should override this to close their connections.

func (*BaseClusterClient) WaitForNodesHealthy

func (c *BaseClusterClient) WaitForNodesHealthy(ctx context.Context, nodeAddresses []string, expectedVersion string) error

WaitForNodesHealthy implements the default polling behavior for node health and version checks

type ClusterClient

type ClusterClient interface {
	// WaitForNodesHealthy waits for nodes to be healthy and optionally match a specific version
	// Polls until all nodes are healthy (and correct version if specified) or timeout
	WaitForNodesHealthy(ctx context.Context, nodeAddresses []string, expectedVersion string) error

	// Close closes any open connections.
	Close()
}

ClusterClient defines the interface for cluster operations

type MockClusterClient

type MockClusterClient struct {
	BaseClusterClient
	WaitForNodesHealthyFunc func(ctx context.Context, nodeAddresses []string, expectedVersion string) error
	CloseFunc               func()
}

MockClusterClient is a mock implementation of the ClusterClient interface

func NewMockClusterClient

func NewMockClusterClient() *MockClusterClient

NewMockClusterClient is a constructor for MockClusterClient

func (*MockClusterClient) Close

func (m *MockClusterClient) Close()

Close calls the mock CloseFunc if set

func (*MockClusterClient) WaitForNodesHealthy

func (m *MockClusterClient) WaitForNodesHealthy(ctx context.Context, nodeAddresses []string, expectedVersion string) error

WaitForNodesHealthy calls the mock WaitForNodesHealthyFunc if set, otherwise returns nil

type Shims

type Shims struct {
	// Talos client operations
	TalosConfigOpen  func(configPath string) (*clientconfig.Config, error)
	TalosNewClient   func(ctx context.Context, opts ...client.OptionFunc) (*client.Client, error)
	TalosVersion     func(ctx context.Context, client *client.Client) (*machine.VersionResponse, error)
	TalosWithNodes   func(ctx context.Context, nodes ...string) context.Context
	TalosServiceList func(ctx context.Context, client *client.Client) (*machine.ServiceListResponse, error)
	TalosClose       func(client *client.Client)
}

Shims provides testable interfaces for external dependencies

func NewShims

func NewShims() *Shims

NewShims creates a new Shims instance with default implementations

type TalosClusterClient

type TalosClusterClient struct {
	*BaseClusterClient
	// contains filtered or unexported fields
}

TalosClusterClient implements ClusterClient for Talos clusters

func NewTalosClusterClient

func NewTalosClusterClient() *TalosClusterClient

NewTalosClusterClient creates a new TalosClusterClient instance with default configuration

func (*TalosClusterClient) Close

func (c *TalosClusterClient) Close()

Close releases resources held by the TalosClusterClient. It safely closes the underlying Talos gRPC client connection if one exists and sets the client reference to nil to prevent further use. This method is safe to call multiple times and handles the case where no client connection was established.

func (*TalosClusterClient) WaitForNodesHealthy

func (c *TalosClusterClient) WaitForNodesHealthy(ctx context.Context, nodeAddresses []string, expectedVersion string) error

WaitForNodesHealthy waits for nodes to be healthy and optionally match a specific version. It polls each node continuously, checking service health and version status until all nodes meet the criteria or timeout occurs. For each node, it validates that all critical services are running and healthy, and if expectedVersion is provided, verifies the node is running that specific version. The method provides detailed status output for each node during polling, showing healthy/unhealthy services and version information. Returns an error with specific details about which nodes failed health checks or version validation if timeout is reached.

Jump to

Keyboard shortcuts

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