const pdRetryTimeout … const pdRetryPollTime … const VolumeSelectorKey … const volumeGidAnnotationKey … var SELinuxLabel … type pvval … type PVMap … type pvcval … type PVCMap … type PersistentVolumeConfig … type PersistentVolumeClaimConfig … // 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 PVPVCCleanup(ctx context.Context, c clientset.Interface, ns string, pv *v1.PersistentVolume, pvc *v1.PersistentVolumeClaim) []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 PVPVCMapCleanup(ctx context.Context, c clientset.Interface, ns string, pvols PVMap, claims PVCMap) []error { … } // DeletePersistentVolume deletes the PV. func DeletePersistentVolume(ctx context.Context, c clientset.Interface, pvName string) error { … } // DeletePersistentVolumeClaim deletes the Claim. func DeletePersistentVolumeClaim(ctx context.Context, c clientset.Interface, pvcName string, ns string) 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 DeletePVCandValidatePV(ctx context.Context, c clientset.Interface, timeouts *framework.TimeoutContext, ns string, pvc *v1.PersistentVolumeClaim, pv *v1.PersistentVolume, 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 DeletePVCandValidatePVGroup(ctx context.Context, c clientset.Interface, timeouts *framework.TimeoutContext, ns string, pvols PVMap, claims PVCMap, expectPVPhase v1.PersistentVolumePhase) error { … } // create the PV resource. Fails test on error. func createPV(ctx context.Context, c clientset.Interface, timeouts *framework.TimeoutContext, pv *v1.PersistentVolume) (*v1.PersistentVolume, error) { … } // CreatePV creates the PV resource. Fails test on error. func CreatePV(ctx context.Context, c clientset.Interface, timeouts *framework.TimeoutContext, pv *v1.PersistentVolume) (*v1.PersistentVolume, error) { … } // CreatePVC creates the PVC resource. Fails test on error. func CreatePVC(ctx context.Context, c clientset.Interface, ns string, pvc *v1.PersistentVolumeClaim) (*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 CreatePVCPV(ctx context.Context, 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 CreatePVPVC(ctx context.Context, c clientset.Interface, timeouts *framework.TimeoutContext, pvConfig PersistentVolumeConfig, pvcConfig PersistentVolumeClaimConfig, ns string, preBind bool) (*v1.PersistentVolume, *v1.PersistentVolumeClaim, 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 CreatePVsPVCs(ctx context.Context, numpvs, numpvcs int, c clientset.Interface, timeouts *framework.TimeoutContext, ns string, pvConfig PersistentVolumeConfig, pvcConfig PersistentVolumeClaimConfig) (PVMap, PVCMap, error) { … } // WaitOnPVandPVC waits for the pv and pvc to bind to each other. func WaitOnPVandPVC(ctx context.Context, c clientset.Interface, timeouts *framework.TimeoutContext, ns string, pv *v1.PersistentVolume, pvc *v1.PersistentVolumeClaim) 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 WaitAndVerifyBinds(ctx context.Context, c clientset.Interface, timeouts *framework.TimeoutContext, ns string, pvols PVMap, claims PVCMap, testExpected bool) error { … } // Return a pvckey struct. func makePvcKey(ns, name string) types.NamespacedName { … } // 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 MakePersistentVolume(pvConfig PersistentVolumeConfig) *v1.PersistentVolume { … } // MakePersistentVolumeClaim returns a PVC API Object based on the PersistentVolumeClaimConfig. func MakePersistentVolumeClaim(cfg PersistentVolumeClaimConfig, ns string) *v1.PersistentVolumeClaim { … } func createPDWithRetry(ctx context.Context, zone string) (string, error) { … } func CreateShare() (string, string, string, error) { … } func DeleteShare(accountName, shareName string) error { … } // CreatePDWithRetry creates PD with retry. func CreatePDWithRetry(ctx context.Context) (string, error) { … } // CreatePDWithRetryAndZone creates PD on zone with retry. func CreatePDWithRetryAndZone(ctx context.Context, zone string) (string, error) { … } // DeletePDWithRetry deletes PD with retry. func DeletePDWithRetry(ctx context.Context, diskName string) error { … } func createPD(zone string) (string, error) { … } func deletePD(pdName string) error { … } // WaitForPVClaimBoundPhase waits until all pvcs phase set to bound func WaitForPVClaimBoundPhase(ctx context.Context, client clientset.Interface, pvclaims []*v1.PersistentVolumeClaim, timeout time.Duration) ([]*v1.PersistentVolume, error) { … } // WaitForPersistentVolumePhase waits for a PersistentVolume to be in a specific phase or until timeout occurs, whichever comes first. func WaitForPersistentVolumePhase(ctx context.Context, phase v1.PersistentVolumePhase, c clientset.Interface, pvName 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 WaitForPersistentVolumeClaimPhase(ctx context.Context, phase v1.PersistentVolumeClaimPhase, c clientset.Interface, ns string, pvcName string, poll, timeout time.Duration) 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 WaitForPersistentVolumeClaimsPhase(ctx context.Context, phase v1.PersistentVolumeClaimPhase, c clientset.Interface, ns string, pvcNames []string, poll, timeout time.Duration, matchAny bool) error { … } // CreatePVSource creates a PV source. func CreatePVSource(ctx context.Context, zone string) (*v1.PersistentVolumeSource, error) { … } // DeletePVSource deletes a PV source. func DeletePVSource(ctx context.Context, pvSource *v1.PersistentVolumeSource) error { … } // GetDefaultStorageClassName returns default storageClass or return error func GetDefaultStorageClassName(ctx context.Context, c clientset.Interface) (string, error) { … } // SkipIfNoDefaultStorageClass skips tests if no default SC can be found. func SkipIfNoDefaultStorageClass(ctx context.Context, c clientset.Interface) { … } // WaitForPersistentVolumeDeleted waits for a PersistentVolume to get deleted or until timeout occurs, whichever comes first. func WaitForPersistentVolumeDeleted(ctx context.Context, c clientset.Interface, pvName string, poll, timeout time.Duration) error { … } // WaitForPVCFinalizer waits for a finalizer to be added to a PVC in a given namespace. func WaitForPVCFinalizer(ctx context.Context, cs clientset.Interface, name, namespace, finalizer string, poll, timeout time.Duration) error { … } // GetDefaultFSType returns the default fsType func GetDefaultFSType() string { … }