@@ -95,10 +95,15 @@ func (acp *AzureClusterProxy) CollectWorkloadClusterLogs(ctx context.Context, na
9595
9696 aboveMachinesPath := strings .Replace (outputPath , "/machines" , "" , 1 )
9797
98- Logf ("Dumping workload cluster %s/%s kube-system pod logs " , namespace , name )
98+ Logf ("Dumping workload cluster %s/%s nodes " , namespace , name )
9999 start := time .Now ()
100+ acp .collectNodes (ctx , namespace , name , aboveMachinesPath )
101+ Logf ("Fetching nodes took %s" , time .Since (start ).String ())
102+
103+ Logf ("Dumping workload cluster %s/%s pod logs" , namespace , name )
104+ start = time .Now ()
100105 acp .collectPodLogs (ctx , namespace , name , aboveMachinesPath )
101- Logf ("Fetching kube-system pod logs took %s" , time .Since (start ).String ())
106+ Logf ("Fetching pod logs took %s" , time .Since (start ).String ())
102107
103108 Logf ("Dumping workload cluster %s/%s Azure activity log" , namespace , name )
104109 start = time .Now ()
@@ -173,33 +178,36 @@ func (acp *AzureClusterProxy) collectPodLogs(ctx context.Context, namespace stri
173178 }(pod , container )
174179 }
175180
176- go func (pod corev1.Pod ) {
177- defer GinkgoRecover ()
181+ Logf ("Describing Pod %s/%s" , podNamespace , pod .Name )
182+ describeFile := path .Join (aboveMachinesPath , podNamespace , pod .Name , "pod-describe.txt" )
183+ writeLogFile (describeFile , podDescribe )
184+ }
185+ }
178186
179- Logf ("Describing Pod %s/%s" , podNamespace , pod .Name )
180- describeFile := path .Join (aboveMachinesPath , podNamespace , pod .Name , "pod-describe.txt" )
181- if err := os .MkdirAll (filepath .Dir (describeFile ), 0o755 ); err != nil {
182- // Failing to mkdir should not cause the test to fail
183- Logf ("Error mkdir: %v" , err )
184- return
185- }
187+ func (acp * AzureClusterProxy ) collectNodes (ctx context.Context , namespace string , name string , aboveMachinesPath string ) {
188+ workload := acp .GetWorkloadCluster (ctx , namespace , name )
189+ nodes := & corev1.NodeList {}
186190
187- f , err := os .OpenFile (describeFile , os .O_APPEND | os .O_CREATE | os .O_WRONLY , 0o644 )
188- if err != nil {
189- // Failing to open the file should not cause the test to fail
190- Logf ("Error opening file to write Pod describe: %v" , err )
191- return
192- }
193- defer f .Close ()
194-
195- out := bufio .NewWriter (f )
196- defer out .Flush ()
197- _ , err = out .WriteString (podDescribe )
198- if errors .Is (err , io .ErrUnexpectedEOF ) {
199- // Failing to describe pod should not cause the test to fail
200- Logf ("failed to describe pod %s/%s: %v" , podNamespace , pod .Name , err )
201- }
202- }(pod )
191+ Expect (workload .GetClient ().List (ctx , nodes )).To (Succeed ())
192+
193+ var err error
194+ var nodeDescribe string
195+
196+ nodeDescriber , ok := describe .DescriberFor (schema.GroupKind {Group : corev1 .GroupName , Kind : "Node" }, workload .GetRESTConfig ())
197+ if ! ok {
198+ Logf ("failed to get node describer" )
199+ }
200+
201+ for _ , node := range nodes .Items {
202+ // Describe the node.
203+ Logf ("Describing Node %s" , node .GetName ())
204+ nodeDescribe , err = nodeDescriber .Describe (node .GetNamespace (), node .GetName (), describe.DescriberSettings {ShowEvents : true })
205+ if err != nil {
206+ Logf ("failed to describe node %s: %v" , node .GetName (), err )
207+ }
208+
209+ describeFile := path .Join (aboveMachinesPath , nodesDir , node .GetName (), "node-describe.txt" )
210+ writeLogFile (describeFile , nodeDescribe )
203211 }
204212}
205213
@@ -274,3 +282,31 @@ func (acp *AzureClusterProxy) collectActivityLogs(ctx context.Context, namespace
274282 }
275283 }
276284}
285+
286+ func writeLogFile (logFilepath string , logData string ) {
287+ go func () {
288+ defer GinkgoRecover ()
289+
290+ if err := os .MkdirAll (filepath .Dir (logFilepath ), 0o755 ); err != nil {
291+ // Failing to mkdir should not cause the test to fail
292+ Logf ("Error mkdir: %v" , err )
293+ return
294+ }
295+
296+ f , err := os .OpenFile (logFilepath , os .O_APPEND | os .O_CREATE | os .O_WRONLY , 0o644 )
297+ if err != nil {
298+ // Failing to open the file should not cause the test to fail
299+ Logf ("Error opening file %s to write logs: %v" , logFilepath , err )
300+ return
301+ }
302+ defer f .Close ()
303+
304+ out := bufio .NewWriter (f )
305+ defer out .Flush ()
306+ _ , err = out .WriteString (logData )
307+ if err != nil {
308+ // Failing to write a log file should not cause the test to fail
309+ Logf ("failed to write logFile %s: %v" , logFilepath , err )
310+ }
311+ }()
312+ }
0 commit comments