@@ -313,6 +313,68 @@ func AssertKnativeObsoleteResource(t *testing.T, clients *test.Clients, namespac
313313func AssertKnativeDeploymentStatus (t * testing.T , clients * test.Clients , namespace string , version string , existingVersion string , expectedDeployments []string ) {
314314 if err := WaitForKnativeDeploymentState (clients , namespace , version , existingVersion , expectedDeployments , t .Logf ,
315315 IsKnativeDeploymentReady ); err != nil {
316+
317+ t .Logf ("=== DEPLOYMENT STATUS SNAPSHOT (namespace=%s, version=%q, existingVersion=%q) ===" ,
318+ namespace , version , existingVersion )
319+
320+ // Dump all deployments in the namespace with full status.
321+ dpList , listErr := clients .KubeClient .AppsV1 ().Deployments (namespace ).List (context .TODO (), metav1.ListOptions {})
322+ if listErr != nil {
323+ t .Logf (" failed to list deployments: %v" , listErr )
324+ } else {
325+ t .Logf (" total deployments found: %d" , len (dpList .Items ))
326+ for _ , d := range dpList .Items {
327+ conds := make ([]string , 0 , len (d .Status .Conditions ))
328+ for _ , c := range d .Status .Conditions {
329+ conds = append (conds , fmt .Sprintf ("%s=%s(reason=%s,msg=%s)" , c .Type , c .Status , c .Reason , c .Message ))
330+ }
331+ versionLabelVal := "<none>"
332+ for _ , key := range []string {"serving.knative.dev/release" , "eventing.knative.dev/release" , "app.kubernetes.io/version" } {
333+ if val , ok := d .Labels [key ]; ok {
334+ versionLabelVal = fmt .Sprintf ("%s=%s" , key , val )
335+ break
336+ }
337+ }
338+ t .Logf (" deployment %q: versionLabel=%s replicas(desired=%d ready=%d available=%d updated=%d unavailable=%d) conditions=%v" ,
339+ d .Name , versionLabelVal ,
340+ d .Status .Replicas , d .Status .ReadyReplicas , d .Status .AvailableReplicas ,
341+ d .Status .UpdatedReplicas , d .Status .UnavailableReplicas , conds )
342+ }
343+ }
344+
345+ // Dump pods in the namespace to expose CrashLoopBackOff / ImagePullBackOff / Pending.
346+ podList , podErr := clients .KubeClient .CoreV1 ().Pods (namespace ).List (context .TODO (), metav1.ListOptions {})
347+ if podErr != nil {
348+ t .Logf (" failed to list pods: %v" , podErr )
349+ } else {
350+ t .Logf (" total pods found: %d" , len (podList .Items ))
351+ for _ , p := range podList .Items {
352+ containerStates := make ([]string , 0 , len (p .Status .ContainerStatuses ))
353+ for _ , cs := range p .Status .ContainerStatuses {
354+ state := "running"
355+ if cs .State .Waiting != nil {
356+ state = fmt .Sprintf ("waiting(reason=%s,msg=%s)" , cs .State .Waiting .Reason , cs .State .Waiting .Message )
357+ } else if cs .State .Terminated != nil {
358+ state = fmt .Sprintf ("terminated(reason=%s,exitCode=%d)" , cs .State .Terminated .Reason , cs .State .Terminated .ExitCode )
359+ }
360+ containerStates = append (containerStates , fmt .Sprintf ("%s:%s(ready=%v,restarts=%d)" , cs .Name , state , cs .Ready , cs .RestartCount ))
361+ }
362+ t .Logf (" pod %q: phase=%s containers=%v" , p .Name , p .Status .Phase , containerStates )
363+ }
364+ }
365+
366+ // Dump KnativeServing CR status conditions to show operator perspective.
367+ ksList , ksErr := clients .KnativeServingAll ().List (context .TODO (), metav1.ListOptions {})
368+ if ksErr != nil {
369+ t .Logf (" failed to list KnativeServings: %v" , ksErr )
370+ } else {
371+ for _ , ks := range ksList .Items {
372+ conds := ks .Status .GetConditions ()
373+ t .Logf (" KnativeServing %s/%s: version=%q observedGen=%d conditions=%v" ,
374+ ks .Namespace , ks .Name , ks .Status .Version , ks .Status .ObservedGeneration , conds )
375+ }
376+ }
377+
316378 t .Fatalf ("Knative Serving deployments failed to meet the expected deployments: %v" , err )
317379 }
318380}
0 commit comments