internal

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: Apache-2.0 Imports: 29 Imported by: 0

README

Internal package

This package can't be included by external repositories. We will maintain methods/functions here that should be shared between our different implementations (e.g. kubectl-fdb and the controller). We mark these methods internal to prevent external usage, since we don't give any guarantees for backwards compatibility.

Documentation

Index

Constants

View Source
const (
	// OldFDBProcessGroupIDLabel represents the label that is used to represent a instance ID
	// Deprecated: This label will not be applied by default in the future.
	OldFDBProcessGroupIDLabel = "fdb-instance-id"

	// OldFDBProcessClassLabel represents the label that is used to represent the process class
	// Deprecated: This label will not be applied by default in the future.
	OldFDBProcessClassLabel = "fdb-process-class"

	// OldFDBClusterLabel represents the label that is used to represent the cluster of an instance
	// Deprecated: This label will not be applied by default in the future.
	OldFDBClusterLabel = "fdb-cluster-name"
)
View Source
const (
	// ClusterFileKey defines the key name in the ConfigMap
	ClusterFileKey = "cluster-file"
)
View Source
const (
	// MockUnreachableAnnotation defines if a Pod should be unreachable. This annotation
	// is currently only used for testing cases.
	MockUnreachableAnnotation = "foundationdb.org/mock-unreachable"
)

Variables

This section is empty.

Functions

func BuildOwnerReference added in v0.39.2

func BuildOwnerReference(ownerType metav1.TypeMeta, ownerMetadata metav1.ObjectMeta) []metav1.OwnerReference

BuildOwnerReference returns an OwnerReference for the provided input

func CheckDynamicFilePresent added in v0.39.2

func CheckDynamicFilePresent(client FdbPodClient, filename string) (bool, error)

CheckDynamicFilePresent waits for a file to be present in the dynamic conf

func CleanupOldCliLogs added in v0.39.0

func CleanupOldCliLogs(minFileAge time.Duration)

CleanupOldCliLogs removes old fdbcli log files.

func CreateDefaultBackup added in v0.39.2

func CreateDefaultBackup(cluster *fdbtypes.FoundationDBCluster) *fdbtypes.FoundationDBBackup

CreateDefaultBackup creates a defaultFoundationDBCluster for testing

func CreateDefaultCluster added in v0.39.2

func CreateDefaultCluster() *fdbtypes.FoundationDBCluster

CreateDefaultCluster creates a default FoundationDBCluster for testing

func CreatePVCMap added in v0.45.0

CreatePVCMap creates a map with the process group ID as a key and the according PVC as a value

func CreatePodMap added in v0.45.0

func CreatePodMap(cluster *fdbtypes.FoundationDBCluster, pods []*corev1.Pod) map[string]*corev1.Pod

CreatePodMap creates a map with the process group ID as a key and the according Pod as a value

func GetBackupDeployment added in v0.39.2

func GetBackupDeployment(backup *fdbtypes.FoundationDBBackup) (*appsv1.Deployment, error)

GetBackupDeployment builds a deployment for backup agents for a cluster.

func GetConfigMap added in v0.39.2

func GetConfigMap(cluster *v1beta1.FoundationDBCluster) (*corev1.ConfigMap, error)

GetConfigMap builds a config map for a cluster's dynamic config

func GetConfigMapMonitorConfEntry added in v0.39.2

func GetConfigMapMonitorConfEntry(pClass v1beta1.ProcessClass, serversPerPod int) string

GetConfigMapMonitorConfEntry returns the specific key for the monitor conf in the ConfigMap

func GetCoordinatorsFromStatus added in v0.37.0

func GetCoordinatorsFromStatus(status *fdbtypes.FoundationDBStatus) map[string]struct{}

GetCoordinatorsFromStatus gets the current coordinators from the status. The returning set will contain all processes by their process group ID.

func GetDynamicConfHash added in v0.39.2

func GetDynamicConfHash(configMap *corev1.ConfigMap, pClass v1beta1.ProcessClass, serversPerPod int) (string, error)

GetDynamicConfHash gets a hash of the data from the config map holding the cluster's dynamic conf.

This will omit keys that we do not expect the Pods to reference e.g. for storage Pods only include the storage config.

func GetEnvVars added in v0.39.2

func GetEnvVars(container v1.Container) map[string]*v1.EnvVar

GetEnvVars returns a HashMap of EnvVars for the container

func GetHeadlessService added in v0.39.2

func GetHeadlessService(cluster *v1beta1.FoundationDBCluster) *v1.Service

GetHeadlessService builds a headless service for a FoundationDB cluster.

func GetImage added in v0.39.2

func GetImage(image string, configs []fdbtypes.ImageConfig, versionString string, allowOverride bool) (string, error)

