Skip to content

Backport of (apigw/httproute) Add support to disable traffic with weight 0 in services into release/1.22.x#23305

Merged
sujay-hashicorp merged 1 commit into
release/1.22.xfrom
backport/sujay/fix/route-weight-0/amazingly-prepared-raptor
Mar 11, 2026
Merged

Backport of (apigw/httproute) Add support to disable traffic with weight 0 in services into release/1.22.x#23305
sujay-hashicorp merged 1 commit into
release/1.22.xfrom
backport/sujay/fix/route-weight-0/amazingly-prepared-raptor

Conversation

@hc-github-team-consul-core
Copy link
Copy Markdown
Collaborator

Backport

This PR is auto-generated from #23216 to be assessed for backporting due to the inclusion of the label backport/1.22.

The below text is copied from the body of the original PR.


Description

This PR fixes Consul API Gateway behavior for Kubernetes HTTPRoute backends with weight: 0.

Previously, HTTPRoute normalization converted all weight <= 0 values to 1, which caused explicit weight: 0 backends to still receive traffic. This conflicted with Gateway API expectations and customer-observed behavior.

This change updates normalization logic to:

  • Preserve explicit weight: 0 (so zero-weight backends can be excluded from traffic).
  • Continue normalizing negative weights to 1.

Links

Tests

  • With this fix, the routes support definition of 0 weight services.
  • The instance with weight: 0 does not receive any traffic.
HTTPRoute config output

$ consul config read -kind http-route -name quill-route

{
    "Kind": "http-route",
    "Name": "quill-route",
    "Parents": [
        {
            "Kind": "api-gateway",
            "Name": "api-gateway",
            "SectionName": "http-listener"
        }
    ],
    "Rules": [
        {
            "Filters": {
                "Headers": null,
                "URLRewrite": null,
                "RetryFilter": null,
                "TimeoutFilter": null,
                "JWT": null
            },
            "ResponseFilters": {
                "Headers": null
            },
            "Matches": [
                {
                    "Headers": null,
                    "Method": "",
                    "Path": {
                        "Match": "prefix",
                        "Value": "/"
                    },
                    "Query": null
                }
            ],
            "Services": [
                {
                    "Name": "quill-v1",
                    "Weight": 0,
                    "Filters": {
                        "Headers": null,
                        "URLRewrite": null,
                        "RetryFilter": null,
                        "TimeoutFilter": null,
                        "JWT": null
                    },
                    "ResponseFilters": {
                        "Headers": null
                    }
                },
                {
                    "Name": "quill-v2",
                    "Weight": 100,
                    "Filters": {
                        "Headers": null,
                        "URLRewrite": null,
                        "RetryFilter": null,
                        "TimeoutFilter": null,
                        "JWT": null
                    },
                    "ResponseFilters": {
                        "Headers": null
                    }
                }
            ]
        }
    ],
    "Hostnames": null,
    "CreateIndex": 43,
    "ModifyIndex": 80,
    "Status": {
        "Conditions": [
            {
                "Type": "Accepted",
                "Status": "True",
                "Reason": "Accepted",
                "Message": "route is valid",
                "Resource": {
                    "Kind": "",
                    "Name": "",
                    "SectionName": ""
                },
                "LastTransitionTime": "2026-02-16T08:17:57.943208Z"
            },
            {
                "Type": "Bound",
                "Status": "True",
                "Reason": "Bound",
                "Message": "successfully bound route",
                "Resource": {
                    "Kind": "api-gateway",
                    "Name": "api-gateway",
                    "SectionName": "http-listener"
                },
                "LastTransitionTime": "2026-02-16T08:17:57.943215Z"
            }
        ]
    }
}

Traffic Distribution

case 1:
Services = [
  {
    Name = "quill-v1"
    Weight = 100
  },
  {
    Name = "quill-v2"
    Weight = 100
  }
]
Screenshot 2026-02-16 at 14 29 59
case 2:
Services = [
  {
    Name = "quill-v1"
    Weight = 0
  },
  {
    Name = "quill-v2"
    Weight = 100
  }
]
Screenshot 2026-02-16 at 14 32 55

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.


Overview of commits

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Auto approved Consul Bot automated PR

@sujay-hashicorp sujay-hashicorp merged commit 6adb65a into release/1.22.x Mar 11, 2026
175 of 179 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants