kubernetes: k8s.io/kubernetes/test/e2e/framework/pv Index | Files

package framework

import "k8s.io/kubernetes/test/e2e/framework/pv"

Index

Package Files

pv.go

Constants

const (

    // PVBindingTimeout is how long PVs have to become bound.
    PVBindingTimeout = 3 * time.Minute

    // ClaimBindingTimeout is how long claims have to become bound.
    ClaimBindingTimeout = 3 * time.Minute

    // PVReclaimingTimeout is how long PVs have to beome reclaimed.
    PVReclaimingTimeout = 3 * time.Minute

    // PVDeletingTimeout is how long PVs have to become deleted.
    PVDeletingTimeout = 3 * time.Minute

    // VolumeSelectorKey is the key for volume selector.
    VolumeSelectorKey = "e2e-pv-pool"
)

Variables

var (
    // SELinuxLabel is common selinux labels.
    SELinuxLabel = &v1.SELinuxOptions{
        Level: "s0:c0,c1"}
)

func CreatePDWithRetry Uses

func CreatePDWithRetry() (string, error)

CreatePDWithRetry creates PD with retry.

func CreatePDWithRetryAndZone Uses

func CreatePDWithRetryAndZone(zone string) (string, error)

CreatePDWithRetryAndZone creates PD on zone with retry.

func CreatePV Uses

func CreatePV(c clientset.Interface, pv *v1.PersistentVolume) (*v1.PersistentVolume, error)

CreatePV creates the PV resource. Fails test on error.

func CreatePVC Uses

func CreatePVC(c clientset.Interface, ns string, pvc *v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error)

CreatePVC creates the PVC resource. Fails test on error.

func CreatePVCPV Uses

func CreatePVCPV(c clientset.Interface, pvConfig PersistentVolumeConfig, pvcConfig PersistentVolumeClaimConfig, ns string, preBind bool) (*v1.PersistentVolume, *v1.PersistentVolumeClaim, error)

CreatePVCPV creates a PVC followed by the PV based on the passed in nfs-server ip and namespace. If the "preBind" bool is true then pre-bind the PV to the PVC via the PV's ClaimRef. Return the pv and pvc to reflect the created objects. Note: in the pre-bind case the real PVC name, which is generated, is not

known until after the PVC is instantiated. This is why the pvc is created
before the pv.

func CreatePVPVC Uses

func CreatePVPVC(c clientset.Interface, pvConfig PersistentVolumeConfig, pvcConfig PersistentVolumeClaimConfig, ns string, preBind bool) (*v1.PersistentVolume, *v1.PersistentVolumeClaim, error)

CreatePVPVC creates a PV followed by the PVC based on the passed in nfs-server ip and namespace. If the "preBind" bool is true then pre-bind the PVC to the PV via the PVC's VolumeName. Return the pv and pvc to reflect the created objects. Note: in the pre-bind case the real PV name, which is generated, is not

known until after the PV is instantiated. This is why the pv is created
before the pvc.

func CreatePVSource Uses

func CreatePVSource(zone string) (*v1.PersistentVolumeSource, error)

CreatePVSource creates a PV source.

func CreatePVsPVCs Uses

func CreatePVsPVCs(numpvs, numpvcs int, c clientset.Interface, ns string, pvConfig PersistentVolumeConfig, pvcConfig PersistentVolumeClaimConfig) (PVMap, PVCMap, error)

CreatePVsPVCs creates the desired number of PVs and PVCs and returns them in separate maps. If the number of PVs != the number of PVCs then the min of those two counts is the number of PVs expected to bind. If a Create error occurs, the returned maps may contain pv and pvc entries for the resources that were successfully created. In other words, when the caller sees an error returned, it needs to decide what to do about entries in the maps. Note: when the test suite deletes the namespace orphaned pvcs and pods are deleted. However,

orphaned pvs are not deleted and will remain after the suite completes.

func DeletePDWithRetry Uses

func DeletePDWithRetry(diskName string) error

DeletePDWithRetry deletes PD with retry.

func DeletePVCandValidatePV Uses

func DeletePVCandValidatePV(c clientset.Interface, ns string, pvc *v1.PersistentVolumeClaim, pv *v1.PersistentVolume, expectPVPhase v1.PersistentVolumePhase) error

DeletePVCandValidatePV deletes the PVC and waits for the PV to enter its expected phase. Validate that the PV has been reclaimed (assumption here about reclaimPolicy). Caller tells this func which phase value to expect for the pv bound to the to-be-deleted claim.

func DeletePVCandValidatePVGroup Uses

