persistentvolumeclaim

package
v1.18.3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package persistentvolumeclaim contains all the logic to reconcile and build PVCS

Index

Constants

This section is empty.

Variables

View Source
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 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 EnrichStatus

func EnrichStatus(
	ctx context.Context,
	cluster *apiv1.Cluster,
	podList []corev1.Pod,
	jobList []batchv1.Job,
	pvcList []corev1.PersistentVolumeClaim,
)

EnrichStatus obtains and classifies the current status of each managed PVC

func FilterByInstance

func FilterByInstance(
	pvcs []corev1.PersistentVolumeClaim,
	instanceSpec corev1.PodSpec,
) []corev1.PersistentVolumeClaim

FilterByInstance returns all the corev1.PersistentVolumeClaim that are used inside the podSpec

func GetName

func GetName(cluster *apiv1.Cluster, instanceName string, role utils.PVCRole) string

GetName builds the name for a given PVC of the instance

func IsUsedByInstance

func IsUsedByInstance(cluster *apiv1.Cluster, instanceName, resourceName string) bool

IsUsedByInstance returns a boolean indicating if that given PVC belongs to an instance

func IsUsedByPodSpec

func IsUsedByPodSpec(podSpec corev1.PodSpec, pvcNames ...string) bool

IsUsedByPodSpec checks if the given pod spec is using the PVCs

func ReconcileExistingResources

func ReconcileExistingResources(
	ctx context.Context,
	c client.Client,
	cluster *apiv1.Cluster,
	instances []corev1.Pod,
	pvcs []corev1.PersistentVolumeClaim,
) (ctrl.Result, error)

ReconcileExistingResources reconciles the PVC already created TODO: in future it should also create the PVCs

Types

type CreateConfiguration

type CreateConfiguration struct {
	Status     PVCStatus
	NodeSerial int
	Role       utils.PVCRole
	Storage    apiv1.StorageConfiguration
}

CreateConfiguration specifies how a PVC should be created

type PVCStatus

type PVCStatus = string

PVCStatus describes the PVC phase

const (
	// StatusAnnotationName is an annotation that shows the current status of the PVC.
	// The status can be "initializing", "ready" or "detached"
	StatusAnnotationName = specs.MetadataNamespace + "/pvcStatus"

	// 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"
)

Jump to

Keyboard shortcuts

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