controllerhelpers

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 56 Imported by: 10

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func AddFinalizerPatch added in v1.16.0

func AddFinalizerPatch(obj metav1.Object, finalizer string) ([]byte, error)

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 ConvertEndpointSlicesToEndpoints added in v1.16.0

func ConvertEndpointSlicesToEndpoints(endpointSlices []*discoveryv1.EndpointSlice) ([]*corev1.Endpoints, 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 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 GetCustomResourceObjects added in v1.15.0

func GetCustomResourceObjects[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 GetDeleteOwnerReferenceMergePatchBytes added in v1.15.0

func GetDeleteOwnerReferenceMergePatchBytes(obj metav1.Object, controllerUID types.UID) ([]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 GetRackNodeCount added in v1.15.0

func GetRackNodeCount(sdc *scyllav1alpha1.ScyllaDBDatacenter, rackName string) (*int32, error)

func GetRemoteObjects added in v1.16.0

func GetRemoteObjects[CT, T kubeinterfaces.ObjectInterface](
	ctx context.Context,
	remoteClusters []string,
	controllerMap map[string]metav1.Object,
	controllerGVK schema.GroupVersionKind,
	selector labels.Selector,
	control ClusterControlleeManagerGetObjectsInterface[CT, T],
) (map[string]map[string]T, map[string]error)

func GetRequiredScyllaHosts

func GetRequiredScyllaHosts(sdc *scyllav1alpha1.ScyllaDBDatacenter, services map[string]*corev1.Service, podLister corev1listers.PodLister) ([]string, error)

func GetScyllaBroadcastAddress added in v1.11.1

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

func GetScyllaClientBroadcastHost added in v1.16.3

func GetScyllaClientBroadcastHost(sdc *scyllav1alpha1.ScyllaDBDatacenter, svc *corev1.Service, pod *corev1.Pod) (string, error)

func GetScyllaContainerID

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

func GetScyllaDBClusterDatacenterNodeCount added in v1.16.0

func GetScyllaDBClusterDatacenterNodeCount(sc *scyllav1alpha1.ScyllaDBCluster, dc scyllav1alpha1.ScyllaDBClusterDatacenter) int32

func GetScyllaDBClusterNodeCount added in v1.16.0

func GetScyllaDBClusterNodeCount(sc *scyllav1alpha1.ScyllaDBCluster) int32

func GetScyllaDBManagerAgentAuthToken added in v1.18.0

func GetScyllaDBManagerAgentAuthToken(
	getAuthTokens ...func() ([]metav1.Condition, string, error),
) ([]metav1.Condition, string, error)

GetScyllaDBManagerAgentAuthToken retrieves the ScyllaDB Manager agent auth token. It greedily gets the auth tokens from the provided functions, returning on the first non-empty result. If no auth token is provided by any of the sources, a new auth token is generated.

func GetScyllaHost

func GetScyllaHost(sdc *scyllav1alpha1.ScyllaDBDatacenter, svc *corev1.Service, pod *corev1.Pod) (string, error)

func GetScyllaHostForScyllaCluster added in v1.15.0

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

func GetSidecarRuntimeConfigFromConfigMap added in v1.14.0

func GetSidecarRuntimeConfigFromConfigMap(cm *corev1.ConfigMap) (*internalapi.SidecarRuntimeConfig, error)

func HasFinalizer added in v1.16.0

func HasFinalizer(obj metav1.Object, finalizer string) bool

func HasMatchingAnnotation added in v1.18.0

func HasMatchingAnnotation(obj metav1.Object, annotationKey string, annotationValue string) bool

func IsDaemonSetRolledOut

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

func IsManagedByGlobalScyllaDBManagerInstance added in v1.18.0

func IsManagedByGlobalScyllaDBManagerInstance(smcr *scyllav1alpha1.ScyllaDBManagerClusterRegistration) bool

func IsNodeConfigPod added in v1.18.0

func IsNodeConfigPod(pod *corev1.Pod) bool

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 IsPodTunable added in v1.13.0

func IsPodTunable(pod *corev1.Pod) bool

func IsScyllaContainerRunning

func IsScyllaContainerRunning(pod *corev1.Pod) bool

func IsScyllaDBDatacenterRolledOut added in v1.16.0

func IsScyllaDBDatacenterRolledOut(sdc *scyllav1alpha1.ScyllaDBDatacenter) (bool, error)

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 PrepareSetAnnotationPatch added in v1.18.0

func PrepareSetAnnotationPatch(obj metav1.Object, annotationKey string, annotationValue *string) ([]byte, 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 ReleaseObjects added in v1.15.0

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

func RemoveFinalizerPatch added in v1.16.0

func RemoveFinalizerPatch(obj metav1.Object, finalizer string) ([]byte, 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 SetAggregatedWorkloadConditions added in v1.9.0

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

func SetAggregatedWorkloadConditionsBySuffixes added in v1.17.0

func SetAggregatedWorkloadConditionsBySuffixes(availableConditionType, progressingConditionType, degradedConditionType string, conditions *[]metav1.Condition, generation int64) error

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 SyncRemoteNamespacedObject added in v1.17.0

func SyncRemoteNamespacedObject(conditions *[]metav1.Condition, progressingConditionType, degradedCondType string, observedGeneration int64, remoteClusterName string, remoteNamespace *corev1.Namespace, remoteController metav1.Object, syncFn func(*corev1.Namespace, metav1.Object) ([]metav1.Condition, error)) error

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 WaitForDaemonSetState added in v1.15.0

func WaitForDaemonSetState(ctx context.Context, client appsv1client.DaemonSetInterface, name string, options WaitForStateOptions, condition func(*appsv1.DaemonSet) (bool, error), additionalConditions ...func(set *appsv1.DaemonSet) (bool, error)) (*appsv1.DaemonSet, 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 WaitForScyllaDBClusterState added in v1.16.0

func WaitForScyllaDBClusterState(ctx context.Context, client scyllav1alpha1client.ScyllaDBClusterInterface, name string, options WaitForStateOptions, condition func(cluster *scyllav1alpha1.ScyllaDBCluster) (bool, error), additionalConditions ...func(cluster *scyllav1alpha1.ScyllaDBCluster) (bool, error)) (*scyllav1alpha1.ScyllaDBCluster, error)

func WaitForScyllaDBDatacenterState added in v1.18.0

func WaitForScyllaDBDatacenterState(ctx context.Context, client scyllav1alpha1client.ScyllaDBDatacenterInterface, name string, options WaitForStateOptions, condition func(cluster *scyllav1alpha1.ScyllaDBDatacenter) (bool, error), additionalConditions ...func(*scyllav1alpha1.ScyllaDBDatacenter) (bool, error)) (*scyllav1alpha1.ScyllaDBDatacenter, error)

func WaitForScyllaDBManagerTaskState added in v1.18.0

func WaitForScyllaDBManagerTaskState(ctx context.Context, client scyllav1alpha1client.ScyllaDBManagerTaskInterface, name string, options WaitForStateOptions, condition func(*scyllav1alpha1.ScyllaDBManagerTask) (bool, error), additionalConditions ...func(task *scyllav1alpha1.ScyllaDBManagerTask) (bool, error)) (*scyllav1alpha1.ScyllaDBManagerTask, 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 AggregatedConditions added in v1.14.0

type AggregatedConditions[Obj runtime.Object] struct {
	// contains filtered or unexported fields
}

func NewAggregatedConditions added in v1.14.0

func NewAggregatedConditions[Obj runtime.Object](condition func(obj Obj) (bool, error), additionalConditions ...func(obj Obj) (bool, error)) *AggregatedConditions[Obj]

func (AggregatedConditions[Obj]) Condition added in v1.14.0

func (ac AggregatedConditions[Obj]) Condition(obj Obj) (bool, error)

func (AggregatedConditions[Obj]) GetStateString added in v1.14.0

func (ac AggregatedConditions[Obj]) GetStateString() string

type ClusterControlleeManagerGetObjectsFuncs added in v1.16.0

type ClusterControlleeManagerGetObjectsFuncs[CT, T kubeinterfaces.ObjectInterface] struct {
	ClusterFunc func(string) (ControlleeManagerGetObjectsInterface[CT, T], error)
}

func (*ClusterControlleeManagerGetObjectsFuncs[CT, T]) Cluster added in v1.16.0

type ClusterControlleeManagerGetObjectsInterface added in v1.16.0

type ClusterControlleeManagerGetObjectsInterface[CT, T kubeinterfaces.ObjectInterface] interface {
	Cluster(string) (ControlleeManagerGetObjectsInterface[CT, T], error)
}

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[T]) EnqueueAllFunc added in v1.14.0

func (h *Handlers[T]) EnqueueAllFunc(enqueueFunc EnqueueFuncType) EnqueueFuncType

func (*Handlers[T]) EnqueueAllWithUntypedFilterFunc added in v1.14.0

func (h *Handlers[T]) EnqueueAllWithUntypedFilterFunc(filterFunc func(kubeinterfaces.ObjectInterface) bool) EnqueueFuncType

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