func DeletePVCandValidatePVGroup(c clientset.Interface, ns string, pvols PVMap, claims PVCMap, expectPVPhase v1.PersistentVolumePhase) error

DeletePVCandValidatePVGroup wraps deletePVCandValidatePV() by calling the function in a loop over the PV map. Only bound PVs are deleted. Validates that the claim was deleted and the PV is in the expected Phase (Released, Available, Bound). Note: if there are more claims than pvs then some of the remaining claims may bind to just made

available pvs.

func DeletePVSource Uses

func DeletePVSource(pvSource *v1.PersistentVolumeSource) error

DeletePVSource deletes a PV source.

func DeletePersistentVolume Uses

func DeletePersistentVolume(c clientset.Interface, pvName string) error

DeletePersistentVolume deletes the PV.

func DeletePersistentVolumeClaim Uses

func DeletePersistentVolumeClaim(c clientset.Interface, pvcName string, ns string) error

DeletePersistentVolumeClaim deletes the Claim.

func GetBoundPV Uses

func GetBoundPV(client clientset.Interface, pvc *v1.PersistentVolumeClaim) (*v1.PersistentVolume, error)

GetBoundPV returns a PV details.

func GetDefaultStorageClassName Uses

func GetDefaultStorageClassName(c clientset.Interface) (string, error)

GetDefaultStorageClassName returns default storageClass or return error

func MakePersistentVolume Uses

func MakePersistentVolume(pvConfig PersistentVolumeConfig) *v1.PersistentVolume

MakePersistentVolume returns a PV definition based on the nfs server IP. If the PVC is not nil then the PV is defined with a ClaimRef which includes the PVC's namespace. If the PVC is nil then the PV is not defined with a ClaimRef. If no reclaimPolicy is assigned, assumes "Retain". Specs are expected to match the test's PVC. Note: the passed-in claim does not have a name until it is created and thus the PV's

ClaimRef cannot be completely filled-in in this func. Therefore, the ClaimRef's name
is added later in CreatePVCPV.

func MakePersistentVolumeClaim Uses

func MakePersistentVolumeClaim(cfg PersistentVolumeClaimConfig, ns string) *v1.PersistentVolumeClaim

MakePersistentVolumeClaim returns a PVC API Object based on the PersistentVolumeClaimConfig.

func MakeWritePod Uses

func MakeWritePod(ns string, pvc *v1.PersistentVolumeClaim) *v1.Pod

MakeWritePod returns a pod definition based on the namespace. The pod references the PVC's name.

func PVPVCCleanup Uses

func PVPVCCleanup(c clientset.Interface, ns string, pv *v1.PersistentVolume, pvc *v1.PersistentVolumeClaim) []error

PVPVCCleanup cleans up a pv and pvc in a single pv/pvc test case. Note: delete errors are appended to []error so that we can attempt to delete both the pvc and pv.

func PVPVCMapCleanup Uses

func PVPVCMapCleanup(c clientset.Interface, ns string, pvols PVMap, claims PVCMap) []error

PVPVCMapCleanup Cleans up pvs and pvcs in multi-pv-pvc test cases. Entries found in the pv and claim maps are deleted as long as the Delete api call succeeds. Note: delete errors are appended to []error so that as many pvcs and pvs as possible are deleted.

func SkipIfNoDefaultStorageClass Uses

func SkipIfNoDefaultStorageClass(c clientset.Interface)

SkipIfNoDefaultStorageClass skips tests if no default SC can be found.

func WaitAndVerifyBinds Uses

func WaitAndVerifyBinds(c clientset.Interface, ns string, pvols PVMap, claims PVCMap, testExpected bool) error

WaitAndVerifyBinds searches for bound PVs and PVCs by examining pvols for non-nil claimRefs. NOTE: Each iteration waits for a maximum of 3 minutes per PV and, if the PV is bound,

up to 3 minutes for the PVC. When the number of PVs != number of PVCs, this can lead
to situations where the maximum wait times are reached several times in succession,
extending test time. Thus, it is recommended to keep the delta between PVs and PVCs
small.

func WaitForPVClaimBoundPhase Uses

func WaitForPVClaimBoundPhase(client clientset.Interface, pvclaims []*v1.PersistentVolumeClaim, timeout time.Duration) ([]*v1.PersistentVolume, error)

WaitForPVClaimBoundPhase waits until all pvcs phase set to bound

func WaitForPersistentVolumeClaimPhase Uses

