ceohelpers

package
v0.0.0-alpha.0....-eeef803 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DelayedHABootstrapScalingStrategyAnnotation is an annotation on the openshift-etcd
	// namespace which, if present indicates the DelayedHAScalingStrategy strategy
	// should be used.
	DelayedHABootstrapScalingStrategyAnnotation = "openshift.io/delayed-ha-bootstrap"
)
View Source
const InfrastructureClusterName = "cluster"
View Source
const MachineDeletionHookName = "EtcdQuorumOperator"

MachineDeletionHookName holds a name of the Machine Deletion Hook

View Source
const MachineDeletionHookOwner = "clusteroperator/etcd"

MachineDeletionHookOwner holds an owner of the Machine Deletion Hook

Variables

This section is empty.

Functions

func CheckSafeToScaleCluster

func CheckSafeToScaleCluster(
	configmapLister corev1listers.ConfigMapLister,
	staticPodClient v1helpers.StaticPodOperatorClient,
	namespaceLister corev1listers.NamespaceLister,
	infraLister configv1listers.InfrastructureLister,
	etcdClient etcdcli.AllMemberLister) error

CheckSafeToScaleCluster is used to implement the bootstrap scaling strategy invariants. This function returns nil if cluster conditions are such that it's safe to scale the etcd cluster based on the scaling strategy in use, and otherwise will return an error explaining why it's unsafe to scale.

func CurrentMemberMachinesWithDeletionHooks

func CurrentMemberMachinesWithDeletionHooks(machineSelector labels.Selector, machineLister machinelistersv1beta1.MachineLister) ([]*machinev1beta1.Machine, error)

CurrentMemberMachinesWithDeletionHooks returns machines with the deletion hooks from the lister

func FilterMachinesPendingDeletion

func FilterMachinesPendingDeletion(machines []*machinev1beta1.Machine) []*machinev1beta1.Machine

FilterMachinesPendingDeletion a convenience function for filtering machines pending deletion

func FilterMachinesWithMachineDeletionHook

func FilterMachinesWithMachineDeletionHook(machines []*machinev1beta1.Machine) []*machinev1beta1.Machine

FilterMachinesWithMachineDeletionHook a convenience function for filtering only machines with the machine deletion hook present

func FilterMachinesWithoutMachineDeletionHook

func FilterMachinesWithoutMachineDeletionHook(machines []*machinev1beta1.Machine) []*machinev1beta1.Machine

FilterMachinesWithoutMachineDeletionHook a convenience function for filtering only machines without the machine deletion hook present

func FindMachineByNodeInternalIP

func FindMachineByNodeInternalIP(nodeInternalIP string, machineSelector labels.Selector, machineLister machinelistersv1beta1.MachineLister) (*machinev1beta1.Machine, error)

FindMachineByNodeInternalIP finds the machine that matches the given nodeInternalIP is safe because the MAO:

syncs the addresses in the Machine with those assigned to real nodes by the cloud provider,
checks that the Machine and Node lists match before issuing a serving certification for the kubelet
when the host disappears from the cloud side, it stops updating the Machine so the addresses and information
should persist there as a tombstone as the Machine is marked Failed

func GetControlPlaneTopology

func GetControlPlaneTopology(infraLister configv1listers.InfrastructureLister) (configv1.TopologyMode, error)

func HasMachineDeletionHook

func HasMachineDeletionHook(machine *machinev1beta1.Machine) bool

HasMachineDeletionHook simply checks if the given machine has the machine deletion hook present

func IndexMachinesByNodeInternalIP

func IndexMachinesByNodeInternalIP(machines []*machinev1beta1.Machine) map[string]*machinev1beta1.Machine

IndexMachinesByNodeInternalIP maps machines to IPs

Note that a machine can have multiple internal IPs with different types (v4/v6)

func IsBootstrapComplete

func IsBootstrapComplete(configMapClient corev1listers.ConfigMapLister, staticPodClient v1helpers.StaticPodOperatorClient, etcdClient etcdcli.AllMemberLister) (bool, error)

IsBootstrapComplete returns true if bootstrap has completed.

func IsSingleNodeTopology

func IsSingleNodeTopology(infraLister configv1listers.InfrastructureLister) (bool, error)

func MemberToNodeInternalIP

func MemberToNodeInternalIP(member *etcdserverpb.Member) (string, error)

MemberToNodeInternalIP extracts assigned IP address from the given member

func NewAlreadySyncedInformer

func NewAlreadySyncedInformer(informer cache.SharedInformer) cache.SharedInformer

func ReadDesiredControlPlaneReplicasCount

func ReadDesiredControlPlaneReplicasCount(operatorClient v1helpers.StaticPodOperatorClient) (int, error)

ReadDesiredControlPlaneReplicasCount reads the current Control Plane replica count

func VotingMemberIPListSet

func VotingMemberIPListSet(ctx context.Context, cli etcdcli.EtcdClient) (sets.String, error)

Types

type AlreadySyncedInformer

type AlreadySyncedInformer struct {
	cache.SharedInformer
}

