Skip to content

WIP: Avoid TLS port-forward to stale endpoints on degraded TNF clusters. - #31502

Open
eggfoobar wants to merge 1 commit into
openshift:mainfrom
eggfoobar:update-tls-tests-for-tnf
Open

WIP: Avoid TLS port-forward to stale endpoints on degraded TNF clusters.#31502
eggfoobar wants to merge 1 commit into
openshift:mainfrom
eggfoobar:update-tls-tests-for-tnf

Conversation

@eggfoobar

@eggfoobar eggfoobar commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

When DEGRADED_NODE is set, ForwardPortAndExecute targets a Running pod on a Ready node so TestTLSMinimumVersions/TestTLSDefaults do not follow fenced-node endpoints that still appear Ready.

Summary by CodeRabbit

  • Bug Fixes
    • Improved command execution reliability when a cluster is degraded by routing requests through healthy application instances when available.
    • Added validation to ensure traffic is directed only to ready instances with compatible service configuration.
    • Added graceful fallback to standard service routing when a healthy instance cannot be resolved.
    • Improved error reporting for routing resolution failures.

When DEGRADED_NODE is set, ForwardPortAndExecute targets a Running pod on a Ready node so TestTLSMinimumVersions/TestTLSDefaults do not follow fenced-node endpoints that still appear Ready.

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: ehila <ehila@redhat.com>
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 11, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Walkthrough

ForwardPortAndExecute now resolves a running pod on a Ready node during degraded clusters. It uses the Service target port, logs resolution failures, and falls back to forwarding through the Service.

Changes

Degraded-cluster port forwarding

Layer / File(s) Summary
Ready-node target resolution
test/extended/util/tls.go
The helper validates Service selectors and ports, identifies Ready nodes, and selects the first non-deleting Running pod scheduled on a Ready node.
Degraded forwarding integration
test/extended/util/tls.go
ForwardPortAndExecute uses the resolved pod and port when ClusterDegraded is enabled. Resolution errors trigger logging and Service fallback.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ForwardPortAndExecute
  participant portForwardTargetOnReadyNode
  participant KubernetesAPI
  participant PortForwardRetryFlow
  ForwardPortAndExecute->>portForwardTargetOnReadyNode: Resolve pod and target port
  portForwardTargetOnReadyNode->>KubernetesAPI: Query Service, Nodes, and Pods
  KubernetesAPI-->>portForwardTargetOnReadyNode: Return resolution data
  portForwardTargetOnReadyNode-->>ForwardPortAndExecute: Return pod resource and port
  ForwardPortAndExecute->>PortForwardRetryFlow: Forward to resolved target
Loading
🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: avoiding TLS port-forwarding to stale endpoints on degraded TNF clusters.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The patch changes only test/extended/util/tls.go, adds no Ginkgo test declarations or title expressions, and leaves existing test names unchanged.
Test Structure And Quality ✅ Passed Only the TLS helper changed; it adds no Ginkgo It block or resource lifecycle, and bounds Service/Node/Pod resolution to 30s plus port-forward attempts to 5s.
Microshift Test Compatibility ✅ Passed The pull request changes only test/extended/util/tls.go and adds no Ginkgo tests or new test declarations; the MicroShift API compatibility check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The patch changes only test/extended/util/tls.go and adds no Ginkgo It, Describe, Context, or When tests; SNO multi-node compatibility checks do not apply.
Topology-Aware Scheduling Compatibility ✅ Passed The commit changes only test/extended/util/tls.go. It adds runtime Service, node, and pod discovery, with no manifests, controllers, or scheduling constraints.
Ote Binary Stdout Contract ✅ Passed The PR only adds e2e.Logf calls in a helper invoked from Ginkgo It blocks; the framework routes Logf to GinkgoWriter, and no process-level stdout write was added.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR changes only test/extended/util/tls.go and adds no Ginkgo tests. Added code uses Kubernetes APIs and oc port-forwarding, with no IPv4 literals or external connectivity.
No-Weak-Crypto ✅ Passed The PR adds Kubernetes pod and service resolution only; added lines contain no MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB, custom crypto, or secret comparisons.
Container-Privileges ✅ Passed The pull request changes only Go test utility logic; no container or Kubernetes manifest declares privileged, host namespaces, SYS_ADMIN, or allowPrivilegeEscalation.
No-Sensitive-Data-In-Logs ✅ Passed New logs contain resource names, namespaces, ports, and resolver errors only; command output is discarded, and framework logging records only oc arguments without passwords, tokens, or API keys.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@eggfoobar

Copy link
Copy Markdown
Contributor Author

