Add nethealth prepull container output to e2e run logs
This commit is contained in:
		@@ -35,6 +35,18 @@ spec:
 | 
				
			|||||||
      name: socket
 | 
					      name: socket
 | 
				
			||||||
    - mountPath: /usr/bin/docker
 | 
					    - mountPath: /usr/bin/docker
 | 
				
			||||||
      name: docker
 | 
					      name: docker
 | 
				
			||||||
 | 
					  # Add a container that runs a health-check
 | 
				
			||||||
 | 
					  - name: nethealth-check
 | 
				
			||||||
 | 
					    resources:
 | 
				
			||||||
 | 
					      requests:
 | 
				
			||||||
 | 
					        cpu: 100m
 | 
				
			||||||
 | 
					      limits:
 | 
				
			||||||
 | 
					        cpu: 100m
 | 
				
			||||||
 | 
					    image:  gcr.io/google_containers/kube-nethealth-amd64:1.0
 | 
				
			||||||
 | 
					    command:
 | 
				
			||||||
 | 
					    - /bin/sh
 | 
				
			||||||
 | 
					    - -c
 | 
				
			||||||
 | 
					    - "/usr/bin/nethealth || true"
 | 
				
			||||||
  volumes:
 | 
					  volumes:
 | 
				
			||||||
  - hostPath:
 | 
					  - hostPath:
 | 
				
			||||||
      path: /var/run/docker.sock
 | 
					      path: /var/run/docker.sock
 | 
				
			||||||
@@ -44,3 +56,6 @@ spec:
 | 
				
			|||||||
    name: docker
 | 
					    name: docker
 | 
				
			||||||
  # This pod is really fire-and-forget.
 | 
					  # This pod is really fire-and-forget.
 | 
				
			||||||
  restartPolicy: Never
 | 
					  restartPolicy: Never
 | 
				
			||||||
 | 
					  # This pod needs hostNetworking for true VM perf measurement as well as avoiding cbr0 issues
 | 
				
			||||||
 | 
					  hostNetwork: true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -140,6 +140,12 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
 | 
				
			|||||||
		framework.Logf("WARNING: Image pulling pods failed to enter success in %v: %v", imagePrePullingTimeout, err)
 | 
							framework.Logf("WARNING: Image pulling pods failed to enter success in %v: %v", imagePrePullingTimeout, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Dump the output of the nethealth containers only once per run
 | 
				
			||||||
 | 
						if framework.TestContext.DumpLogsOnFailure {
 | 
				
			||||||
 | 
							framework.Logf("Dumping network health container logs from all nodes")
 | 
				
			||||||
 | 
							framework.LogContainersInPodsWithLabels(c, api.NamespaceSystem, framework.ImagePullerLabels, "nethealth")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}, func(data []byte) {
 | 
					}, func(data []byte) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -263,7 +263,7 @@ func (f *Framework) AfterEach() {
 | 
				
			|||||||
	if CurrentGinkgoTestDescription().Failed && TestContext.DumpLogsOnFailure {
 | 
						if CurrentGinkgoTestDescription().Failed && TestContext.DumpLogsOnFailure {
 | 
				
			||||||
		DumpAllNamespaceInfo(f.Client, f.Namespace.Name)
 | 
							DumpAllNamespaceInfo(f.Client, f.Namespace.Name)
 | 
				
			||||||
		By(fmt.Sprintf("Dumping a list of prepulled images on each node"))
 | 
							By(fmt.Sprintf("Dumping a list of prepulled images on each node"))
 | 
				
			||||||
		LogPodsWithLabels(f.Client, api.NamespaceSystem, ImagePullerLabels)
 | 
							LogContainersInPodsWithLabels(f.Client, api.NamespaceSystem, ImagePullerLabels, "image-puller")
 | 
				
			||||||
		if f.federated {
 | 
							if f.federated {
 | 
				
			||||||
			// Print logs of federation control plane pods (federation-apiserver and federation-controller-manager)
 | 
								// Print logs of federation control plane pods (federation-apiserver and federation-controller-manager)
 | 
				
			||||||
			LogPodsWithLabels(f.Client, "federation", map[string]string{"app": "federated-cluster"})
 | 
								LogPodsWithLabels(f.Client, "federation", map[string]string{"app": "federated-cluster"})
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -663,8 +663,10 @@ func RunKubernetesServiceTestContainer(c *client.Client, repoRoot string, ns str
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func kubectlLogPod(c *client.Client, pod api.Pod) {
 | 
					func kubectlLogPod(c *client.Client, pod api.Pod, containerNameSubstr string) {
 | 
				
			||||||
	for _, container := range pod.Spec.Containers {
 | 
						for _, container := range pod.Spec.Containers {
 | 
				
			||||||
 | 
							if strings.Contains(container.Name, containerNameSubstr) {
 | 
				
			||||||
 | 
								// Contains() matches all strings if substr is empty
 | 
				
			||||||
			logs, err := GetPodLogs(c, pod.Namespace, pod.Name, container.Name)
 | 
								logs, err := GetPodLogs(c, pod.Namespace, pod.Name, container.Name)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				logs, err = getPreviousPodLogs(c, pod.Namespace, pod.Name, container.Name)
 | 
									logs, err = getPreviousPodLogs(c, pod.Namespace, pod.Name, container.Name)
 | 
				
			||||||
@@ -673,7 +675,8 @@ func kubectlLogPod(c *client.Client, pod api.Pod) {
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			By(fmt.Sprintf("Logs of %v/%v:%v on node %v", pod.Namespace, pod.Name, container.Name, pod.Spec.NodeName))
 | 
								By(fmt.Sprintf("Logs of %v/%v:%v on node %v", pod.Namespace, pod.Name, container.Name, pod.Spec.NodeName))
 | 
				
			||||||
		Logf(logs)
 | 
								Logf("%s : STARTLOG\n%s\nENDLOG for container %v:%v:%v", containerNameSubstr, logs, pod.Namespace, pod.Name, container.Name)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -686,7 +689,7 @@ func LogFailedContainers(c *client.Client, ns string) {
 | 
				
			|||||||
	Logf("Running kubectl logs on non-ready containers in %v", ns)
 | 
						Logf("Running kubectl logs on non-ready containers in %v", ns)
 | 
				
			||||||
	for _, pod := range podList.Items {
 | 
						for _, pod := range podList.Items {
 | 
				
			||||||
		if res, err := PodRunningReady(&pod); !res || err != nil {
 | 
							if res, err := PodRunningReady(&pod); !res || err != nil {
 | 
				
			||||||
			kubectlLogPod(c, pod)
 | 
								kubectlLogPod(c, pod, "")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -699,7 +702,18 @@ func LogPodsWithLabels(c *client.Client, ns string, match map[string]string) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	Logf("Running kubectl logs on pods with labels %v in %v", match, ns)
 | 
						Logf("Running kubectl logs on pods with labels %v in %v", match, ns)
 | 
				
			||||||
	for _, pod := range podList.Items {
 | 
						for _, pod := range podList.Items {
 | 
				
			||||||
		kubectlLogPod(c, pod)
 | 
							kubectlLogPod(c, pod, "")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func LogContainersInPodsWithLabels(c *client.Client, ns string, match map[string]string, containerSubstr string) {
 | 
				
			||||||
 | 
						podList, err := c.Pods(ns).List(api.ListOptions{LabelSelector: labels.SelectorFromSet(match)})
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							Logf("Error getting pods in namespace %q: %v", ns, err)
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						for _, pod := range podList.Items {
 | 
				
			||||||
 | 
							kubectlLogPod(c, pod, containerSubstr)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user