Created
November 11, 2024 12:24
-
-
Save diegolovison/0a46f590b3656d0a476148f3a0e906e4 to your computer and use it in GitHub Desktop.
log pod events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if pod.Status.Phase != corev1.PodRunning { | |
// Fetch and log the events for the current pod | |
events, err := suite.clientset.CoreV1().Events(suite.DSPANamespace).List(suite.Ctx, metav1.ListOptions{ | |
FieldSelector: fmt.Sprintf("involvedObject.name=%s", pod.Name), | |
}) | |
if err != nil { | |
for _, event := range events.Items { | |
t.Log(fmt.Sprintf("Event for Pod %s: %s - %s", pod.Name, event.Reason, event.Message)) | |
} | |
} else { | |
t.Fatalf("Error fetching events for Pod %s: %v", pod.Name, err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment