Skip to content

Commit 15b8dfc

Browse files
committed
debug
Signed-off-by: Vincent Hou <vhou@coreweave.com>
1 parent 95406b7 commit 15b8dfc

3 files changed

Lines changed: 94 additions & 4 deletions

File tree

test/e2e-common.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ readonly PREVIOUS_SERVING_RELEASE_VERSION="1.21"
2323
readonly PREVIOUS_EVENTING_RELEASE_VERSION="1.21"
2424
# The target serving/eventing release to upgrade, installed by the operator. It can be a release available under
2525
# kodata or an incoming new release. This value should be in the semantic format of major.minor.
26-
readonly TARGET_RELEASE_VERSION="1.21"
26+
readonly TARGET_RELEASE_VERSION="1.22"
2727
# This is the branch name of knative repos, where we run the upgrade tests.
2828
# Default to empty for local runs (not in Prow).
29-
readonly KNATIVE_REPO_BRANCH="release-1.21"
29+
readonly KNATIVE_REPO_BRANCH="release-1.22"
3030
# Namespaces used for tests
3131
# This environment variable TEST_NAMESPACE defines the namespace to install Knative Serving.
3232
export TEST_NAMESPACE="${TEST_NAMESPACE:-knative-operator-testing}"

test/resources/knativeresources.go

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,29 @@ func IsKnativeDeploymentReady(dpList *v1.DeploymentList, expectedDeployments []s
9292
return false
9393
}
9494

95+
// formatDeploymentStatus returns a compact, human-readable summary of a deployment's
96+
// status conditions and replica counts to help diagnose why it is not ready.
97+
formatDeploymentStatus := func(d *v1.Deployment) string {
98+
s := d.Status
99+
conds := make([]string, 0, len(s.Conditions))
100+
for _, c := range s.Conditions {
101+
conds = append(conds, fmt.Sprintf("%s=%s(reason=%s,msg=%s)", c.Type, c.Status, c.Reason, c.Message))
102+
}
103+
return fmt.Sprintf("replicas(desired=%d ready=%d available=%d updated=%d unavailable=%d) conditions=%v",
104+
s.Replicas, s.ReadyReplicas, s.AvailableReplicas, s.UpdatedReplicas, s.UnavailableReplicas, conds)
105+
}
106+
107+
// formatVersionLabel extracts the version-related label from a deployment for diagnostics.
108+
formatVersionLabel := func(d *v1.Deployment) string {
109+
labels := d.GetLabels()
110+
for _, key := range []string{"serving.knative.dev/release", "eventing.knative.dev/release", "app.kubernetes.io/version", "networking.knative.dev/ingress-provider"} {
111+
if val, ok := labels[key]; ok {
112+
return fmt.Sprintf("%s=%s", key, val)
113+
}
114+
}
115+
return "<no version label>"
116+
}
117+
95118
isReady := func(d *v1.Deployment) bool {
96119
for key, val := range d.GetObjectMeta().GetLabels() {
97120
// Check if the version matches. As long as we find a value equals to the version, we can determine
@@ -139,14 +162,19 @@ func IsKnativeDeploymentReady(dpList *v1.DeploymentList, expectedDeployments []s
139162
return false
140163
}
141164

165+
logf("[deployment-check] version=%q existingVersion=%q expectedDeployments=%v",
166+
version, existingVersion, expectedDeployments)
167+
142168
for _, name := range expectedDeployments {
143169
dep := findDeployment(name, dpList.Items)
144170
if dep == nil {
145-
logf("The deployment %v is not found.", name)
171+
logf("[deployment-check] deployment %q not found in namespace (found %d total deployments)",
172+
name, len(dpList.Items))
146173
return false, nil
147174
}
148175
if !isReady(dep) {
149-
logf("The deployment %v is not ready.", dep.Name)
176+
logf("[deployment-check] deployment %q not ready: versionLabel=%s status=%s",
177+
dep.Name, formatVersionLabel(dep), formatDeploymentStatus(dep))
150178
return false, nil
151179
}
152180
}

test/resources/verify.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,68 @@ func AssertKnativeObsoleteResource(t *testing.T, clients *test.Clients, namespac
313313
func 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

Comments
 (0)