func WaitForPersistentVolumeClaimPhase(phase v1.PersistentVolumeClaimPhase, c clientset.Interface, ns string, pvcName string, Poll, timeout time.Duration) error

WaitForPersistentVolumeClaimPhase waits for a PersistentVolumeClaim to be in a specific phase or until timeout occurs, whichever comes first.

func WaitForPersistentVolumeClaimsPhase Uses

func WaitForPersistentVolumeClaimsPhase(phase v1.PersistentVolumeClaimPhase, c clientset.Interface, ns string, pvcNames []string, Poll, timeout time.Duration, matchAny bool) error

WaitForPersistentVolumeClaimsPhase waits for any (if matchAny is true) or all (if matchAny is false) PersistentVolumeClaims to be in a specific phase or until timeout occurs, whichever comes first.

func WaitForPersistentVolumePhase Uses

func WaitForPersistentVolumePhase(phase v1.PersistentVolumePhase, c clientset.Interface, pvName string, Poll, timeout time.Duration) error

WaitForPersistentVolumePhase waits for a PersistentVolume to be in a specific phase or until timeout occurs, whichever comes first.

func WaitOnPVandPVC Uses

func WaitOnPVandPVC(c clientset.Interface, ns string, pv *v1.PersistentVolume, pvc *v1.PersistentVolumeClaim) error

WaitOnPVandPVC waits for the pv and pvc to bind to each other.

type PVCMap Uses

type PVCMap map[types.NamespacedName]pvcval

PVCMap is a map of all PVCs used in the multi pv-pvc tests. The key is "namespace/pvc.Name". The value is {} (empty struct) since we're only interested in the PVC's name and if it is present. We must always Get the pvc object before referencing any of its values, eg. its VolumeName. Note: It's unsafe to add keys to a map in a loop. Their insertion in the map is

unpredictable and can result in the same key being iterated over again.

type PVMap Uses

type PVMap map[string]pvval

PVMap is a map of all PVs used in the multi pv-pvc tests. The key is the PV's name, which is guaranteed to be unique. The value is {} (empty struct) since we're only interested in the PV's name and if it is present. We must always Get the pv object before referencing any of its values, eg its ClaimRef.

type PersistentVolumeClaimConfig Uses

type PersistentVolumeClaimConfig struct {
    // NamePrefix defaults to "pvc-" if unspecified
    NamePrefix string
    // ClaimSize must be specified in the Quantity format. Defaults to 2Gi if
    // unspecified
    ClaimSize string
    // AccessModes defaults to RWO if unspecified
    AccessModes      []v1.PersistentVolumeAccessMode
    Annotations      map[string]string
    Selector         *metav1.LabelSelector
    StorageClassName *string
    // VolumeMode defaults to nil if unspecified or specified as the empty
    // string
    VolumeMode *v1.PersistentVolumeMode
}

PersistentVolumeClaimConfig is consumed by MakePersistentVolumeClaim() to generate a PVC object.

type PersistentVolumeConfig Uses

type PersistentVolumeConfig struct {
    // [Optional] NamePrefix defaults to "pv-" if unset
    NamePrefix string
    // [Optional] Labels contains information used to organize and categorize
    // objects
    Labels labels.Set
    // PVSource contains the details of the underlying volume and must be set
    PVSource v1.PersistentVolumeSource
    // [Optional] Prebind lets you specify a PVC to bind this PV to before
    // creation
    Prebind *v1.PersistentVolumeClaim
    // [Optiona] ReclaimPolicy defaults to "Reclaim" if unset
    ReclaimPolicy    v1.PersistentVolumeReclaimPolicy
    StorageClassName string
    // [Optional] NodeAffinity defines constraints that limit what nodes this
    // volume can be accessed from.
    NodeAffinity *v1.VolumeNodeAffinity
    // [Optional] VolumeMode defaults to "Filesystem" if unset
    VolumeMode *v1.PersistentVolumeMode
    // [Optional] AccessModes defaults to RWO if unset
    AccessModes []v1.PersistentVolumeAccessMode
    // [Optional] Capacity is the storage capacity in Quantity format. Defaults
    // to "2Gi" if unset
    Capacity string
}

PersistentVolumeConfig is consumed by MakePersistentVolume() to generate a PV object for varying storage options (NFS, ceph, glusterFS, etc.). (+optional) prebind holds a pre-bound PVC Example pvSource:

pvSource: api.PersistentVolumeSource{
	NFS: &api.NFSVolumeSource{
 		...
 	},
 }

Package framework imports 15 packages (graph) and is imported by 77 packages. Updated 2019-09-19. Refresh now. Tools for package owners.