ci: log pvc events

incase if the pvc is not bound
yet, log the pvc events to
check what is happening.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2024-09-11 10:22:55 +02:00 committed by mergify[bot]
parent 5c621d2e82
commit 744b8e1c1c

View File

@ -75,6 +75,19 @@ func createPVCAndvalidatePV(c kubernetes.Interface, pvc *v1.PersistentVolumeClai
} }
if pvc.Spec.VolumeName == "" { if pvc.Spec.VolumeName == "" {
var events *v1.EventList
// Log the events for the PVC if its not bound yet
events, err = c.CoreV1().Events(namespace).List(ctx, metav1.ListOptions{
FieldSelector: "involvedObject.kind=PersistentVolumeClaim,involvedObject.name=" + name,
})
if err == nil {
for i := range events.Items {
framework.Logf("PVC %s Event: %s - %s", name, events.Items[i].Reason, events.Items[i].Message)
}
} else {
framework.Logf("error getting events for PVC %s: %v", name, err)
}
return false, nil return false, nil
} }