controllerhelpers

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HandlerOperationTypeAdd    = "Add"
	HandlerOperationTypeUpdate = "Update"
	HandlerOperationTypeDelete = "Delete"
)

Variables

This section is empty.

Functions

func AddGenericProgressingStatusCondition added in v1.8.0

func AddGenericProgressingStatusCondition(conditions *[]metav1.Condition, conditionType string, obj runtime.Object, verb string, observedGeneration int64)

func AggregateStatusConditions added in v1.8.0

func AggregateStatusConditions(conditions []metav1.Condition, condition metav1.Condition) (metav1.Condition, error)

func FilterObjectMapByLabel added in v1.9.0

func FilterObjectMapByLabel[T metav1.Object](objects map[string]T, selector labels.Selector) map[string]T

func FindContainerStatus added in v1.8.0

func FindContainerStatus(pod *corev1.Pod, containerName string) *corev1.ContainerStatus

func FindNodeConfigCondition

FindNodeConfigCondition finds the conditionType in conditions.

func FindNodeStatus

func FindNodeStatus(nodeStatuses []scyllav1alpha1.NodeConfigNodeStatus, nodeName string) *scyllav1alpha1.NodeConfigNodeStatus

func FindScyllaContainerStatus

func FindScyllaContainerStatus(pod *corev1.Pod) *corev1.ContainerStatus

func FindStatusConditionsWithSuffix added in v1.8.0

func FindStatusConditionsWithSuffix(conditions []metav1.Condition, suffix string) []metav1.Condition

FindStatusConditionsWithSuffix finds all conditions that end with the suffix, except the identity.

func GenerateMergePatch

func GenerateMergePatch(original runtime.Object, modified runtime.Object) ([]byte, error)

func GetNodePointerArrayFromArray

func GetNodePointerArrayFromArray(nodes []corev1.Node) []*corev1.Node

func GetObjects added in v1.9.0

func GetObjects[CT, T kubeinterfaces.ObjectInterface](
	ctx context.Context,
	controller metav1.Object,
	controllerGVK schema.GroupVersionKind,
	selector labels.Selector,
	control ControlleeManagerGetObjectsInterface[CT, T],
) (map[string]T, error)

func GetObjectsWithFilter added in v1.9.0

func GetObjectsWithFilter[CT, T kubeinterfaces.ObjectInterface](
	ctx context.Context,
	controller metav1.Object,
	controllerGVK schema.GroupVersionKind,
	selector labels.Selector,
	filterFunc func(T) bool,
	control ControlleeManagerGetObjectsInterface[CT, T],
) (map[string]T, error)

func GetPodCondition

func GetPodCondition(conditions []corev1.PodCondition, conditionType corev1.PodConditionType) *corev1.PodCondition

func GetRequiredScyllaHosts

func GetRequiredScyllaHosts(sc *scyllav1.ScyllaCluster, services map[string]*corev1.Service, podLister corev1listers.PodLister) ([]string, error)

func GetScyllaBroadcastAddress added in v1.11.1

func GetScyllaBroadcastAddress(broadcastAddressType scyllav1.BroadcastAddressType, svc *corev1.Service, pod *corev1.Pod) (string, error)

func GetScyllaContainerID

func GetScyllaContainerID(pod *corev1.Pod) (string, error)

func GetScyllaHost

func GetScyllaHost(sc *scyllav1.ScyllaCluster, svc *corev1.Service, pod *corev1.Pod) (string, error)

func IsDaemonSetRolledOut

func IsDaemonSetRolledOut(ds *appsv1.DaemonSet) (bool, error)

func IsNodeConfigSelectingNode

func IsNodeConfigSelectingNode(nc *scyllav1alpha1.NodeConfig, node *corev1.Node) (bool, error)

func IsNodeTuned

func IsNodeTuned(ncnss []scyllav1alpha1.NodeConfigNodeStatus, nodeName string) bool

func IsNodeTunedForContainer

func IsNodeTunedForContainer(nc *scyllav1alpha1.NodeConfig, nodeName string, containerID string) bool

