← Back to Pull requests

fix path for canary by header + add e2e #365

Merged
jgreeer merged 2 files (182 lines) on Mar 04, 2026 21:22 UTC
View on GitHub
jgreeer jgreeer commented on Feb 24, 2026 20:58 UTC
Author

What type of PR is this?
<!--
/kind bug

What this PR does / why we need it:

When creating the new rules for matching the canary header, we don't add the matches from the existing rule. This means the canary header matching isn't scoped to the path defined in the ingress-nginx ingress if there is one.

Does this PR introduce a user-facing change?:
<!--
If no, just write "NONE" in the release-note block below.
If yes, please enter a release note below:
-->
``release-note
added path support for canary by header
``

Diff: 182 lines (+149 / -33) across 2 files Reviewer: bexxmodd Review duration: 11544m
All Vouch review confidence checks passed
Residual risk 0.05 = Change Risk (0.36) × (1 − Review Confidence (0.87)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 182 lines diff across 2 files
0.36
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.83 · 5 substantive comment(s)
0.83
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
86%
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.312
Real PR Conversation Timeline
11 items
k8s-ci-robot k8s-ci-robot commented on Feb 24, 2026 20:58 UTC
Contributor

Hi @jgreeer. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

<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.
</details>

Stevenjin8 Stevenjin8 commented on Feb 24, 2026 23:48 UTC
Contributor

@jgreer could you add an integration test

Stevenjin8 Stevenjin8 commented on Feb 25, 2026 15:57 UTC
Contributor

/ok-to-test

Stevenjin8 Stevenjin8 commented on Feb 26, 2026 20:49 UTC
Contributor

/approve

bexxmodd bexxmodd commented on code on Mar 04, 2026 18:28 UTC
Code Review
pkg/i2gw/providers/ingressnginx/canary.go:1
@@ -150,17 +153,19 @@ func canaryFeature(ingresses []networkingv1.Ingress, _ map[types.NamespacedName]
 						if config.headerValue == "" {
 							nonCanaryBackendCopy := nonCanaryBackend
 							nonCanaryBackendCopy.Weight = nil
-							neverRule := gatewayv1.HTTPRouteRule{
-								Matches: []gatewayv1.HTTPRouteMatch{
+							neverMatch := gatewayv1.HTTPRouteMatch{
+								Headers: []gatewayv1.HTTPHeaderMatch{
 									{
-										Headers: []gatewayv1.HTTPHeaderMatch{
-											{
-												Name:  gatewayv1.HTTPHeaderName(config.header),
-												Value: "never",
-											},
-										},
+										Name:  gatewayv1.HTTPHeaderName(config.header),
+										Value: "never",
 									},
 								},
+							}
+							if len(existingMatches) > 0 && existingMatches[0].Path != nil {
+								neverMatch.Path = existingMatches[0].Path
+							}
+							neverRule := gatewayv1.HTTPRouteRule{
+								Matches:     []gatewayv1.HTTPRouteMatch{neverMatch},
 								BackendRefs: []gatewayv1.HTTPBackendRef{nonCanaryBackendCopy},
 							}

this logic is repeated on lines 142-149. We can extract this into a helper function to reduce the size of canaryFeature function which is already quite long.

jgreeer jgreeer commented on code on Mar 04, 2026 18:42 UTC
Code Review
pkg/i2gw/providers/ingressnginx/canary.go:1
@@ -150,17 +153,19 @@ func canaryFeature(ingresses []networkingv1.Ingress, _ map[types.NamespacedName]
 						if config.headerValue == "" {
 							nonCanaryBackendCopy := nonCanaryBackend
 							nonCanaryBackendCopy.Weight = nil
-							neverRule := gatewayv1.HTTPRouteRule{
-								Matches: []gatewayv1.HTTPRouteMatch{
+							neverMatch := gatewayv1.HTTPRouteMatch{
+								Headers: []gatewayv1.HTTPHeaderMatch{
 									{
-										Headers: []gatewayv1.HTTPHeaderMatch{
-											{
-												Name:  gatewayv1.HTTPHeaderName(config.header),
-												Value: "never",
-											},
-										},
+										Name:  gatewayv1.HTTPHeaderName(config.header),
+										Value: "never",
 									},
 								},
+							}
+							if len(existingMatches) > 0 && existingMatches[0].Path != nil {
+								neverMatch.Path = existingMatches[0].Path
+							}
+							neverRule := gatewayv1.HTTPRouteRule{
+								Matches:     []gatewayv1.HTTPRouteMatch{neverMatch},
 								BackendRefs: []gatewayv1.HTTPBackendRef{nonCanaryBackendCopy},
 							}

will refactor this

bexxmodd bexxmodd approved these changes on Mar 04, 2026 20:15 UTC
Approved Reviewer

Approved these changes.

k8s-ci-robot k8s-ci-robot commented on Mar 04, 2026 20:15 UTC
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: <a href="https://github.com/kubernetes-sigs/ingress2gateway/pull/365#pullrequestreview-3891762151" title="Approved">bexxmodd</a>, <a href="https://github.com/kubernetes-sigs/ingress2gateway/pull/365#" title="Author self-approved">jgreeer</a>, <a href="https://github.com/kubernetes-sigs/ingress2gateway/pull/365#issuecomment-3969154943" title="Approved">Stevenjin8</a>

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

The pull request process is described here

<details >
Needs approval from an approver in each of these files:

  • ~~OWNERS~~ [Stevenjin8]
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":[]} -->

    Stevenjin8 Stevenjin8 commented on Mar 04, 2026 21:02 UTC
    Contributor

    @bexxmodd can you lgtm

    bexxmodd bexxmodd commented on Mar 04, 2026 21:21 UTC
    Contributor

    /lgtm

    Reviewers
    Assignees
    jgreeer jgreeer
    Labels
    risk: low confidence: 86.6% 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: 35.6% (MEDIUM) · Higher = larger blast radius
    35.6%
    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: 86.6% · Lower = rushed or shallow review
    86.6%
    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: 4.8% · Safe to merge
    4.8%