e2e: add getPersistentVolumeClaim helper function

added getPersistentVolumeClaim helper function
to get the PVC and also try if there is any API
error to improve the CI.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna
2022-05-06 12:29:50 +05:30
committed by mergify[bot]
parent c880061882
commit 89d9ec0823
7 changed files with 33 additions and 30 deletions

View File

@ -36,10 +36,7 @@ import (
func expandPVCSize(c kubernetes.Interface, pvc *v1.PersistentVolumeClaim, size string, t int) error {
pvcName := pvc.Name
pvcNamespace := pvc.Namespace
updatedPVC, err := c.CoreV1().
PersistentVolumeClaims(pvcNamespace).
Get(context.TODO(), pvcName, metav1.GetOptions{})
updatedPVC, err := getPersistentVolumeClaim(c, pvcNamespace, pvcName)
if err != nil {
return fmt.Errorf("error fetching pvc %q with %w", pvcName, err)
}
@ -120,10 +117,7 @@ func resizePVCAndValidateSize(pvcPath, appPath string, f *framework.Framework) e
opt := metav1.ListOptions{
LabelSelector: "app=resize-pvc",
}
pvc, err = f.ClientSet.CoreV1().
PersistentVolumeClaims(pvc.Namespace).
Get(context.TODO(), pvc.Name, metav1.GetOptions{})
pvc, err = getPersistentVolumeClaim(f.ClientSet, pvc.Namespace, pvc.Name)
if err != nil {
return fmt.Errorf("failed to get pvc: %w", err)
}