mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 11:00:25 +00:00
e2e: track deletion of PVC and PV more closely
When passing a pointer to a PVC and PV, the status of the deleted objects is not logged correctly. The `PersistentVolumeClaim.Status` and `PersistedVolume.Status` that is added to the logs contain the status of the initially created object (reference to the PVC/PV). When the PVC/PV is removed, there is no guarantee that the object is updated. Logs show an empty (nullified) `PersistentVolumeClaim.Status`, which is not helpful. Instead, use the returned PVC/PV from the `Get()` function and use that for further logging. Even when the `.Status` struct from the PVC/PV gets wiped, the returned object should have correct details. Updates: #1874 Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
ff728eaf0d
commit
47c6223b3a
12
e2e/pvc.go
12
e2e/pvc.go
@ -94,10 +94,12 @@ func deletePVCAndPV(c kubernetes.Interface, pvc *v1.PersistentVolumeClaim, pv *v
|
|||||||
|
|
||||||
timeout := time.Duration(t) * time.Minute
|
timeout := time.Duration(t) * time.Minute
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
pvcToDelete := pvc
|
||||||
err = wait.PollImmediate(poll, timeout, func() (bool, error) {
|
err = wait.PollImmediate(poll, timeout, func() (bool, error) {
|
||||||
// Check that the PVC is deleted.
|
// Check that the PVC is deleted.
|
||||||
e2elog.Logf("waiting for PVC %s in state %s to be deleted (%d seconds elapsed)", pvc.Name, pvc.Status.String(), int(time.Since(start).Seconds()))
|
e2elog.Logf("waiting for PVC %s in state %s to be deleted (%d seconds elapsed)", pvcToDelete.Name, pvcToDelete.Status.String(), int(time.Since(start).Seconds()))
|
||||||
_, err = c.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(context.TODO(), pvc.Name, metav1.GetOptions{})
|
pvcToDelete, err = c.CoreV1().PersistentVolumeClaims(pvcToDelete.Namespace).Get(context.TODO(), pvcToDelete.Name, metav1.GetOptions{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
@ -110,12 +112,14 @@ func deletePVCAndPV(c kubernetes.Interface, pvc *v1.PersistentVolumeClaim, pv *v
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
start = time.Now()
|
start = time.Now()
|
||||||
|
pvToDelete := pv
|
||||||
return wait.PollImmediate(poll, timeout, func() (bool, error) {
|
return wait.PollImmediate(poll, timeout, func() (bool, error) {
|
||||||
// Check that the PV is deleted.
|
// Check that the PV is deleted.
|
||||||
e2elog.Logf("waiting for PV %s in state %s to be deleted (%d seconds elapsed)", pv.Name, pv.Status.String(), int(time.Since(start).Seconds()))
|
e2elog.Logf("waiting for PV %s in state %s to be deleted (%d seconds elapsed)", pvToDelete.Name, pvToDelete.Status.String(), int(time.Since(start).Seconds()))
|
||||||
|
|
||||||
_, err = c.CoreV1().PersistentVolumes().Get(context.TODO(), pv.Name, metav1.GetOptions{})
|
pvToDelete, err = c.CoreV1().PersistentVolumes().Get(context.TODO(), pvToDelete.Name, metav1.GetOptions{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user