func IsOrphanedPV

func IsOrphanedPV(pv *corev1.PersistentVolume, nodes []*corev1.Node) (bool, error)

func IsPodReady

func IsPodReady(pod *corev1.Pod) bool

func IsPodReadyWithPositiveLiveCheck

func IsPodReadyWithPositiveLiveCheck(ctx context.Context, client corev1client.PodsGetter, pod *corev1.Pod) (bool, *corev1.Pod, error)

func IsScyllaContainerRunning

func IsScyllaContainerRunning(pod *corev1.Pod) bool

func IsScyllaPod added in v1.9.0

func IsScyllaPod(pod *corev1.Pod) bool

func IsStatefulSetRolledOut

func IsStatefulSetRolledOut(sts *appsv1.StatefulSet) (bool, error)

func NewScyllaClient added in v1.8.0

func NewScyllaClient(cfg *scyllaclient.Config) (*scyllaclient.Client, error)

func NewScyllaClientForLocalhost added in v1.8.0

func NewScyllaClientForLocalhost() (*scyllaclient.Client, error)

func NewScyllaClientFromToken

func NewScyllaClientFromToken(hosts []string, authToken string) (*scyllaclient.Client, error)

func Prune added in v1.9.0

func Prune[T kubeinterfaces.ObjectInterface](ctx context.Context, requiredObjects []T, existingObjects map[string]T, control PruneControlInterface, eventRecorder record.EventRecorder) error

func RunSync added in v1.9.0

func RunSync(conditions *[]metav1.Condition, progressingConditionType, degradedCondType string, observedGeneration int64, syncFn func() ([]metav1.Condition, error)) error

func SetAggregatedNodeConditions added in v1.9.0

func SetAggregatedNodeConditions(nodeName string, conditions *[]metav1.Condition, generation int64) error

func SetAggregatedWorkloadConditions added in v1.9.0

func SetAggregatedWorkloadConditions(conditions *[]metav1.Condition, generation int64) error

func SetNodeConfigStatusCondition added in v1.9.0

func SetNodeConfigStatusCondition(conditions *[]scyllav1alpha1.NodeConfigCondition, newCondition scyllav1alpha1.NodeConfigCondition)

SetNodeConfigStatusCondition sets the corresponding condition in conditions to newCondition. conditions must be non-nil. If the condition of the specified type already exists (all fields of the existing condition are updated to newCondition, LastTransitionTime is set to now if the new status differs from the old status) If a condition of the specified type does not exist (LastTransitionTime is set to now() if unset, and newCondition is appended)

func SetRackCondition

func SetRackCondition(rackStatus *scyllav1.RackStatus, newCondition scyllav1.RackConditionType)

func SetStatusConditionFromError added in v1.8.0

func SetStatusConditionFromError(conditions *[]metav1.Condition, err error, conditionType string, observedGeneration int64)

func WaitForConfigMapState added in v1.12.0

func WaitForConfigMapState(ctx context.Context, client corev1client.ConfigMapInterface, name string, options WaitForStateOptions, condition func(*corev1.ConfigMap) (bool, error), additionalConditions ...func(*corev1.ConfigMap) (bool, error)) (*corev1.ConfigMap, error)

func WaitForNodeConfigState added in v1.12.0

func WaitForNodeConfigState(ctx context.Context, ncClient scyllav1alpha1client.NodeConfigInterface, name string, options WaitForStateOptions, condition func(*scyllav1alpha1.NodeConfig) (bool, error), additionalConditions ...func(*scyllav1alpha1.NodeConfig) (bool, error)) (*scyllav1alpha1.NodeConfig, error)

func WaitForObjectState added in v1.12.0

func WaitForObjectState[Object, ListObject runtime.Object](ctx context.Context, client listerWatcher[ListObject], name string, options WaitForStateOptions, condition func(obj Object) (bool, error), additionalConditions ...func(obj Object) (bool, error)) (Object, error)

func WaitForPVCState added in v1.12.0

