mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-26 08:10:20 +00:00
e2e: prevent re-using empty pvc object
When an error occurs, the pvc object is overwritten in the PollImmediate() loop. Re-using the pvc.Namespace results in error messages like Error getting pvc in namespace: '': an empty namespace may not be set when a resource name is provided and prevents the retry by PollImmediate() to never succeed. Storing the namespace in a local variable prevents this from happening. Reported-by: Rakshith R <rar@redhat.com> Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
f7ae33c67c
commit
4d4a2a7814
@ -38,14 +38,15 @@ func createPVCAndvalidatePV(c kubernetes.Interface, pvc *v1.PersistentVolumeClai
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
name := pvc.Name
|
name := pvc.Name
|
||||||
|
namespace := pvc.Namespace
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
e2elog.Logf("Waiting up to %v to be in Bound state", pvc)
|
e2elog.Logf("Waiting up to %v to be in Bound state", pvc)
|
||||||
|
|
||||||
return wait.PollImmediate(poll, timeout, func() (bool, error) {
|
return wait.PollImmediate(poll, timeout, func() (bool, error) {
|
||||||
e2elog.Logf("waiting for PVC %s (%d seconds elapsed)", pvc.Name, int(time.Since(start).Seconds()))
|
e2elog.Logf("waiting for PVC %s (%d seconds elapsed)", name, int(time.Since(start).Seconds()))
|
||||||
pvc, err = c.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
pvc, err = c.CoreV1().PersistentVolumeClaims(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e2elog.Logf("Error getting pvc in namespace: '%s': %v", pvc.Namespace, err)
|
e2elog.Logf("Error getting pvc %q in namespace %q: %v", name, namespace, err)
|
||||||
if isRetryableAPIError(err) {
|
if isRetryableAPIError(err) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
@ -72,7 +73,7 @@ func createPVCAndvalidatePV(c kubernetes.Interface, pvc *v1.PersistentVolumeClai
|
|||||||
err = e2epv.WaitOnPVandPVC(
|
err = e2epv.WaitOnPVandPVC(
|
||||||
c,
|
c,
|
||||||
&framework.TimeoutContext{ClaimBound: timeout, PVBound: timeout},
|
&framework.TimeoutContext{ClaimBound: timeout, PVBound: timeout},
|
||||||
pvc.Namespace,
|
namespace,
|
||||||
pv,
|
pv,
|
||||||
pvc)
|
pvc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user