/payload-aggregate periodic-ci-openshift-release-main-nightly-5.0-e2e-metal-ovn-two-node-fencing-degraded

@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@eggfoobar: it appears that you have attempted to use some version of the payload command, but your comment was incorrectly formatted and cannot be acted upon. See the docs for usage info.

@eggfoobar

Copy link
Copy Markdown
Contributor Author

/payload-aggregate periodic-ci-openshift-release-main-nightly-5.0-e2e-metal-ovn-two-node-fencing-degraded 2

@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@eggfoobar: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-release-main-nightly-5.0-e2e-metal-ovn-two-node-fencing-degraded

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/257e8f40-958b-11f1-95e4-356eb7bec005-0

@openshift-ci
openshift-ci Bot requested review from deads2k and p0lyn0mial August 11, 2026 13:47
@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: eggfoobar
Once this PR has been reviewed and has the lgtm label, please assign jogeo for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/extended/util/tls.go`:
- Around line 124-131: Update the pod selection loop to require a true PodReady
condition in addition to PodRunning before returning the pod and targetPort. Use
the pod’s status conditions to reject non-ready pods, ensuring the retry loop
does not repeatedly select the first non-ready pod.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 32fecd0b-6097-42e7-9198-607254a77718

📥 Commits

Reviewing files that changed from the base of the PR and between 29be8bd and 2a038b0.

📒 Files selected for processing (1)
  • test/extended/util/tls.go

Comment thread test/extended/util/tls.go
Comment on lines +124 to +131
for _, pod := range pods.Items {
if pod.DeletionTimestamp != nil || pod.Status.Phase != corev1.PodRunning {
continue
}
if _, ok := readyNodes[pod.Spec.NodeName]; !ok {
continue
}
return "pod/" + pod.Name, targetPort, nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

ast-grep outline test/extended/util/tls.go --items all
rg -n -C 4 --type go 'portForwardTargetOnReadyNode|PodReady|NodeReady|Status\.Conditions' test/extended

Repository: openshift/origin

Length of output: 50373


🏁 Script executed:

#!/bin/bash
set -euo pipefail

cat -n test/extended/util/tls.go | sed -n '35,170p'
printf '\nForwardPortAndExecute call sites:\n'
rg -n -C 5 --type go 'ForwardPortAndExecute\(' test/extended
printf '\nRetry and port-forward helpers:\n'
rg -n -C 6 --type go 'Eventually|Consistently|Retry|port-forward|PortForward' test/extended/util/tls.go

Repository: openshift/origin

Length of output: 10354


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path

source = Path("test/extended/util/tls.go").read_text()
selection = source[source.index("func portForwardTargetOnReadyNode"):source.index("func servicePortToTargetPort")]
retry = source[source.index("var err error"):source.index("return err", source.index("var err error"))]

assert "pod.Status.Phase != corev1.PodRunning" in selection
assert "PodReady" not in selection
assert 'resource, port = podResource, podPort' in source
assert retry.count("resource") == 1, retry

pods = [
    {"name": "not-ready", "phase": "Running", "node": "ready-node", "ready": False},
    {"name": "ready", "phase": "Running", "node": "ready-node", "ready": True},
]
ready_nodes = {"ready-node"}

selected = next(
    pod["name"]
    for pod in pods
    if pod["phase"] == "Running"
    and pod["node"] in ready_nodes
)
targets = [selected for _ in range(3)]

print({
    "running_condition_present": True,
    "pod_ready_condition_present": "PodReady" in selection,
    "selected_pod": selected,
    "retry_targets": targets,
})
PY

Repository: openshift/origin

Length of output: 315


Select a Ready pod before port-forwarding.

PodRunning does not imply PodReady. Because target selection occurs before the retry loop, all three retries can use the first non-ready pod. Check the PodReady condition before returning the pod.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/extended/util/tls.go` around lines 124 - 131, Update the pod selection
loop to require a true PodReady condition in addition to PodRunning before
returning the pod and targetPort. Use the pod’s status conditions to reject
non-ready pods, ensuring the retry loop does not repeatedly select the first
non-ready pod.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

@eggfoobar: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-gcp-ovn 2a038b0 link true /test e2e-gcp-ovn
ci/prow/e2e-vsphere-ovn-upi 2a038b0 link true /test e2e-vsphere-ovn-upi
ci/prow/e2e-metal-ipi-ovn-ipv6 2a038b0 link true /test e2e-metal-ipi-ovn-ipv6
ci/prow/e2e-gcp-ovn-upgrade 2a038b0 link true /test e2e-gcp-ovn-upgrade
ci/prow/e2e-gcp-csi 2a038b0 link true /test e2e-gcp-csi

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant