@@ -216,6 +216,8 @@ func (h *ValidatorHarness) ApplyManifest(defaultNamespace string, manifestPath s
216216 h .Fatalf ("failed to parse manifest %s: %v" , manifestPath , err )
217217 }
218218
219+ h .objectIDs = append (h .objectIDs , objects ... )
220+
219221 h .ShellExec (fmt .Sprintf ("kubectl apply -n %s -f %s" , defaultNamespace , manifestPath ))
220222
221223 return objects
@@ -235,17 +237,20 @@ func (h *ValidatorHarness) dumpNamespaceResources(ctx context.Context, ns string
235237 return
236238 }
237239
238- resourceTypes := []string {
239- "pods" ,
240- "jobs" ,
241- "deployments" ,
242- "statefulsets" ,
243- "services" ,
244- "events" ,
240+ resourceTypes := make (map [string ]bool )
241+ for _ , objectID := range h .objectIDs {
242+ gvk := objectID .GVK ()
243+ id := fmt .Sprintf ("%s.%s" , gvk .Kind , gvk .Group )
244+ resourceTypes [id ] = true
245245 }
246246
247- for _ , resourceType := range resourceTypes {
248- if err := h .dumpResource (ctx , ns , resourceType , filepath .Join (clusterInfoDir , resourceType + ".yaml" )); err != nil {
247+ // Always include Events, Pods: they are usually not in the manifest, but are often critical for understanding failures.
248+ resourceTypes ["Events" ] = true
249+ resourceTypes ["Pods" ] = true
250+
251+ for resourceType := range resourceTypes {
252+ filename := strings .ToLower (resourceType ) + ".yaml"
253+ if err := h .dumpResource (ctx , ns , resourceType , filepath .Join (clusterInfoDir , filename )); err != nil {
249254 h .Logf ("failed to dump resource %s: %v" , resourceType , err )
250255 }
251256 }
0 commit comments