func WaitForPVCState(ctx context.Context, client corev1client.PersistentVolumeClaimInterface, name string, options WaitForStateOptions, condition func(*corev1.PersistentVolumeClaim) (bool, error), additionalConditions ...func(*corev1.PersistentVolumeClaim) (bool, error)) (*corev1.PersistentVolumeClaim, error)

func WaitForPodState added in v1.12.0

func WaitForPodState(ctx context.Context, client corev1client.PodInterface, name string, options WaitForStateOptions, condition func(*corev1.Pod) (bool, error), additionalConditions ...func(*corev1.Pod) (bool, error)) (*corev1.Pod, error)

func WaitForRoleBindingState added in v1.12.0

func WaitForRoleBindingState(ctx context.Context, client rbacv1client.RoleBindingInterface, name string, options WaitForStateOptions, condition func(*rbacv1.RoleBinding) (bool, error), additionalConditions ...func(*rbacv1.RoleBinding) (bool, error)) (*rbacv1.RoleBinding, error)

func WaitForScyllaClusterState added in v1.12.0

func WaitForScyllaClusterState(ctx context.Context, client scyllav1client.ScyllaClusterInterface, name string, options WaitForStateOptions, condition func(*scyllav1.ScyllaCluster) (bool, error), additionalConditions ...func(*scyllav1.ScyllaCluster) (bool, error)) (*scyllav1.ScyllaCluster, error)

func WaitForScyllaDBMonitoringState added in v1.12.0

func WaitForScyllaDBMonitoringState(ctx context.Context, client scyllav1alpha1client.ScyllaDBMonitoringInterface, name string, options WaitForStateOptions, condition func(monitoring *scyllav1alpha1.ScyllaDBMonitoring) (bool, error), additionalConditions ...func(monitoring *scyllav1alpha1.ScyllaDBMonitoring) (bool, error)) (*scyllav1alpha1.ScyllaDBMonitoring, error)

func WaitForSecretState added in v1.12.0

func WaitForSecretState(ctx context.Context, client corev1client.SecretInterface, name string, options WaitForStateOptions, condition func(*corev1.Secret) (bool, error), additionalConditions ...func(*corev1.Secret) (bool, error)) (*corev1.Secret, error)

func WaitForServiceAccountState added in v1.12.0

func WaitForServiceAccountState(ctx context.Context, client corev1client.ServiceAccountInterface, name string, options WaitForStateOptions, condition func(*corev1.ServiceAccount) (bool, error), additionalConditions ...func(*corev1.ServiceAccount) (bool, error)) (*corev1.ServiceAccount, error)

func WaitForServiceState added in v1.12.0

func WaitForServiceState(ctx context.Context, client corev1client.ServiceInterface, name string, options WaitForStateOptions, condition func(*corev1.Service) (bool, error), additionalConditions ...func(*corev1.Service) (bool, error)) (*corev1.Service, error)

Types

type ControlleeManagerGetObjectsFuncs added in v1.9.0

