Documentation ¶
Overview ¶
Package persistentvolumeclaim contains all the logic to reconcile and build PVCS
Index ¶
- Variables
- func BelongToInstance(cluster *apiv1.Cluster, instanceName, pvcName string) bool
- func Build(cluster *apiv1.Cluster, configuration *CreateConfiguration) (*corev1.PersistentVolumeClaim, error)
- func CreateInstancePVCs(ctx context.Context, c client.Client, cluster *apiv1.Cluster, ...) error
- func EnrichStatus(ctx context.Context, cluster *apiv1.Cluster, runningInstances []corev1.Pod, ...)
- func EnsureInstancePVCGroupIsDeleted(ctx context.Context, c client.Client, cluster *apiv1.Cluster, name string, ...) error
- func FilterByPodSpec(pvcs []corev1.PersistentVolumeClaim, instanceSpec corev1.PodSpec) []corev1.PersistentVolumeClaim
- func GetInstancePVCs(ctx context.Context, cli client.Client, instanceName string, namespace string) ([]corev1.PersistentVolumeClaim, error)
- func GetSourceMetadataOrNil(ctx context.Context, c client.Client, namespace string, ...) (*metav1.ObjectMeta, error)
- func InstanceHasMissingMounts(cluster *apiv1.Cluster, instance *corev1.Pod) bool
- func IsUsedByPodSpec(podSpec corev1.PodSpec, pvcNames ...string) bool
- func Reconcile(ctx context.Context, c client.Client, cluster *apiv1.Cluster, ...) (ctrl.Result, error)
- func ReconcileMetadata(ctx context.Context, c client.Client, cluster *apiv1.Cluster, ...) error
- func ReconcileSerialAnnotation(ctx context.Context, c client.Client, cluster *apiv1.Cluster, ...) error
- type Backup
- type Bootstrap
- type Configuration
- type CreateConfiguration
- type ExpectedObjectCalculator
- type Meta
- type PVCStatus
- type StorageSource
- type ValidationMessage
- type ValidationStatus
Constants ¶
This section is empty.
Variables ¶
var ErrorInvalidSize = fmt.Errorf("invalid storage size")
ErrorInvalidSize is raised when the size specified by the user is not valid and can't be specified in a PVC declaration
Functions ¶
func BelongToInstance ¶ added in v1.18.4
BelongToInstance returns a boolean indicating if that given PVC belongs to an instance
func Build ¶
func Build( cluster *apiv1.Cluster, configuration *CreateConfiguration, ) (*corev1.PersistentVolumeClaim, error)
Build spec of a PVC, given its name and the storage configuration TODO: this logic eventually should be moved inside reconcile
func CreateInstancePVCs ¶ added in v1.18.4
func CreateInstancePVCs( ctx context.Context, c client.Client, cluster *apiv1.Cluster, source *StorageSource, serial int, ) error
CreateInstancePVCs creates the expected pvcs for the instance
func EnrichStatus ¶
func EnrichStatus( ctx context.Context, cluster *apiv1.Cluster, runningInstances []corev1.Pod, jobs []batchv1.Job, managedPVCs []corev1.PersistentVolumeClaim, )
EnrichStatus obtains and classifies the current status of each managed PVC
func EnsureInstancePVCGroupIsDeleted ¶ added in v1.18.4
func EnsureInstancePVCGroupIsDeleted( ctx context.Context, c client.Client, cluster *apiv1.Cluster, name string, namespace string, ) error
EnsureInstancePVCGroupIsDeleted ensures that all the expected pvc for a given instance are deleted
func FilterByPodSpec ¶ added in v1.18.4
func FilterByPodSpec( pvcs []corev1.PersistentVolumeClaim, instanceSpec corev1.PodSpec, ) []corev1.PersistentVolumeClaim
FilterByPodSpec returns all the corev1.PersistentVolumeClaim that are used inside the podSpec
func GetInstancePVCs ¶ added in v1.21.0
func GetInstancePVCs( ctx context.Context, cli client.Client, instanceName string, namespace string, ) ([]corev1.PersistentVolumeClaim, error)
GetInstancePVCs gets all the PVC associated with a given instance
func GetSourceMetadataOrNil ¶ added in v1.22.5
func GetSourceMetadataOrNil( ctx context.Context, c client.Client, namespace string, typedSource corev1.TypedLocalObjectReference, ) (*metav1.ObjectMeta, error)
GetSourceMetadataOrNil gets snapshot metadata from a specified source. If the source doesn't exist, returns nil
func InstanceHasMissingMounts ¶ added in v1.18.4
InstanceHasMissingMounts returns true if the instance has expected PVCs that are not mounted
func IsUsedByPodSpec ¶
IsUsedByPodSpec checks if the given pod spec is using the PVCs
func Reconcile ¶ added in v1.18.4
func Reconcile( ctx context.Context, c client.Client, cluster *apiv1.Cluster, instances []corev1.Pod, pvcs []corev1.PersistentVolumeClaim, ) (ctrl.Result, error)
Reconcile reconciles the PVCs
func ReconcileMetadata ¶ added in v1.21.4
func ReconcileMetadata( ctx context.Context, c client.Client, cluster *apiv1.Cluster, pvcs []corev1.PersistentVolumeClaim, ) error
ReconcileMetadata a ensures that the pvc metadata is kept up to date
func ReconcileSerialAnnotation ¶ added in v1.21.4
func ReconcileSerialAnnotation( ctx context.Context, c client.Client, cluster *apiv1.Cluster, runningInstances []corev1.Pod, pvcs []corev1.PersistentVolumeClaim, ) error
ReconcileSerialAnnotation ensures that all the PVCs have the correct serial annotation
Types ¶
type Backup ¶ added in v1.22.0
type Backup interface { // GetSnapshotName gets the snapshot name for a certain PVC GetSnapshotName(backupName string) string // GetVolumeSnapshotClass will return the volume snapshot class to be used // when snapshotting a PVC with this Role. GetVolumeSnapshotClass(configuration *apiv1.VolumeSnapshotConfiguration) *string }
Backup is an object capable of describing the backup behaviour of a pvc
type Bootstrap ¶ added in v1.22.0
type Bootstrap interface { // GetInitialStatus returns the status the PVC should be first created with GetInitialStatus() PVCStatus }
Bootstrap is an object capable of describing the starting status of a pvc
type Configuration ¶ added in v1.22.0
type Configuration interface { // GetStorageConfiguration will return the storage configuration to be used // for this PVC role and this cluster GetStorageConfiguration(cluster *apiv1.Cluster) (apiv1.StorageConfiguration, error) // GetSource gets the PVC source to be used when creating a new PVC GetSource(source *StorageSource) (*corev1.TypedLocalObjectReference, error) }
Configuration is an object capable of describing the configuration of a pvc
type CreateConfiguration ¶
type CreateConfiguration struct { Status PVCStatus NodeSerial int Calculator ExpectedObjectCalculator TablespaceName string Storage apiv1.StorageConfiguration Source *corev1.TypedLocalObjectReference }
CreateConfiguration specifies how a PVC should be created
type ExpectedObjectCalculator ¶ added in v1.22.0
type ExpectedObjectCalculator interface { Bootstrap Backup Configuration Meta }
ExpectedObjectCalculator returns the data needed for a given pvc
func GetExpectedObjectCalculator ¶ added in v1.22.0
func GetExpectedObjectCalculator(labels map[string]string) (ExpectedObjectCalculator, error)
GetExpectedObjectCalculator return an object capable of determining a series of data for the given pvc
func NewPgDataCalculator ¶ added in v1.22.0
func NewPgDataCalculator() ExpectedObjectCalculator
NewPgDataCalculator returns a ExpectedObjectCalculator for a PVC of PG_DATA type
func NewPgTablespaceCalculator ¶ added in v1.22.0
func NewPgTablespaceCalculator(tbsName string) ExpectedObjectCalculator
NewPgTablespaceCalculator returns a ExpectedObjectCalculator for a PVC of PG_TABLESPACE type
func NewPgWalCalculator ¶ added in v1.22.0
func NewPgWalCalculator() ExpectedObjectCalculator
NewPgWalCalculator returns a ExpectedObjectCalculator for a PVC of PG_WAL type
type Meta ¶ added in v1.22.0
type Meta interface { // GetName will be used to get the name of the PVC GetName(instanceName string) string // GetLabels will be used as the label value GetLabels(instanceName string) map[string]string // GetRoleName return the role name in string GetRoleName() string }
Meta is an object capable of describing the metadata of a pvc
type PVCStatus ¶
type PVCStatus = string
PVCStatus describes the PVC phase
const ( // StatusInitializing is the annotation value for PVC initializing status StatusInitializing PVCStatus = "initializing" // StatusReady is the annotation value for PVC ready status StatusReady PVCStatus = "ready" // StatusDetached is the annotation value for PVC detached status StatusDetached PVCStatus = "detached" )
type StorageSource ¶ added in v1.21.0
type StorageSource struct { // The data source that should be used for PGDATA DataSource corev1.TypedLocalObjectReference `json:"dataSource"` // The (optional) data source that should be used for WALs WALSource *corev1.TypedLocalObjectReference `json:"walSource"` // The (optional) data source that should be used for TABLESPACE TablespaceSource map[string]corev1.TypedLocalObjectReference `json:"tablespaceSource"` }
StorageSource the storage source to be used when creating a set of PVCs
func GetCandidateStorageSourceForPrimary ¶ added in v1.21.0
func GetCandidateStorageSourceForPrimary( cluster *apiv1.Cluster, backup *apiv1.Backup, ) *StorageSource
GetCandidateStorageSourceForPrimary gets the candidate storage source to be used to create a primary PVC
func GetCandidateStorageSourceForReplica ¶ added in v1.21.0
func GetCandidateStorageSourceForReplica( ctx context.Context, cluster *apiv1.Cluster, backupList apiv1.BackupList, ) *StorageSource
GetCandidateStorageSourceForReplica gets the candidate storage source to be used to create a replica PVC
type ValidationMessage ¶ added in v1.21.1
type ValidationMessage struct { ObjectName string `json:"objectName"` Message string `json:"message"` }
ValidationMessage is a message about a snapshot
type ValidationStatus ¶ added in v1.21.1
type ValidationStatus struct { // Errors is the list of blocking errors Errors []ValidationMessage `json:"errors"` // Warnings is the list of warnings that are not blocking Warnings []ValidationMessage `json:"warnings"` }
ValidationStatus is the result of the validation of a cluster datasource
func VerifyDataSourceCoherence ¶ added in v1.21.1
func VerifyDataSourceCoherence( ctx context.Context, c client.Client, namespace string, source *apiv1.DataSource, ) (ValidationStatus, error)
VerifyDataSourceCoherence verifies if the specified data source that we should use when creating a new cluster is coherent. We check for:
role of the volume snapshot is coherent with the requested section (being storage or walStorage)
the specified snapshots all belong to the same cluster and backupName
func (*ValidationStatus) ContainsErrors ¶ added in v1.21.1
func (status *ValidationStatus) ContainsErrors() bool
ContainsErrors returns true if the validation result has any blocking errors.
func (*ValidationStatus) ContainsWarnings ¶ added in v1.21.1
func (status *ValidationStatus) ContainsWarnings() bool
ContainsWarnings returns true if there are any validation warnings.