GetImage returns the image for container

func GetInstanceID added in v0.39.2

func GetInstanceID(cluster *fdbtypes.FoundationDBCluster, processClass fdbtypes.ProcessClass, idNum int) (string, string)

GetInstanceID generates an ID for an instance.

This will return the pod name and the processGroup ID.

func GetJSONHash added in v0.39.2

func GetJSONHash(object interface{}) (string, error)

GetJSONHash serializes an object to JSON and takes a hash of the resulting JSON.

func GetMonitorConf added in v0.39.2

func GetMonitorConf(cluster *fdbtypes.FoundationDBCluster, processClass fdbtypes.ProcessClass, podClient FdbPodClient, serversPerPod int) (string, error)

GetMonitorConf builds the monitor conf template

func GetObjectMetadata added in v0.39.2

func GetObjectMetadata(cluster *fdbtypes.FoundationDBCluster, base *metav1.ObjectMeta, processClass fdbtypes.ProcessClass, id string) metav1.ObjectMeta

GetObjectMetadata returns the ObjectMetadata for a process

func GetPod added in v0.39.2

func GetPod(cluster *fdbtypes.FoundationDBCluster, processClass fdbtypes.ProcessClass, idNum int) (*corev1.Pod, error)

GetPod builds a pod for a new instance

func GetPodLabels added in v0.44.0

func GetPodLabels(cluster *fdbtypes.FoundationDBCluster, processClass fdbtypes.ProcessClass, id string) map[string]string

GetPodLabels creates the labels that we will apply to a Pod

func GetPodListOptions added in v0.39.2

func GetPodListOptions(cluster *fdbtypes.FoundationDBCluster, processClass fdbtypes.ProcessClass, id string) []client.ListOption

GetPodListOptions returns the listOptions to list Pods

func GetPodMatchLabels added in v0.44.0

func GetPodMatchLabels(cluster *fdbtypes.FoundationDBCluster, processClass fdbtypes.ProcessClass, id string) map[string]string

GetPodMatchLabels creates the labels that we will use when filtering for a pod.

func GetPodMetadata added in v0.39.2

func GetPodMetadata(cluster *fdbtypes.FoundationDBCluster, processClass fdbtypes.ProcessClass, id string, specHash string) metav1.ObjectMeta

GetPodMetadata returns the metadata for a specific Pod

func GetPodSpec added in v0.39.2

func GetPodSpec(cluster *fdbtypes.FoundationDBCluster, processClass fdbtypes.ProcessClass, idNum int) (*corev1.PodSpec, error)

GetPodSpec builds a pod spec for a FoundationDB pod

func GetPodSpecHash added in v0.39.2

func GetPodSpecHash(cluster *fdbtypes.FoundationDBCluster, processClass fdbtypes.ProcessClass, id int, spec *corev1.PodSpec) (string, error)

GetPodSpecHash builds the hash of the expected spec for a pod.

func GetProcessClassFromMeta

func GetProcessClassFromMeta(cluster *fdbtypes.FoundationDBCluster, metadata v1.ObjectMeta) fdbtypes.ProcessClass

GetProcessClassFromMeta fetches the process class from an object's metadata.

func GetProcessGroupIDFromMeta added in v0.44.0

func GetProcessGroupIDFromMeta(cluster *fdbtypes.FoundationDBCluster, metadata metav1.ObjectMeta) string

GetProcessGroupIDFromMeta fetches the instance ID from an object's metadata.

func GetPublicIPSource added in v0.46.0

func GetPublicIPSource(pod *corev1.Pod) (fdbtypes.PublicIPSource, error)

GetPublicIPSource determines how a Pod has gotten its public IP.

func GetPublicIPsForPod added in v0.39.2

func GetPublicIPsForPod(pod *corev1.Pod) []string

GetPublicIPsForPod returns the public IPs for a Pod

func GetPvc added in v0.39.2

func GetPvc(cluster *fdbtypes.FoundationDBCluster, processClass fdbtypes.ProcessClass, idNum int) (*corev1.PersistentVolumeClaim, error)

GetPvc builds a persistent volume claim for a FoundationDB instance.

func GetPvcMetadata added in v0.39.2

func GetPvcMetadata(cluster *fdbtypes.FoundationDBCluster, processClass fdbtypes.ProcessClass, id string) metav1.ObjectMeta

GetPvcMetadata returns the metadata for a PVC

func GetService added in v0.39.2

func GetService(cluster *fdbtypes.FoundationDBCluster, processClass fdbtypes.ProcessClass, idNum int) (*corev1.Service, error)

GetService builds a service for a new instance

func GetSidecarImage added in v0.44.0