type ControlleeManagerGetObjectsFuncs[CT, T kubeinterfaces.ObjectInterface] struct {
	GetControllerUncachedFunc func(ctx context.Context, name string, opts metav1.GetOptions) (CT, error)
	ListObjectsFunc           func(selector labels.Selector) ([]T, error)
	PatchObjectFunc           func(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (T, error)
}

func (ControlleeManagerGetObjectsFuncs[CT, T]) GetControllerUncached added in v1.9.0

func (f ControlleeManagerGetObjectsFuncs[CT, T]) GetControllerUncached(ctx context.Context, name string, opts metav1.GetOptions) (CT, error)

func (ControlleeManagerGetObjectsFuncs[CT, T]) ListObjects added in v1.9.0

func (f ControlleeManagerGetObjectsFuncs[CT, T]) ListObjects(selector labels.Selector) ([]T, error)

func (ControlleeManagerGetObjectsFuncs[CT, T]) PatchObject added in v1.9.0

func (f ControlleeManagerGetObjectsFuncs[CT, T]) PatchObject(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (T, error)

type ControlleeManagerGetObjectsInterface added in v1.9.0

type ControlleeManagerGetObjectsInterface[CT, T kubeinterfaces.ObjectInterface] interface {
	GetControllerUncached(ctx context.Context, name string, opts metav1.GetOptions) (CT, error)
	ListObjects(selector labels.Selector) ([]T, error)
	PatchObject(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (T, error)
}

type DeleteFuncType added in v1.9.0

type DeleteFuncType = func(any)

type EnqueueFuncType added in v1.9.0

type GetFuncType added in v1.9.0

type GetFuncType[T any] func(namespace, name string) (T, error)

type HandlerOperationType added in v1.9.0

type HandlerOperationType string

type Handlers added in v1.9.0

type Handlers[T kubeinterfaces.ObjectInterface] struct {
	// contains filtered or unexported fields
}

func NewHandlers added in v1.9.0

func (*Handlers[T]) Enqueue added in v1.9.0

func (h *Handlers[T]) Enqueue(depth int, untypedObj kubeinterfaces.ObjectInterface, op HandlerOperationType)

func (*Handlers[T]) EnqueueAll added in v1.9.0

func (h *Handlers[T]) EnqueueAll(depth int, untypedObj kubeinterfaces.ObjectInterface, op HandlerOperationType)

func (*Handlers[QT]) EnqueueOwner added in v1.9.0

func (h *Handlers[QT]) EnqueueOwner(depth int, obj kubeinterfaces.ObjectInterface, operation HandlerOperationType)

func (*Handlers[QT]) EnqueueOwnerFunc added in v1.9.0

func (h *Handlers[QT]) EnqueueOwnerFunc(enqueueFunc EnqueueFuncType) EnqueueFuncType

func (*Handlers[T]) EnqueueWithFilterFunc added in v1.9.0

func (h *Handlers[T]) EnqueueWithFilterFunc(filterFunc func(T) bool) EnqueueFuncType

func (*Handlers[T]) HandleAdd added in v1.9.0

func (h *Handlers[T]) HandleAdd(obj kubeinterfaces.ObjectInterface, enqueueFunc EnqueueFuncType)

func (*Handlers[T]) HandleAddWithDepth added in v1.9.0

func (h *Handlers[T]) HandleAddWithDepth(depth int, obj any, enqueueFunc EnqueueFuncType)

func (*Handlers[T]) HandleDelete added in v1.9.0

func (h *Handlers[T]) HandleDelete(obj any, enqueueFunc EnqueueFuncType)

func (*Handlers[T]) HandleDeleteWithDepth added in v1.9.0

func (h *Handlers[T]) HandleDeleteWithDepth(depth int, obj any, enqueueFunc EnqueueFuncType)

func (*Handlers[QT]) HandleUpdate added in v1.9.0

func (h *Handlers[QT]) HandleUpdate(old, cur any, enqueueFunc EnqueueFuncType, deleteFunc DeleteFuncType)

func (*Handlers[QT]) HandleUpdateWithDepth added in v1.9.0

func (h *Handlers[QT]) HandleUpdateWithDepth(depth int, oldUntyped, curUntyped any, enqueueFunc EnqueueFuncType, deleteFunc DeleteFuncType)

type InformerHandler added in v1.9.0

type InformerHandler struct {
	Informer cache.SharedIndexInformer
	Handler  cache.ResourceEventHandler
}

type KeyFuncType added in v1.9.0

type KeyFuncType func(obj interface{}) (string, error)

type PruneControlFuncs added in v1.9.0

type PruneControlFuncs struct {
	DeleteFunc func(ctx context.Context, name string, opts metav1.DeleteOptions) error
}

func (*PruneControlFuncs) Delete added in v1.9.0

func (pcf *PruneControlFuncs) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error

type PruneControlInterface added in v1.9.0

type PruneControlInterface interface {
	Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
}

type RequeueError

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

func NewRequeueError

func NewRequeueError(reasons ...string) *RequeueError

func (*RequeueError) Error

func (e *RequeueError) Error() string

type WaitForStateOptions added in v1.12.0

type WaitForStateOptions struct {
	TolerateDelete bool
}

Jump to

Keyboard shortcuts

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