Documentation
¶
Overview ¶
Package common contains common utilities for the everest-operator.
Index ¶
- Constants
- Variables
- func BackupStoragePrefix(db *everestv1alpha1.DatabaseCluster) string
- func BackupStoragesThatReferenceObject(ctx context.Context, c client.Client, keyPath, namespace, keyValue string) (*everestv1alpha1.BackupStorageList, error)
- func CalculatePMMResources(dbEnginSize everestv1alpha1.EngineSize) corev1.ResourceRequirements
- func ConfigureStorage(ctx context.Context, c client.Client, db *everestv1alpha1.DatabaseCluster, ...) error
- func CreateOrUpdate(ctx context.Context, c client.Client, obj client.Object, patchSecretData bool) error
- func CreateOrUpdateSecretData(ctx context.Context, c client.Client, ...) error
- func DatabaseClusterBackupsThatReferenceObject(ctx context.Context, c client.Client, keyPath, namespace, keyValue string) (*everestv1alpha1.DatabaseClusterBackupList, error)
- func DatabaseClusterRestoresThatReferenceObject(ctx context.Context, c client.Client, keyPath, namespace, keyValue string) (*everestv1alpha1.DatabaseClusterRestoreList, error)
- func DatabaseClustersThatReferenceObject(ctx context.Context, c client.Client, keyPath, namespace, keyValue string) (*everestv1alpha1.DatabaseClusterList, error)
- func EnqueueObjectsInNamespace(c client.Client, list client.ObjectList) handler.EventHandler
- func EnsureInUseFinalizer(ctx context.Context, c client.Client, used bool, obj client.Object) error
- func GetAnnotations(ctx context.Context, c client.Client, ...) (map[string]string, error)
- func GetBackupStorage(ctx context.Context, c client.Client, name, namespace string) (*everestv1alpha1.BackupStorage, error)
- func GetClusterType(ctx context.Context, c client.Client) (consts.ClusterType, error)
- func GetDBMonitoringConfig(ctx context.Context, c client.Client, ...) (*everestv1alpha1.MonitoringConfig, error)
- func GetDataImportJobName(db *everestv1alpha1.DatabaseCluster) string
- func GetDatabaseEngine(ctx context.Context, c client.Client, name, namespace string) (*everestv1alpha1.DatabaseEngine, error)
- func GetLoadBalancerConfig(ctx context.Context, c client.Client, ...) (*everestv1alpha1.LoadBalancerConfig, error)
- func GetOperatorImage(ctx context.Context, c client.Client, name types.NamespacedName) (string, error)
- func GetOperatorVersion(ctx context.Context, c client.Client, name types.NamespacedName) (*version.Version, error)
- func GetPodSchedulingPolicy(ctx context.Context, c client.Client, pspName string) (*everestv1alpha1.PodSchedulingPolicy, error)
- func GetRecommendedCRVersion(ctx context.Context, c client.Client, operatorName string, ...) (*string, error)
- func GetRepoNameByBackupStorage(backupStorage *everestv1alpha1.BackupStorage, ...) string
- func GetSecretFromMonitoringConfig(ctx context.Context, c client.Client, ...) (string, error)
- func HandleDBBackupsCleanup(ctx context.Context, c client.Client, ...) (bool, error)
- func HandleUpstreamClusterCleanup(ctx context.Context, c client.Client, ...) (bool, error)
- func IsDatabaseClusterRestoreRunning(ctx context.Context, c client.Client, dbName, dbNs string) (bool, error)
- func IsNewDatabaseCluster(dbState everestv1alpha1.AppState) bool
- func IsOwnedBy(child, parent metav1.Object) bool
- func MergeResources(highPriorityResources, lowPriorityResources corev1.ResourceRequirements) corev1.ResourceRequirements
- func MonitoringConfigsThatReferenceObject(ctx context.Context, c client.Client, keyPath, namespace, keyValue string) (*everestv1alpha1.MonitoringConfigList, error)
- func PITRBucketName(db *everestv1alpha1.DatabaseCluster, bucket string) string
- func PITRStorageName(storageName string) string
- func ReconcileDBRestoreFromDataSource(ctx context.Context, c client.Client, ...) error
- func StatusAsPlainTextOrEmptyString(status interface{}) string
- func UpdateSecretData(ctx context.Context, c client.Client, ...) error
- func ValidatePitrRestoreSpec(dataSource everestv1alpha1.DataSource) error
- func VerifyPVCResizeFailure(ctx context.Context, c client.Client, name, namespace string) (bool, string, error)
Constants ¶
const ( // Kibibyte represents 1 KiB. Kibibyte = 1024 // Mebibyte represents 1 MiB. Mebibyte = 1024 * Kibibyte // DefaultPMMClientImage is the default image for PMM client. DefaultPMMClientImage = "percona/pmm-client:2" )
Variables ¶
var ( // PmmResourceRequirementsSmall is the resource requirements for PMM for small clusters. PmmResourceRequirementsSmall = corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceMemory: *resource.NewQuantity(97*Mebibyte+276*Kibibyte, resource.BinarySI), corev1.ResourceCPU: *resource.NewScaledQuantity(pmmClientRequestCPUSmall, resource.Milli), }, } // PmmResourceRequirementsMedium is the resource requirements for PMM for medium clusters. PmmResourceRequirementsMedium = corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceMemory: *resource.NewQuantity(194*Mebibyte+512*Kibibyte, resource.BinarySI), corev1.ResourceCPU: *resource.NewScaledQuantity(pmmClientRequestCPUMedium, resource.Milli), }, } // PmmResourceRequirementsLarge is the resource requirements for PMM for large clusters. PmmResourceRequirementsLarge = corev1.ResourceRequirements{ Requests: corev1.ResourceList{ corev1.ResourceMemory: *resource.NewQuantity(778*Mebibyte+235*Kibibyte, resource.BinarySI), corev1.ResourceCPU: *resource.NewScaledQuantity(pmmClientRequestCPULarge, resource.Milli), }, } )
var ( // ErrPitrTypeIsNotSupported is an error for unsupported PITR type. ErrPitrTypeIsNotSupported = errors.New("unknown PITR type") // ErrPitrTypeLatest is an error for 'latest' being an unsupported PITR type. ErrPitrTypeLatest = errors.New("'latest' type is not supported by Everest yet") // ErrPitrEmptyDate is an error for missing PITR date. ErrPitrEmptyDate = errors.New("no date provided for PITR of type 'date'") // ErrPSMDBOneStorageRestriction is an error for using more than one storage for psmdb clusters. ErrPSMDBOneStorageRestriction = errors.New("using more than one storage is not allowed for psmdb clusters") )
var DefaultNamespaceFilter predicate.Predicate = &predicates.Nop{}
DefaultNamespaceFilter is the default namespace filter.
var ErrEmptyLbc = errors.New("empty backup load balancer config")
ErrEmptyLbc error returned when no lbc name is definded in db.
Functions ¶
func BackupStoragePrefix ¶
func BackupStoragePrefix(db *everestv1alpha1.DatabaseCluster) string
BackupStoragePrefix returns the prefix for the backup storage.
func BackupStoragesThatReferenceObject ¶ added in v1.8.0
func BackupStoragesThatReferenceObject( ctx context.Context, c client.Client, keyPath, namespace, keyValue string, ) (*everestv1alpha1.BackupStorageList, error)
BackupStoragesThatReferenceObject returns a list of BackupStorages that reference the given name by the provided keyPath and namespace.
func CalculatePMMResources ¶ added in v1.9.0
func CalculatePMMResources(dbEnginSize everestv1alpha1.EngineSize) corev1.ResourceRequirements
CalculatePMMResources returns the resource requirements for PMM based on database engine size.
func ConfigureStorage ¶ added in v1.6.0
func ConfigureStorage( ctx context.Context, c client.Client, db *everestv1alpha1.DatabaseCluster, currentSize resource.Quantity, setStorageSizeFunc func(resource.Quantity), ) error
ConfigureStorage handles storage configuration and volume expansion checks for the given database cluster.
func CreateOrUpdate ¶
func CreateOrUpdate( ctx context.Context, c client.Client, obj client.Object, patchSecretData bool, ) error
CreateOrUpdate creates or updates a resource. With patchSecretData the new secret Data is applied on top of the original secret's Data.
func CreateOrUpdateSecretData ¶
func CreateOrUpdateSecretData( ctx context.Context, c client.Client, database *everestv1alpha1.DatabaseCluster, secretName string, data map[string][]byte, setControllerRef bool, ) error
CreateOrUpdateSecretData creates or updates the data of a secret. When updating, it only changes the values of the keys specified in the data map. All other keys are left untouched, so it's not possible to delete a key.
func DatabaseClusterBackupsThatReferenceObject ¶ added in v1.8.0
func DatabaseClusterBackupsThatReferenceObject( ctx context.Context, c client.Client, keyPath, namespace, keyValue string, ) (*everestv1alpha1.DatabaseClusterBackupList, error)
DatabaseClusterBackupsThatReferenceObject returns a list of DatabaseClusterBackups that reference the given name by the provided keyPath and namespace.
func DatabaseClusterRestoresThatReferenceObject ¶ added in v1.8.0
func DatabaseClusterRestoresThatReferenceObject( ctx context.Context, c client.Client, keyPath, namespace, keyValue string, ) (*everestv1alpha1.DatabaseClusterRestoreList, error)
DatabaseClusterRestoresThatReferenceObject returns a list of DatabaseClusterRestores that reference the given name by the provided keyPath and namespace.
func DatabaseClustersThatReferenceObject ¶ added in v1.7.0
func DatabaseClustersThatReferenceObject( ctx context.Context, c client.Client, keyPath, namespace, keyValue string, ) (*everestv1alpha1.DatabaseClusterList, error)
DatabaseClustersThatReferenceObject returns a list of DatabaseClusters that reference the given name by the provided keyPath and namespace.
func EnqueueObjectsInNamespace ¶
func EnqueueObjectsInNamespace(c client.Client, list client.ObjectList) handler.EventHandler
EnqueueObjectsInNamespace returns an event handler that should be attached with Namespace watchers. It enqueues all objects specified by the type of list in the triggered namespace.
func EnsureInUseFinalizer ¶ added in v1.8.0
EnsureInUseFinalizer ensures that the InUseResourceFinalizer is present or absent.
func GetAnnotations ¶ added in v1.9.0
func GetAnnotations( ctx context.Context, c client.Client, database *everestv1alpha1.DatabaseCluster, ) (map[string]string, error)
GetAnnotations returns annotations from the LoadBalancerConfig used in the given DB.
func GetBackupStorage ¶
func GetBackupStorage( ctx context.Context, c client.Client, name, namespace string, ) (*everestv1alpha1.BackupStorage, error)
GetBackupStorage returns a BackupStorage object with the specified name and namespace.
func GetClusterType ¶
GetClusterType returns the type of the cluster on which this operator is running.
func GetDBMonitoringConfig ¶
func GetDBMonitoringConfig( ctx context.Context, c client.Client, database *everestv1alpha1.DatabaseCluster, ) (*everestv1alpha1.MonitoringConfig, error)
GetDBMonitoringConfig returns the MonitoringConfig object for the given DatabaseCluster object.
func GetDataImportJobName ¶ added in v1.8.0
func GetDataImportJobName(db *everestv1alpha1.DatabaseCluster) string
GetDataImportJobName returns the name of the DataImport job for the given database cluster.
func GetDatabaseEngine ¶
func GetDatabaseEngine(ctx context.Context, c client.Client, name, namespace string) (*everestv1alpha1.DatabaseEngine, error)
GetDatabaseEngine gets the DatabaseEngine object with the specified name and namespace.
func GetLoadBalancerConfig ¶ added in v1.9.0
func GetLoadBalancerConfig( ctx context.Context, c client.Client, database *everestv1alpha1.DatabaseCluster, ) (*everestv1alpha1.LoadBalancerConfig, error)
GetLoadBalancerConfig returns the LoadBalancerConfig object for the given DatabaseCluster object.
func GetOperatorImage ¶
func GetOperatorImage( ctx context.Context, c client.Client, name types.NamespacedName, ) (string, error)
GetOperatorImage returns the image of the operator running in the cluster for the specified deployment name and namespace.
func GetOperatorVersion ¶
func GetOperatorVersion( ctx context.Context, c client.Client, name types.NamespacedName, ) (*version.Version, error)
GetOperatorVersion returns the version of the operator running in the cluster for the specified deployment name and namespace.
TODO: Read the operator version from the DatabaseEngine status rather than fetching the Deployment, since DatabaseEngines are cached in the controller's client.
func GetPodSchedulingPolicy ¶ added in v1.7.0
func GetPodSchedulingPolicy(ctx context.Context, c client.Client, pspName string) (*everestv1alpha1.PodSchedulingPolicy, error)
GetPodSchedulingPolicy returns the PodSchedulingPolicy object by name.
func GetRecommendedCRVersion ¶
func GetRecommendedCRVersion( ctx context.Context, c client.Client, operatorName string, db *everestv1alpha1.DatabaseCluster, ) (*string, error)
GetRecommendedCRVersion returns the recommended CR version for the operator.
func GetRepoNameByBackupStorage ¶
func GetRepoNameByBackupStorage( backupStorage *everestv1alpha1.BackupStorage, repos []crunchyv1beta1.PGBackRestRepo, ) string
GetRepoNameByBackupStorage returns the name of the repo that corresponds to the given backup storage.
func GetSecretFromMonitoringConfig ¶
func GetSecretFromMonitoringConfig( ctx context.Context, c client.Client, monitoring *everestv1alpha1.MonitoringConfig, ) (string, error)
GetSecretFromMonitoringConfig gets the secret data from the MonitoringConfig.
func HandleDBBackupsCleanup ¶
func HandleDBBackupsCleanup( ctx context.Context, c client.Client, database *everestv1alpha1.DatabaseCluster, ) (bool, error)
HandleDBBackupsCleanup handles the cleanup of the dbbackup objects. Returns true if cleanup is complete.
func HandleUpstreamClusterCleanup ¶
func HandleUpstreamClusterCleanup( ctx context.Context, c client.Client, database *everestv1alpha1.DatabaseCluster, upstream client.Object, ) (bool, error)
HandleUpstreamClusterCleanup handles the cleanup of the psdmb objects. Returns true if cleanup is complete.
func IsDatabaseClusterRestoreRunning ¶
func IsDatabaseClusterRestoreRunning( ctx context.Context, c client.Client, dbName, dbNs string, ) (bool, error)
IsDatabaseClusterRestoreRunning returns true if a restore is running for the specified database, otherwise false.
func IsNewDatabaseCluster ¶ added in v1.9.0
func IsNewDatabaseCluster(dbState everestv1alpha1.AppState) bool
IsNewDatabaseCluster returns true if the database is in a new or init state.
func IsOwnedBy ¶
IsOwnedBy checks if the child object is owned by the parent object. Returns true if child has an owner reference to the parents.
func MergeResources ¶ added in v1.9.0
func MergeResources(highPriorityResources, lowPriorityResources corev1.ResourceRequirements) corev1.ResourceRequirements
MergeResources merges highPriorityResources and lowPriorityResources. If a resource is specified in both, the value from highPriorityResources is used. If a resource is only specified in one, that value is used.
func MonitoringConfigsThatReferenceObject ¶ added in v1.8.0
func MonitoringConfigsThatReferenceObject( ctx context.Context, c client.Client, keyPath, namespace, keyValue string, ) (*everestv1alpha1.MonitoringConfigList, error)
MonitoringConfigsThatReferenceObject returns a list of MonitoringConfig that reference the given name by the provided keyPath and namespace.
func PITRBucketName ¶
func PITRBucketName(db *everestv1alpha1.DatabaseCluster, bucket string) string
PITRBucketName returns the name of the bucket for the point-in-time recovery backups.
func PITRStorageName ¶
PITRStorageName returns the name of the storage for the point-in-time recovery backups.
func ReconcileDBRestoreFromDataSource ¶
func ReconcileDBRestoreFromDataSource( ctx context.Context, c client.Client, database *everestv1alpha1.DatabaseCluster, ) error
ReconcileDBRestoreFromDataSource reconciles the DatabaseClusterRestore object based on the DataSource field of the DatabaseCluster.
func StatusAsPlainTextOrEmptyString ¶
func StatusAsPlainTextOrEmptyString(status interface{}) string
StatusAsPlainTextOrEmptyString returns the status as a plain text string or an empty string.
func UpdateSecretData ¶
func UpdateSecretData( ctx context.Context, c client.Client, database *everestv1alpha1.DatabaseCluster, secretName string, data map[string][]byte, setControllerRef bool, ) error
UpdateSecretData updates the data of a secret. It only changes the values of the keys specified in the data map. All other keys are left untouched, so it's not possible to delete a key.
func ValidatePitrRestoreSpec ¶
func ValidatePitrRestoreSpec(dataSource everestv1alpha1.DataSource) error
ValidatePitrRestoreSpec validates the PITR restore spec.
Types ¶
This section is empty.