helpers

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyRunningMasterMachine

func AnyRunningMasterMachine(ctx context.Context, t TestingT, machineClient machinev1beta1client.MachineInterface) (*machinev1beta1.Machine, error)

AnyRunningMasterMachine finds and returns a running master machine from the cluster.

func CreateNewMasterMachine

func CreateNewMasterMachine(ctx context.Context, t TestingT, machineClient machinev1beta1client.MachineInterface, templateMachine *machinev1beta1.Machine) (string, error)

CreateNewMasterMachine creates a new master node by cloning an existing Machine resource. If templateMachine is provided, it will be cloned. Otherwise a running machine will be picked for cloning.

func DeleteAllMasterMachines

func DeleteAllMasterMachines(ctx context.Context, t TestingT, machineClient machinev1beta1client.MachineInterface) ([]string, error)

DeleteAllMasterMachines deletes all master machines and returns the list of deleted machine names

func DeleteMachine

func DeleteMachine(ctx context.Context, t TestingT, machineClient machinev1beta1client.MachineInterface, machineToDelete string) error

DeleteMachine deletes the given machine and returns error if any issues occur during deletion

func DeleteSingleMachine

func DeleteSingleMachine(ctx context.Context, t TestingT, machineClient machinev1beta1client.MachineInterface) (string, error)

DeleteSingleMachine deletes the master machine with lowest index. Returns the deleted machine name and error if any issues occur during deletion

func DisableCPMS

DisableCPMS disables the CPMS by deleting the custom resource and verifies it. Returns error if there was one while disabling or verifying

func EnableCPMS

EnableCPMS activates the CPMS setting the .spec.state field to Active and verifies it. Returns error if there was one while activating or verifying

func EnsureCPMSReplicasConverged

func EnsureCPMSReplicasConverged(ctx context.Context, cpmsClient machinev1client.ControlPlaneMachineSetInterface) error

EnsureCPMSReplicasConverged returns error if the number of expected master machines not equals the number of actual master machines otherwise it returns nil

func EnsureHealthyMember

func EnsureHealthyMember(t TestingT, etcdClientFactory EtcdClientCreator, memberName string) error

func EnsureInitialClusterState

func EnsureInitialClusterState(ctx context.Context, t TestingT, etcdClientFactory EtcdClientCreator, machineClient machinev1beta1client.MachineInterface, kubeClient kubernetes.Interface) error

EnsureInitialClusterState makes sure the cluster state is expected, that is, has only 3 running machines and exactly 3 voting members otherwise it attempts to recover the cluster by removing any excessive machines

func EnsureMasterMachine

func EnsureMasterMachine(ctx context.Context, t TestingT, machineName string, machineClient machinev1beta1client.MachineInterface) error

func EnsureMasterMachinesAndCount

func EnsureMasterMachinesAndCount(ctx context.Context, t TestingT, machineClient machinev1beta1client.MachineInterface) error

EnsureMasterMachinesAndCount checks if there are only 3 running master machines otherwise it returns an error

func EnsureMemberRemoved

func EnsureMemberRemoved(t TestingT, etcdClientFactory EtcdClientCreator, memberName string) error

func EnsureReadyMasterNodes

func EnsureReadyMasterNodes(ctx context.Context, expectedReplicaCount int, nodeClient v1.NodeInterface) error

EnsureReadyMasterNodes checks if the current master nodes matches the expected number of master nodes, and that all master nodes' are Ready

func EnsureReadyReplicasOnCPMS

func EnsureReadyReplicasOnCPMS(ctx context.Context, t TestingT, expectedReplicaCount int, cpmsClient machinev1client.ControlPlaneMachineSetInterface, nodeClient v1.NodeInterface) error

EnsureReadyReplicasOnCPMS checks if status.readyReplicas on the cluster CPMS is n this effectively counts the number of control-plane machines with the provider state as running

func EnsureUpdatedReplicasOnCPMS

func EnsureUpdatedReplicasOnCPMS(ctx context.Context, t TestingT, expectedCount int, cpmsClient machinev1client.ControlPlaneMachineSetInterface) error

EnsureUpdatedReplicasOnCPMS checks if status.updatedReplicas on the cluster CPMS equals the expected count updatedReplicas represents machines with the desired spec that are ready

func EnsureVotingMembersCount

func EnsureVotingMembersCount(ctx context.Context, t TestingT, etcdClientFactory EtcdClientCreator, kubeClient kubernetes.Interface, expectedMembersCount int) error

EnsureVotingMembersCount counts the number of voting etcd members, it doesn't evaluate health conditions or any other attributes (i.e. name) of individual members this method won't fail immediately on errors, this is useful during scaling down operation until the feature can ensure this operation to be graceful

func EnsureVotingMembersExcluding

func EnsureVotingMembersExcluding(ctx context.Context, t TestingT, etcdClientFactory EtcdClientCreator, kubeClient kubernetes.Interface, excludedMemberNames []string, expectedCount int) error

EnsureVotingMembersExcluding waits for the cluster to have exactly expectedCount voting members, with none of the members in the excludedMemberNames list

func GetVotingMemberNames

func GetVotingMemberNames(ctx context.Context, t TestingT, etcdClientFactory EtcdClientCreator) ([]string, error)

GetVotingMemberNames returns the list of current voting etcd member names

func InitPlatformSpecificConfiguration

func InitPlatformSpecificConfiguration(oc *exutil.CLI) func()

func IsCPMSActive

IsCPMSActive returns true if the current platform's has an active CPMS Not all platforms are supported (as of 4.12 only AWS and Azure) See https://github.com/openshift/cluster-control-plane-machine-set-operator/tree/main/docs/user#supported-platforms

func MachineNameToEtcdMemberName

func MachineNameToEtcdMemberName(ctx context.Context, kubeClient kubernetes.Interface, machineClient machinev1beta1client.MachineInterface, machineName string) (string, error)

MachineNameToEtcdMemberName finds an etcd member name that corresponds to the given machine name first it looks up a node that corresponds to the machine by comparing the ProviderID field next, it returns the node name as it is used to name an etcd member.

In cases the ProviderID is empty it will try to find a node that matches an internal IP address

note: it will exit and report an error in case the node was not found

func SkipIfUnsupportedPlatform

func SkipIfUnsupportedPlatform(ctx context.Context, oc *exutil.CLI)

func UpdateCPMSStrategy

UpdateCPMSStrategy updates the CPMS strategy to the specified type (OnDelete, RollingUpdate, or Recreate)

func WaitOnExpectedVotingMembersCount

func WaitOnExpectedVotingMembersCount(ctx context.Context, t TestingT, etcdClientFactory EtcdClientCreator, kubeClient kubernetes.Interface, expectedMembersCount int) error

WaitOnExpectedVotingMembersCount waits for 2 minutes and ensures the etcd membership remains at the expected member count. Returns an error if there is a change in the expected voting members count

Types

type EtcdClientCreator

type EtcdClientCreator interface {
	NewEtcdClient() (*clientv3.Client, func(), error)
	NewEtcdClientForMember(memberName string) (*clientv3.Client, func(), error)
}

type EtcdClientFactoryImpl

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

func NewEtcdClientFactory

func NewEtcdClientFactory(kubeClient kubernetes.Interface) *EtcdClientFactoryImpl

func (*EtcdClientFactoryImpl) NewEtcdClient

func (e *EtcdClientFactoryImpl) NewEtcdClient() (*clientv3.Client, func(), error)

func (*EtcdClientFactoryImpl) NewEtcdClientForMember

func (e *EtcdClientFactoryImpl) NewEtcdClientForMember(memberName string) (*clientv3.Client, func(), error)

type TestingT

type TestingT interface {
	Logf(format string, args ...interface{})
}

Jump to

Keyboard shortcuts

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