Documentation ¶
Index ¶
- Constants
- func ComputeScheduleInterval(cronSchedule string) (time.Duration, error)
- func ContainsAllDesiredLabels(actual, desired map[string]string) bool
- func ContainsLabel(actual map[string]string, key, value string) bool
- func DoesLabelSelectorMatchLabels(labelSelector *metav1.LabelSelector, resourceLabels map[string]string) (bool, error)
- func FetchPVCWarningMessagesForStatefulSet(ctx context.Context, cl client.Client, sts *appsv1.StatefulSet) (string, error)
- func GetBackupRestoreContainerEnvVars(store *druidv1alpha1.StoreSpec) ([]corev1.EnvVar, error)
- func GetEnvVarFromSecret(name, secretName, secretKey string, optional bool) corev1.EnvVar
- func GetEnvVarFromValue(name, value string) corev1.EnvVar
- func GetEtcdBackupRestoreImage(iv imagevector.ImageVector) (*string, error)
- func GetEtcdContainerPeerTLSVolumeMounts(sts *appsv1.StatefulSet) []corev1.VolumeMount
- func GetEtcdImages(etcd *druidv1alpha1.Etcd, iv imagevector.ImageVector) (string, string, string, error)
- func GetInitContainerImage(iv imagevector.ImageVector) (*string, error)
- func GetStatefulSet(ctx context.Context, cl client.Client, etcd *druidv1alpha1.Etcd) (*appsv1.StatefulSet, error)
- func GetStatefulSetContainerTLSVolumeMounts(sts *appsv1.StatefulSet) map[string][]corev1.VolumeMount
- func HasPodReadyConditionTrue(pod *corev1.Pod) bool
- func IfConditionOr[T any](condition bool, trueVal, falseVal T) T
- func IsEmptyString(s string) bool
- func IsPeerURLInSyncForAllMembers(ctx context.Context, cl client.Client, logger logr.Logger, ...) (bool, error)
- func IsStatefulSetReady(etcdReplicas int32, statefulSet *appsv1.StatefulSet) (bool, string)
- func Key(namespaceOrName string, nameOpt ...string) client.ObjectKey
- func ListAllMemberLeaseObjectMeta(ctx context.Context, cl client.Client, etcd *druidv1alpha1.Etcd) ([]metav1.PartialObjectMetadata, error)
- func MatchPodConditions(conditions []corev1.PodCondition, condType corev1.PodConditionType, ...) bool
- func MergeMaps[K comparable, V any](sourceMaps ...map[K]V) map[K]V
- func MustNewLogger(devMode bool, format LogFormat) logr.Logger
- func NewLogger(devMode bool, format LogFormat) (logr.Logger, error)
- func RunConcurrently(ctx component.OperatorContext, tasks []OperatorTask) []error
- type LogFormat
- type OperatorTask
Constants ¶
const LeaseAnnotationKeyPeerURLTLSEnabled = "member.etcd.gardener.cloud/tls-enabled"
LeaseAnnotationKeyPeerURLTLSEnabled is the annotation key present on the member lease. If its value is `true` then it indicates that the member is TLS enabled. If the annotation is not present or its value is `false` then it indicates that the member is not TLS enabled.
Variables ¶
This section is empty.
Functions ¶
func ComputeScheduleInterval ¶ added in v0.24.0
ComputeScheduleInterval computes the interval between two activations for the given cron schedule. Assumes that every cron activation is at equal intervals apart, based on cron schedules such as "once every X hours", "once every Y days", "at 1:00pm on every Tuesday", etc. TODO: write a new function to accurately compute the previous activation time from the cron schedule in order to compute when the previous activation of the cron schedule was supposed to have occurred, instead of relying on the assumption that all the cron activations are evenly spaced.
func ContainsAllDesiredLabels ¶
ContainsAllDesiredLabels checks if the actual map contains all the desired labels.
func ContainsLabel ¶
ContainsLabel checks if the actual map contains the specified key-value pair.
func DoesLabelSelectorMatchLabels ¶ added in v0.23.1
func DoesLabelSelectorMatchLabels(labelSelector *metav1.LabelSelector, resourceLabels map[string]string) (bool, error)
DoesLabelSelectorMatchLabels checks if the given label selector matches the given labels.
func FetchPVCWarningMessagesForStatefulSet ¶
func FetchPVCWarningMessagesForStatefulSet(ctx context.Context, cl client.Client, sts *appsv1.StatefulSet) (string, error)
FetchPVCWarningMessagesForStatefulSet fetches warning messages for PVCs for a statefulset, if found concatenates the first 2 warning messages and returns them as string warning message. In case it fails to fetch events, it collects the errors and returns the combined error.
func GetBackupRestoreContainerEnvVars ¶
func GetBackupRestoreContainerEnvVars(store *druidv1alpha1.StoreSpec) ([]corev1.EnvVar, error)
GetBackupRestoreContainerEnvVars returns non-provider-specific environment variables for the backup-restore container.
func GetEnvVarFromSecret ¶
GetEnvVarFromSecret returns environment variable object with provided name and optional value from secret
func GetEnvVarFromValue ¶
GetEnvVarFromValue returns environment variable object with the provided name and value
func GetEtcdBackupRestoreImage ¶
func GetEtcdBackupRestoreImage(iv imagevector.ImageVector) (*string, error)
GetEtcdBackupRestoreImage returns the image for backup-restore from the given image vector.
func GetEtcdContainerPeerTLSVolumeMounts ¶ added in v0.23.3
func GetEtcdContainerPeerTLSVolumeMounts(sts *appsv1.StatefulSet) []corev1.VolumeMount
GetEtcdContainerPeerTLSVolumeMounts returns the volume mounts for the etcd container that are related to peer TLS. It will look at both older names (present in version <= v0.22) and new names (present in version >= v0.23) to create the slice.
func GetEtcdImages ¶
func GetEtcdImages(etcd *druidv1alpha1.Etcd, iv imagevector.ImageVector) (string, string, string, error)
GetEtcdImages returns images for etcd and backup-restore by inspecting the etcd spec and the image vector and returns the image for the init container by inspecting the image vector. It will give preference to images that are set in the etcd spec and only if the image is not found in it should it be picked up from the image vector if it's set there. A return value of nil for either of the images indicates that the image is not set.
func GetInitContainerImage ¶
func GetInitContainerImage(iv imagevector.ImageVector) (*string, error)
GetInitContainerImage returns the image for init container from the given image vector.
func GetStatefulSet ¶
func GetStatefulSet(ctx context.Context, cl client.Client, etcd *druidv1alpha1.Etcd) (*appsv1.StatefulSet, error)
GetStatefulSet fetches StatefulSet created for the etcd. Nil will be returned if one of these conditions are met: - StatefulSet is not found - StatefulSet is not controlled by the etcd
func GetStatefulSetContainerTLSVolumeMounts ¶ added in v0.23.1
func GetStatefulSetContainerTLSVolumeMounts(sts *appsv1.StatefulSet) map[string][]corev1.VolumeMount
GetStatefulSetContainerTLSVolumeMounts returns a map of container name to TLS volume mounts for the given StatefulSet.
func HasPodReadyConditionTrue ¶
HasPodReadyConditionTrue checks if the pod has a Ready condition with status True.
func IfConditionOr ¶
IfConditionOr implements a simple ternary operator, if the passed condition is true then trueVal is returned else falseVal is returned.
func IsEmptyString ¶
IsEmptyString returns true if the string is empty or contains only whitespace characters.
func IsPeerURLInSyncForAllMembers ¶ added in v0.23.1
func IsPeerURLInSyncForAllMembers(ctx context.Context, cl client.Client, logger logr.Logger, etcd *druidv1alpha1.Etcd, replicas int32) (bool, error)
IsPeerURLInSyncForAllMembers checks if the peer URL is in sync for all existing members of an etcd cluster identified by etcdName and in the provided namespace.
func IsStatefulSetReady ¶
func IsStatefulSetReady(etcdReplicas int32, statefulSet *appsv1.StatefulSet) (bool, string)
IsStatefulSetReady checks whether the given StatefulSet is ready and up-to-date. A StatefulSet is considered healthy if its controller observed its current revision, it is not in an update (i.e. UpdateRevision is empty) and if its current replicas are equal to desired replicas specified in ETCD specs. It returns ready status (bool) and in case it is not ready then the second return value holds the reason.
func Key ¶
Key creates a new client.ObjectKey from the given parameters. There are only two ways to call this function:
- If only namespaceOrName is set, then a client.ObjectKey with name set to namespaceOrName is returned.
- If namespaceOrName and one nameOpt is given, then a client.ObjectKey with namespace set to namespaceOrName and name set to nameOpt[0] is returned.
For all other cases, this method panics.
func ListAllMemberLeaseObjectMeta ¶ added in v0.23.1
func ListAllMemberLeaseObjectMeta(ctx context.Context, cl client.Client, etcd *druidv1alpha1.Etcd) ([]metav1.PartialObjectMetadata, error)
ListAllMemberLeaseObjectMeta returns the list of all member leases for the given etcd cluster.
func MatchPodConditions ¶
func MatchPodConditions(conditions []corev1.PodCondition, condType corev1.PodConditionType, condStatus corev1.ConditionStatus) bool
MatchPodConditions checks if the specified condition type and status are present in the given pod conditions.
func MergeMaps ¶
func MergeMaps[K comparable, V any](sourceMaps ...map[K]V) map[K]V
MergeMaps merges the contents of maps. All maps will be processed in the order in which they are sent. For overlapping keys across source maps, value in the merged map for this key will be from the last occurrence of the key-value.
func MustNewLogger ¶
MustNewLogger is like NewLogger but panics on invalid input.
func RunConcurrently ¶
func RunConcurrently(ctx component.OperatorContext, tasks []OperatorTask) []error
RunConcurrently runs tasks concurrently with number of goroutines bounded by bound. If there is a panic executing a single OperatorTask then it will capture the panic and capture it as an error which will then subsequently be returned from this function. It will not propagate the panic causing the app to exit.
Types ¶
type OperatorTask ¶
type OperatorTask struct { // Name is the name of the task Name string // Fn is the function which accepts a component operator context and returns an error if there is one. // Implementations of Fn should handle context cancellation properly. Fn func(ctx component.OperatorContext) error }
OperatorTask is a holder for a named function.