Skip to content

Commit 5b0eea8

Browse files
committed
test/e2e: do not use ambiguous container image short names
The e2e tests fail on OCP 4.22 because RHEL 9 enforces fully qualified container image names ("short name mode"). The backend image `nginxdemos/nginx-hello:plain-text` is rejected with ImageInspectError since Podman cannot determine which registry to pull from. Replace it with `registry.k8s.io/e2e-test-images/agnhost:2.53`, a fully qualified image that is the standard e2e test image across OpenShift repositories. The agnhost image requires running the `netexec` subcommand to start its HTTP server. Update test expectations from "URI: /" to "NOW:" to match agnhost's response format.
1 parent 39f8426 commit 5b0eea8

2 files changed

Lines changed: 89 additions & 10 deletions

File tree

test/e2e/proxy_test.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func TestOAuthProxyE2E(t *testing.T) {
9292
proxyArgs: []string{
9393
"--upstream=http://localhost:8080",
9494
},
95-
pageResult: "URI: /",
95+
pageResult: "NOW:",
9696
},
9797
{
9898
name: "scope-full",
@@ -108,7 +108,7 @@ func TestOAuthProxyE2E(t *testing.T) {
108108
"--upstream=http://localhost:8080",
109109
`--openshift-sar={"namespace":"` + ns + `","resource":"services","verb":"list"}`,
110110
},
111-
pageResult: "URI: /",
111+
pageResult: "NOW:",
112112
},
113113
{
114114
name: "sar-fail",
@@ -124,7 +124,7 @@ func TestOAuthProxyE2E(t *testing.T) {
124124
"--upstream=http://localhost:8080",
125125
`--openshift-sar={"namespace":"` + ns + `","resource":"routes","resourceName":"proxy-route","verb":"get"}`,
126126
},
127-
pageResult: "URI: /",
127+
pageResult: "NOW:",
128128
},
129129
{
130130
name: "sar-name-fail",
@@ -140,7 +140,7 @@ func TestOAuthProxyE2E(t *testing.T) {
140140
"--upstream=http://localhost:8080",
141141
`--openshift-sar=[{"namespace":"` + ns + `","resource":"services","verb":"list"}, {"namespace":"` + ns + `","resource":"routes","verb":"list"}]`,
142142
},
143-
pageResult: "URI: /",
143+
pageResult: "NOW:",
144144
},
145145
{
146146
name: "sar-multi-fail",
@@ -157,7 +157,7 @@ func TestOAuthProxyE2E(t *testing.T) {
157157
`--skip-auth-regex=^/foo`,
158158
},
159159
accessSubPath: "/foo",
160-
pageResult: "URI: /foo\n",
160+
pageResult: "NOW:",
161161
bypass: true,
162162
},
163163
{
@@ -167,7 +167,7 @@ func TestOAuthProxyE2E(t *testing.T) {
167167
`--skip-auth-regex=^/foo`,
168168
},
169169
accessSubPath: "/bar",
170-
pageResult: "URI: /bar",
170+
pageResult: "NOW:",
171171
},
172172
{
173173
name: "bypass-auth-foo",
@@ -176,7 +176,7 @@ func TestOAuthProxyE2E(t *testing.T) {
176176
`--bypass-auth-for=^/foo`,
177177
},
178178
accessSubPath: "/foo",
179-
pageResult: "URI: /foo\n",
179+
pageResult: "NOW:",
180180
bypass: true,
181181
},
182182
{
@@ -186,7 +186,7 @@ func TestOAuthProxyE2E(t *testing.T) {
186186
`--bypass-auth-except-for=^/foo`,
187187
},
188188
accessSubPath: "/foo",
189-
pageResult: "URI: /foo\n",
189+
pageResult: "NOW:",
190190
},
191191
{
192192
name: "bypass-auth-except-bypassed",
@@ -195,7 +195,7 @@ func TestOAuthProxyE2E(t *testing.T) {
195195
`--bypass-auth-except-for=^/foo`,
196196
},
197197
accessSubPath: "/bar",
198-
pageResult: "URI: /bar",
198+
pageResult: "NOW:",
199199
bypass: true,
200200
},
201201
}
@@ -227,7 +227,7 @@ func TestOAuthProxyE2E(t *testing.T) {
227227
openshiftTransport, err := rest.TransportFor(testConfig)
228228
require.NoError(t, err)
229229

230-
backendImage := "nginxdemos/nginx-hello:plain-text"
230+
backendImage := "registry.k8s.io/e2e-test-images/agnhost:2.53"
231231

232232
upstreamCA, upstreamCert, upstreamKey, err := createCAandCertSet("localhost")
233233
require.NoError(t, err, "Error creating upstream TLS certificates")
@@ -306,6 +306,9 @@ func TestOAuthProxyE2E(t *testing.T) {
306306

307307
err = waitForPodRunningInNamespace(ctx, kubeClient, oauthProxyPod)
308308
if err != nil {
309+
// Log detailed pod debug info to help diagnose startup failures
310+
debugInfo := getPodDebugInfo(ctx, kubeClient, oauthProxyPod.Name, ns)
311+
t.Logf("Pod failed to reach Running state. Debug info:\n%s", debugInfo)
309312
t.Fatalf("setup: error waiting for pod to run: %s", err)
310313
}
311314

test/e2e/util.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,81 @@ func podRunning(ctx context.Context, c kubernetes.Interface, podName, namespace
188188
}
189189
}
190190

191+
// getPodDebugInfo returns detailed debugging information about a pod's state,
192+
// including conditions, container statuses, and events. This is useful for
193+
// diagnosing why a pod failed to reach Running state.
194+
func getPodDebugInfo(ctx context.Context, c kubernetes.Interface, podName, namespace string) string {
195+
var info strings.Builder
196+
197+
pod, err := c.CoreV1().Pods(namespace).Get(ctx, podName, metav1.GetOptions{})
198+
if err != nil {
199+
return fmt.Sprintf("failed to get pod %s/%s: %v", namespace, podName, err)
200+
}
201+
202+
// Pod phase and basic info
203+
info.WriteString(fmt.Sprintf("Pod: %s/%s\n", namespace, podName))
204+
info.WriteString(fmt.Sprintf("Phase: %s\n", pod.Status.Phase))
205+
if pod.Status.Reason != "" {
206+
info.WriteString(fmt.Sprintf("Reason: %s\n", pod.Status.Reason))
207+
}
208+
if pod.Status.Message != "" {
209+
info.WriteString(fmt.Sprintf("Message: %s\n", pod.Status.Message))
210+
}
211+
212+
// Pod conditions
213+
info.WriteString("\nConditions:\n")
214+
for _, cond := range pod.Status.Conditions {
215+
info.WriteString(fmt.Sprintf(" - %s: %s", cond.Type, cond.Status))
216+
if cond.Reason != "" {
217+
info.WriteString(fmt.Sprintf(" (Reason: %s)", cond.Reason))
218+
}
219+
if cond.Message != "" {
220+
info.WriteString(fmt.Sprintf(" - %s", cond.Message))
221+
}
222+
info.WriteString("\n")
223+
}
224+
225+
// Container statuses
226+
info.WriteString("\nContainer Statuses:\n")
227+
allStatuses := append(pod.Status.InitContainerStatuses, pod.Status.ContainerStatuses...)
228+
for _, cs := range allStatuses {
229+
info.WriteString(fmt.Sprintf(" - %s: Ready=%v, RestartCount=%d\n",
230+
cs.Name, cs.Ready, cs.RestartCount))
231+
if cs.State.Waiting != nil {
232+
info.WriteString(fmt.Sprintf(" State: Waiting - Reason: %s, Message: %s\n",
233+
cs.State.Waiting.Reason, cs.State.Waiting.Message))
234+
}
235+
if cs.State.Running != nil {
236+
info.WriteString(fmt.Sprintf(" State: Running since %s\n",
237+
cs.State.Running.StartedAt.String()))
238+
}
239+
if cs.State.Terminated != nil {
240+
info.WriteString(fmt.Sprintf(" State: Terminated - Reason: %s, ExitCode: %d, Message: %s\n",
241+
cs.State.Terminated.Reason, cs.State.Terminated.ExitCode, cs.State.Terminated.Message))
242+
}
243+
if cs.LastTerminationState.Terminated != nil {
244+
info.WriteString(fmt.Sprintf(" LastTermination: Reason: %s, ExitCode: %d, Message: %s\n",
245+
cs.LastTerminationState.Terminated.Reason,
246+
cs.LastTerminationState.Terminated.ExitCode,
247+
cs.LastTerminationState.Terminated.Message))
248+
}
249+
}
250+
251+
// Pod events
252+
events, err := c.CoreV1().Events(namespace).List(ctx, metav1.ListOptions{
253+
FieldSelector: fmt.Sprintf("involvedObject.name=%s,involvedObject.kind=Pod", podName),
254+
})
255+
if err == nil && len(events.Items) > 0 {
256+
info.WriteString("\nEvents:\n")
257+
for _, e := range events.Items {
258+
info.WriteString(fmt.Sprintf(" - %s %s: %s\n",
259+
e.Type, e.Reason, e.Message))
260+
}
261+
}
262+
263+
return info.String()
264+
}
265+
191266
func waitUntilRouteIsReady(t *testing.T, transport http.RoundTripper, url string) error {
192267
client := newHTTPSClient(t, transport)
193268
return wait.PollImmediate(time.Second, 30*time.Second, func() (bool, error) {
@@ -781,6 +856,7 @@ func newOAuthProxyPod(proxyImage, backendImage string, suffix string, extraProxy
781856
{
782857
Image: backendImage,
783858
Name: "hello-openshift",
859+
Args: []string{"netexec", "--http-port=8080"},
784860
SecurityContext: &v1.SecurityContext{
785861
AllowPrivilegeEscalation: pointer.Bool(false),
786862
Capabilities: &v1.Capabilities{Drop: []v1.Capability{"ALL"}},

0 commit comments

Comments
 (0)