Grab init containers logs in e2e tests
Storage tests use initContainers + framework.TestContainerOutput and they will benefit from logging their output in failed tests.
This commit is contained in:
		@@ -1249,15 +1249,16 @@ func (f *Framework) MatchContainerOutput(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if podErr != nil {
 | 
						if podErr != nil {
 | 
				
			||||||
		// Pod failed. Dump all logs from all containers to see what's wrong
 | 
							// Pod failed. Dump all logs from all containers to see what's wrong
 | 
				
			||||||
		for _, container := range podStatus.Spec.Containers {
 | 
							_ = podutil.VisitContainers(&podStatus.Spec, func(c *v1.Container) bool {
 | 
				
			||||||
			logs, err := e2epod.GetPodLogs(f.ClientSet, ns, podStatus.Name, container.Name)
 | 
								logs, err := e2epod.GetPodLogs(f.ClientSet, ns, podStatus.Name, c.Name)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				Logf("Failed to get logs from node %q pod %q container %q: %v",
 | 
									Logf("Failed to get logs from node %q pod %q container %q: %v",
 | 
				
			||||||
					podStatus.Spec.NodeName, podStatus.Name, container.Name, err)
 | 
										podStatus.Spec.NodeName, podStatus.Name, c.Name, err)
 | 
				
			||||||
				continue
 | 
								} else {
 | 
				
			||||||
			}
 | 
									Logf("Output of node %q pod %q container %q: %s", podStatus.Spec.NodeName, podStatus.Name, c.Name, logs)
 | 
				
			||||||
			Logf("Output of node %q pod %q container %q: %s", podStatus.Spec.NodeName, podStatus.Name, container.Name, logs)
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								return true
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
		return fmt.Errorf("expected pod %q success: %v", createdPod.Name, podErr)
 | 
							return fmt.Errorf("expected pod %q success: %v", createdPod.Name, podErr)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user