← Back to Pull requests

OCPBUGS-99207: Prevent empty interface webhook panic #810

Closed
unknown closed this pull request without merging on Nov 06, 2026 06:11 UTC
View on GitHub
unknown unknown commented on Oct 24, 2026 16:19 UTC
Author

Context & Problem Statement

IngressNodeFirewall accepts an empty interface item such as spec.interfaces: [""] through CRD structural validation. During admission, validateINFInterfaces() records a validation error and then evaluates inf[0], which panics for the empty string.

With the validating webhook configured with failurePolicy: Fail, the API server returns an opaque admission failure:

admission webhook "vingressnodefirewall.kb.io" denied the request: panic: runtime error: index out of range [0] with length 0

The invalid resource should be rejected with a field-level validation error and must not cause the webhook to panic.

Fixes OCPBUGS-99207.

Implementation Overview

  • Update validateINFInterfaces() to return a validation error and continue when an interface name is empty.

  • Report the correct field path, spec.interfaces[index], and rejected interface value for every invalid interface case.

  • Normalize the empty-interface message to interface name must not be empty.

  • Strengthen the existing webhook envtest to require an invalid API response containing the field path and message.

  • Keep failurePolicy: Fail and the existing CRD/API contract unchanged.
  • No schema alteration, migration, or environment-variable dependency is introduced.

    Trade-offs & Edge Cases

  • spec.interfaces: [""] remains invalid; it is now rejected cleanly.

  • Omitted spec.interfaces and an empty interface list remain rejected by CRD validation.

  • No wildcard or all-interface semantics are introduced.

  • A CRD item-level minimum-length constraint could reject empty strings earlier, but the webhook remains defensive for existing objects and older CRD versions.
  • Risk & Blast Radius

    Low. The change is limited to invalid interface validation in validateINFInterfaces().

  • Valid interface names such as br-ex retain existing behavior.

  • Invalid requests continue to be rejected because failurePolicy: Fail is unchanged.

  • No stored-resource migration or controller reconciliation behavior changes.
  • Testing & Evidence

    The regression test in pkg/webhook/webhook_suite_test.go covers interfaces: [""] and asserts:

  • the request returns an apierrors.IsInvalid error;

  • the error references spec.interfaces[0]; and

  • the error contains interface name must not be empty.
  • Local verification completed:

    gofmt -d pkg/webhook/webhook.go pkg/webhook/webhook_suite_test.go
    git diff --check
    go vet ./pkg/webhook/...
    KUBEBUILDER_ASSETS=<kubernetes-1.37-envtest-assets> go test ./pkg/webhook/...
    

    The webhook suite passed all 56 specs with Kubernetes 1.37 envtest assets.

    The repository's OpenShift CI configuration exercises this change through:

  • unit-test — runs make test, including the webhook regression through go test ./...;

  • test-fmt — runs make fmt;

  • lint — runs make lint;

  • verify-deps — runs dependency verification;

  • ingress-node-firewall-e2e-metal-ipi — bare-metal IPI on the equinix-ocp-metal profile with OVN-Kubernetes and dual-stack networking; and

  • optional e2e-aws-ovn-infw-extension — AWS OVN integration coverage on the aws-5 profile.
  • At the time of this update, Prow has not executed these jobs because the PR is awaiting OpenShift /ok-to-test verification; no Prow result is represented as passed here.

    No new test/e2e test is added because this defect is isolated to admission-time validation of a malformed CR. The existing webhook envtest directly exercises the failing API path and verifies the Kubernetes Invalid response; deployment-level E2E coverage would not add coverage for this code path.

    Before this change, the reproducer returned the webhook panic shown above. After this change, it returns a normal Invalid API response and does not index an empty interface name.

    Rollback Plan

    Revert the controller image/operator bundle to the previous version. No CRD or data rollback is required.

    Diff: 493 lines (+369 / -124) across 6 files Reviewer: danwinship Review duration: 18111m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 493 lines diff across 6 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.371
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #810"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.4% (MEDIUM) · Higher = larger blast radius
    47.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.7% · Safe to merge
    18.7%