Documentation ¶
Index ¶
- Constants
- Variables
- func CreatePDWithRetry() (string, error)
- func CreatePDWithRetryAndZone(zone string) (string, error)
- func CreatePV(c clientset.Interface, timeouts *framework.TimeoutContext, ...) (*v1.PersistentVolume, error)
- func CreatePVC(c clientset.Interface, ns string, pvc *v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error)
- func CreatePVCPV(c clientset.Interface, timeouts *framework.TimeoutContext, ...) (*v1.PersistentVolume, *v1.PersistentVolumeClaim, error)
- func CreatePVPVC(c clientset.Interface, timeouts *framework.TimeoutContext, ...) (*v1.PersistentVolume, *v1.PersistentVolumeClaim, error)
- func CreatePVSource(zone string) (*v1.PersistentVolumeSource, error)
- func CreatePVsPVCs(numpvs, numpvcs int, c clientset.Interface, timeouts *framework.TimeoutContext, ...) (PVMap, PVCMap, error)
- func DeletePDWithRetry(diskName string) error
- func DeletePVCandValidatePV(c clientset.Interface, timeouts *framework.TimeoutContext, ns string, ...) error
- func DeletePVCandValidatePVGroup(c clientset.Interface, timeouts *framework.TimeoutContext, ns string, ...) error
- func DeletePVSource(pvSource *v1.PersistentVolumeSource) error
- func DeletePersistentVolume(c clientset.Interface, pvName string) error
- func DeletePersistentVolumeClaim(c clientset.Interface, pvcName string, ns string) error
- func GetDefaultFSType() string
- func GetDefaultStorageClassName(c clientset.Interface) (string, error)
- func MakePersistentVolume(pvConfig PersistentVolumeConfig) *v1.PersistentVolume
- func MakePersistentVolumeClaim(cfg PersistentVolumeClaimConfig, ns string) *v1.PersistentVolumeClaim
- func PVPVCCleanup(c clientset.Interface, ns string, pv *v1.PersistentVolume, ...) []error
- func PVPVCMapCleanup(c clientset.Interface, ns string, pvols PVMap, claims PVCMap) []error
- func SkipIfNoDefaultStorageClass(c clientset.Interface)
- func WaitAndVerifyBinds(c clientset.Interface, timeouts *framework.TimeoutContext, ns string, ...) error
- func WaitForPVCFinalizer(ctx context.Context, cs clientset.Interface, name, namespace, finalizer string, ...) error
- func WaitForPVClaimBoundPhase(client clientset.Interface, pvclaims []*v1.PersistentVolumeClaim, ...) ([]*v1.PersistentVolume, error)
- func WaitForPersistentVolumeClaimPhase(phase v1.PersistentVolumeClaimPhase, c clientset.Interface, ns string, ...) error
- func WaitForPersistentVolumeClaimsPhase(phase v1.PersistentVolumeClaimPhase, c clientset.Interface, ns string, ...) error
- func WaitForPersistentVolumeDeleted(c clientset.Interface, pvName string, poll, timeout time.Duration) error
- func WaitForPersistentVolumePhase(phase v1.PersistentVolumePhase, c clientset.Interface, pvName string, ...) error
- func WaitOnPVandPVC(c clientset.Interface, timeouts *framework.TimeoutContext, ns string, ...) error
- type PVCMap
- type PVMap
- type PersistentVolumeClaimConfig
- type PersistentVolumeConfig
Constants ¶
const (
// 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"} )
Functions ¶
func CreatePDWithRetry ¶
CreatePDWithRetry creates PD with retry.
func CreatePDWithRetryAndZone ¶
CreatePDWithRetryAndZone creates PD on zone with retry.
func CreatePV ¶
func CreatePV(c clientset.Interface, timeouts *framework.TimeoutContext, pv *v1.PersistentVolume) (*v1.PersistentVolume, error)
CreatePV creates the PV resource. Fails test on error.
func CreatePVC ¶
func CreatePVC(c clientset.Interface, ns string, pvc *v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error)
CreatePVC creates the PVC resource. Fails test on error.
func CreatePVCPV ¶
func CreatePVCPV(c clientset.Interface, timeouts *framework.TimeoutContext, 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 ¶
func CreatePVPVC(c clientset.Interface, timeouts *framework.TimeoutContext, 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 ¶
func CreatePVSource(zone string) (*v1.PersistentVolumeSource, error)
CreatePVSource creates a PV source.
func CreatePVsPVCs ¶
func CreatePVsPVCs(numpvs, numpvcs int, c clientset.Interface, timeouts *framework.TimeoutContext, 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 ¶
DeletePDWithRetry deletes PD with retry.
func DeletePVCandValidatePV ¶
func DeletePVCandValidatePV(c clientset.Interface, timeouts *framework.TimeoutContext, 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 ¶
func DeletePVCandValidatePVGroup(c clientset.Interface, timeouts *framework.TimeoutContext, 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 ¶
func DeletePVSource(pvSource *v1.PersistentVolumeSource) error
DeletePVSource deletes a PV source.
func DeletePersistentVolume ¶
DeletePersistentVolume deletes the PV.
func DeletePersistentVolumeClaim ¶
DeletePersistentVolumeClaim deletes the Claim.
func GetDefaultFSType ¶ added in v1.21.0
func GetDefaultFSType() string
GetDefaultFSType returns the default fsType
func GetDefaultStorageClassName ¶
GetDefaultStorageClassName returns default storageClass or return error
func MakePersistentVolume ¶
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 ¶
func MakePersistentVolumeClaim(cfg PersistentVolumeClaimConfig, ns string) *v1.PersistentVolumeClaim
MakePersistentVolumeClaim returns a PVC API Object based on the PersistentVolumeClaimConfig.
func PVPVCCleanup ¶
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 ¶
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 ¶
SkipIfNoDefaultStorageClass skips tests if no default SC can be found.
func WaitAndVerifyBinds ¶
func WaitAndVerifyBinds(c clientset.Interface, timeouts *framework.TimeoutContext, 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 WaitForPVCFinalizer ¶ added in v1.20.0
func WaitForPVCFinalizer(ctx context.Context, cs clientset.Interface, name, namespace, finalizer string, poll, timeout time.Duration) error
WaitForPVCFinalizer waits for a finalizer to be added to a PVC in a given namespace.
func WaitForPVClaimBoundPhase ¶
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 ¶
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 ¶
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 WaitForPersistentVolumeDeleted ¶ added in v1.19.0
func WaitForPersistentVolumeDeleted(c clientset.Interface, pvName string, poll, timeout time.Duration) error
WaitForPersistentVolumeDeleted waits for a PersistentVolume to get deleted or until timeout occurs, whichever comes first.
func WaitForPersistentVolumePhase ¶
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 ¶
func WaitOnPVandPVC(c clientset.Interface, timeouts *framework.TimeoutContext, ns string, pv *v1.PersistentVolume, pvc *v1.PersistentVolumeClaim) error
WaitOnPVandPVC waits for the pv and pvc to bind to each other.
Types ¶
type PVCMap ¶
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 ¶
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 ¶
type PersistentVolumeClaimConfig struct { // Name of the PVC. If set, overrides NamePrefix Name string // 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 ¶
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{ ... }, }