From 72d56cb8db1feb9f18fe001da480ba1d973a07bf Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 3 Aug 2021 17:03:13 +0200 Subject: [PATCH] e2e: use original namespace for retrying resize check expandPVCSize() uses the namespace of the PVC that was checked. In case the .Get() call fails, the PVC will not have its namespace set, and subsequent tries will fail with errors like: Error getting pvc in namespace: '': etcdserver: request timed out waiting for PVC (9 seconds elapsed) Error getting pvc in namespace: '': an empty namespace may not be set when a resource name is provided By using the original namespace of the PVC stored in a separate variable as is done with the name of the PVC, this problem should not occur anymore. Signed-off-by: Niels de Vos --- e2e/resize.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/e2e/resize.go b/e2e/resize.go index 8471b0f57..429377f60 100644 --- a/e2e/resize.go +++ b/e2e/resize.go @@ -19,9 +19,10 @@ 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(pvc.Namespace). + PersistentVolumeClaims(pvcNamespace). Get(context.TODO(), pvcName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("error fetching pvc %q with %w", pvcName, err) @@ -38,12 +39,12 @@ func expandPVCSize(c kubernetes.Interface, pvc *v1.PersistentVolumeClaim, size s e2elog.Logf("Waiting up to %v to be in Resized state", pvc) return wait.PollImmediate(poll, timeout, func() (bool, error) { - e2elog.Logf("waiting for PVC %s (%d seconds elapsed)", updatedPVC.Name, int(time.Since(start).Seconds())) + e2elog.Logf("waiting for PVC %s (%d seconds elapsed)", pvcName, int(time.Since(start).Seconds())) updatedPVC, err = c.CoreV1(). - PersistentVolumeClaims(updatedPVC.Namespace). + PersistentVolumeClaims(pvcNamespace). Get(context.TODO(), pvcName, metav1.GetOptions{}) if err != nil { - e2elog.Logf("Error getting pvc in namespace: '%s': %v", updatedPVC.Namespace, err) + e2elog.Logf("Error getting pvc in namespace: '%s': %v", pvcNamespace, err) if isRetryableAPIError(err) { return false, nil }