mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Gather Fluentd logs
This commit is contained in:
parent
ed8390a51f
commit
c3d400f4bb
@ -12,8 +12,6 @@ spec:
|
||||
resources:
|
||||
limits:
|
||||
cpu: 100m
|
||||
args:
|
||||
- -q
|
||||
volumeMounts:
|
||||
- name: varlog
|
||||
mountPath: /var/log
|
||||
|
@ -219,9 +219,9 @@ func ClusterLevelLoggingWithElasticsearch(f *Framework) {
|
||||
By("Checking to make sure the Fluentd pod are running on each healthy node")
|
||||
label = labels.SelectorFromSet(labels.Set(map[string]string{k8sAppKey: fluentdValue}))
|
||||
options = api.ListOptions{LabelSelector: label}
|
||||
pods, err = f.Client.Pods(api.NamespaceSystem).List(options)
|
||||
fluentdPods, err := f.Client.Pods(api.NamespaceSystem).List(options)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
for _, pod := range pods.Items {
|
||||
for _, pod := range fluentdPods.Items {
|
||||
if nodeInNodeList(pod.Spec.NodeName, nodes) {
|
||||
err = waitForPodRunningInNamespace(f.Client, pod.Name, api.NamespaceSystem)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -231,7 +231,7 @@ func ClusterLevelLoggingWithElasticsearch(f *Framework) {
|
||||
// Check if each healthy node has fluentd running on it
|
||||
for _, node := range nodes.Items {
|
||||
exists := false
|
||||
for _, pod := range pods.Items {
|
||||
for _, pod := range fluentdPods.Items {
|
||||
if pod.Spec.NodeName == node.Name {
|
||||
exists = true
|
||||
break
|
||||
@ -432,7 +432,7 @@ func ClusterLevelLoggingWithElasticsearch(f *Framework) {
|
||||
}
|
||||
for n := range missingPerNode {
|
||||
if missingPerNode[n] > 0 {
|
||||
Logf("Node %d is missing %d logs", n, missingPerNode[n])
|
||||
Logf("Node %d %s is missing %d logs", n, nodes.Items[n].Name, missingPerNode[n])
|
||||
opts := &api.PodLogOptions{}
|
||||
body, err = f.Client.Pods(ns).GetLogs(podNames[n], opts).DoRaw()
|
||||
if err != nil {
|
||||
@ -440,6 +440,18 @@ func ClusterLevelLoggingWithElasticsearch(f *Framework) {
|
||||
continue
|
||||
}
|
||||
Logf("Pod %s has the following logs: %s", podNames[n], body)
|
||||
|
||||
for _, pod := range fluentdPods.Items {
|
||||
if pod.Spec.NodeName == nodes.Items[n].Name {
|
||||
body, err = f.Client.Pods(api.NamespaceSystem).GetLogs(pod.Name, opts).DoRaw()
|
||||
if err != nil {
|
||||
Logf("Cannot get logs from pod %v", pod.Name)
|
||||
break
|
||||
}
|
||||
Logf("Fluentd Pod %s on node %s has the following logs: %s", pod.Name, nodes.Items[n].Name, body)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Failf("Failed to find all %d log lines", expected)
|
||||
|
Loading…
Reference in New Issue
Block a user