AlreadySyncedInformer wraps an ordinary cache.SharedInformer, but allows us to fake HasSynced results. This is to allow controllers to proceed when an informer could not sync (eg when the API isn't available).

func (*AlreadySyncedInformer) HasSynced

func (s *AlreadySyncedInformer) HasSynced() bool

type AlwaysSafeQuorumChecker

type AlwaysSafeQuorumChecker struct {
}

AlwaysSafeQuorumChecker can be used for testing and always returns that it is safe to update a revision

func (*AlwaysSafeQuorumChecker) IsSafeToUpdateRevision

func (c *AlwaysSafeQuorumChecker) IsSafeToUpdateRevision() (bool, error)

IsSafeToUpdateRevision always returns true, nil

type BootstrapScalingStrategy

type BootstrapScalingStrategy string

BootstrapScalingStrategy describes the invariants which will be enforced when scaling the etcd cluster.

const (
	// HAScalingStrategy means the etcd cluster will only be scaled up when at least
	// 3 node are available so that HA is enforced at all times. This rule applies
	// during bootstrapping and the steady state.
	//
	// This is the default strategy.
	HAScalingStrategy BootstrapScalingStrategy = "HAScalingStrategy"

	// DelayedHAScalingStrategy means that during bootstrapping, the etcd cluster will
	// be allowed to scale when at least 2 members are available (which is not HA),
	// but after bootstrapping any further scaling will require 3 nodes in the same
	// way as HAScalingStrategy.
	//
	// This strategy is selected by adding the `openshift.io/delayed-ha-bootstrap`
	// annotation to the openshift-etcd namesapce.
	DelayedHAScalingStrategy BootstrapScalingStrategy = "DelayedHAScalingStrategy"

	// BootstrapInPlaceStrategy means that the bootstrap node will never exist
	// during the lifecycle of the cluster. Bootkube will run on a live iso
	// afterwards the node will pivot into the manifests generated during that
	// process.
	//
	// This strategy is selected by observing the existence of `bootstrapInPlace`
	// root key in the install-config.
	BootstrapInPlaceStrategy BootstrapScalingStrategy = "BootstrapInPlaceStrategy"

	// UnsafeScalingStrategy means scaling will occur without regards to nodes and
	// any effect on quorum. Use of this strategy isn't officially tested or supported,
	// but is made available for ad-hoc use.
	//
	// This strategy is selected by setting unsupportedConfigOverrides on the
	// operator config.
	UnsafeScalingStrategy BootstrapScalingStrategy = "UnsafeScalingStrategy"
)

func GetBootstrapScalingStrategy

func GetBootstrapScalingStrategy(staticPodClient v1helpers.StaticPodOperatorClient, namespaceLister corev1listers.NamespaceLister, infraLister configv1listers.InfrastructureLister) (BootstrapScalingStrategy, error)

GetBootstrapScalingStrategy determines the scaling strategy to use

type MachineAPI

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

MachineAPI a simple struct that helps determine if the Machine API is functional

Note:

since this type needs to take into account only master machine objects
make sure machineInformer contain only filtered data
otherwise it might be expensive to react to every node update in larger installations

as a safety net this type requires masterMachineSelector, just in case a caller won't provide a filtered informer

func NewMachineAPI

func NewMachineAPI(masterMachineInformer cache.SharedIndexInformer,
	masterMachineLister machinelistersv1beta1.MachineLister,
	masterMachineSelector labels.Selector,
	versionInformer configv1informers.ClusterVersionInformer,
	dynamicClient dynamic.Interface) *MachineAPI

func (*MachineAPI) IsAvailable

func (m *MachineAPI) IsAvailable() (bool, error)

IsAvailable checks if the Machine API is available as an API on the API server.

func (*MachineAPI) IsEnabled

func (m *MachineAPI) IsEnabled() (bool, error)

IsEnabled checks if the Machine API is enabled. As of today Machine API is enabled when: * clusterVersionInformer is synced * clusterVersion has "MachineAPI" as an enabled capability This method might not be reliable under some configuration, thus it's important to also check whether it IsAvailable

func (*MachineAPI) IsFunctional

func (m *MachineAPI) IsFunctional() (bool, error)

IsFunctional checks if the Machine API is (enabled OR available) AND functional. As of today Machine API is functional when: * clusterVersionInformer is synced * clusterVersion has MachineAPI as an enabled capability OR the API enabled on the api server * MachineInformer is synced * we find at least one Machine resources in the Running state.

type MachineAPIChecker

type MachineAPIChecker interface {
	// IsFunctional checks if the Machine API is functional (that requires it to be either enabled OR available)
	IsFunctional() (bool, error)
	// IsEnabled checks if the Machine API is enabled via CVO
	IsEnabled() (bool, error)
	// IsAvailable checks if the Machine API is available on the API server
	IsAvailable() (bool, error)
}

MachineAPIChecker captures a set of functions for working with the Machine API

type QuorumCheck

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

QuorumCheck is just a convenience struct around bootstrap.go

func (*QuorumCheck) IsSafeToUpdateRevision

func (c *QuorumCheck) IsSafeToUpdateRevision() (bool, error)

type QuorumChecker

type QuorumChecker interface {
	// IsSafeToUpdateRevision checks the current etcd cluster and returns true if the cluster can tolerate the
	// loss of a single etcd member. Such loss is common during new static pod revision.
	// Returns True when it is absolutely safe, false if not. Error otherwise, which always indicates it is unsafe.
	IsSafeToUpdateRevision() (bool, error)
}

func NewQuorumChecker

func NewQuorumChecker(
	configMapLister corev1listers.ConfigMapLister,
	namespaceLister corev1listers.NamespaceLister,
	infraLister configv1listers.InfrastructureLister,
	operatorClient v1helpers.StaticPodOperatorClient,
	etcdClient etcdcli.AllMemberLister,
) QuorumChecker

Jump to

Keyboard shortcuts

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