func GetSidecarImage(cluster *fdbtypes.FoundationDBCluster, pClass fdbtypes.ProcessClass) (string, error)

GetSidecarImage returns the expected sidecar image for a specific process class

func GetSinglePodListOptions added in v0.39.2

func GetSinglePodListOptions(cluster *fdbtypes.FoundationDBCluster, instanceID string) []client.ListOption

GetSinglePodListOptions returns the listOptions to list a single Pod

func GetStartCommand added in v0.39.2

func GetStartCommand(cluster *fdbtypes.FoundationDBCluster, processCless fdbtypes.ProcessClass, podClient FdbPodClient, processNumber int, processCount int) (string, error)

GetStartCommand builds the expected start command for an instance.

func GetStorageServersPerPodForPod added in v0.39.2

func GetStorageServersPerPodForPod(pod *corev1.Pod) (int, error)

GetStorageServersPerPodForPod returns the value of STORAGE_SERVERS_PER_POD from the sidecar or 1

func HasDesiredFaultTolerance added in v0.44.0

func HasDesiredFaultTolerance(adminClient fdbadminclient.AdminClient, cluster *fdbtypes.FoundationDBCluster) (bool, error)

HasDesiredFaultTolerance checks if the cluster has the desired fault tolerance.

func IsNetworkError added in v0.39.1

func IsNetworkError(err error) bool

IsNetworkError returns true if the network is a network error net.Error

func NormalizeClusterSpec

func NormalizeClusterSpec(cluster *fdbtypes.FoundationDBCluster, options DeprecationOptions) error

NormalizeClusterSpec converts a cluster spec into an unambiguous, future-proof form, by applying any implicit defaults and moving configuration from deprecated fields into fully-supported fields.

func ParseProcessGroupID added in v0.46.0

func ParseProcessGroupID(id string) (fdbtypes.ProcessClass, int, error)

ParseProcessGroupID extracts the components of an process group ID.

func ProcessClassFromLabels

func ProcessClassFromLabels(cluster *fdbtypes.FoundationDBCluster, labels map[string]string) fdbtypes.ProcessClass

ProcessClassFromLabels extracts the ProcessClass label from the metav1.ObjectMeta.Labels map

func UpdateDynamicFiles added in v0.39.2

func UpdateDynamicFiles(client FdbPodClient, filename string, contents string, updateFunc func(client FdbPodClient) error) (bool, error)

UpdateDynamicFiles checks if the files in the dynamic conf volume match the expected contents, and tries to copy the latest files from the input volume if they do not.

func ValidateCustomParameters

func ValidateCustomParameters(customParameters []string) error

ValidateCustomParameters ensures that no duplicate values are set and that no protected/forbidden parameters are set. Theoretically we could also check if FDB supports the given parameter.

Types

type DeprecationOptions

type DeprecationOptions struct {
	// Whether we should apply the latest defaults rather than the defaults that
	// were initially established for this major version.
	UseFutureDefaults bool

	// Whether we should only fill in defaults that have changes between major
	// versions of the operator.
	OnlyShowChanges bool
}

DeprecationOptions controls how deprecations and changes to defaults get applied to our specs.

type FdbPodClient added in v0.39.2

type FdbPodClient interface {
	// GetCluster returns the cluster associated with a client
	GetCluster() *fdbtypes.FoundationDBCluster

	// GetPod returns the pod associated with a client
	GetPod() *corev1.Pod

	// IsPresent checks whether a file in the sidecar is present
	IsPresent(filename string) (bool, error)

	// CheckHash checks whether a file in the sidecar has the expected contents.
	CheckHash(filename string, contents string) (bool, error)

	// GenerateMonitorConf updates the monitor conf file for a pod
	GenerateMonitorConf() error

	// CopyFiles copies the files from the config map to the shared dynamic conf
	// volume
	CopyFiles() error

	// GetVariableSubstitutions gets the current keys and values that this
	// instance will substitute into its monitor conf.
	GetVariableSubstitutions() (map[string]string, error)
}

FdbPodClient provides methods for working with a FoundationDB pod

func NewFdbPodClient added in v0.39.2

func NewFdbPodClient(cluster *fdbtypes.FoundationDBCluster, pod *corev1.Pod) (FdbPodClient, error)

NewFdbPodClient builds a client for working with an FDB Pod

func NewMockFdbPodClient added in v0.39.2

func NewMockFdbPodClient(cluster *fdbtypes.FoundationDBCluster, pod *corev1.Pod) (FdbPodClient, error)

NewMockFdbPodClient builds a mock client for working with an FDB pod

type None added in v0.37.0

type None struct{}

None is a simple struct to create a set to indicate the value of the map has no meaning.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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