Skip to content

feat(dns): Add configurable DNS SRV priority on a per-service-instance basis. - #23729

Open
drawks wants to merge 1 commit into
hashicorp:mainfrom
drawks:issue-23728
Open

feat(dns): Add configurable DNS SRV priority on a per-service-instance basis.#23729
drawks wants to merge 1 commit into
hashicorp:mainfrom
drawks:issue-23728

Conversation

@drawks

@drawks drawks commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

This PR introduces an optional priority field (0-65535) for service definitions to natively support RFC 2782 failover routing.

DNS SRV responses use the configured value for node, IP, FQDN, and prepared-query results; A/AAAA responses remain unchanged.

This change only affects SRV record construction. It does not change health filtering, weight calculation or prepared-query result selection.

When priority is unset the default priority is left at 1 preserving existing behavior. Explicit priority 0 remains distinguishable from an unset value.

While this feature is quite small it required a lot of mechanical fiddling; the implementation follows the service-definition config checklist and was modeled after #22769 and #16581 which both added a service config field.

The new priority field has been plumbed through the service registration lifecycle, from the API and protobuf layers down to the catalog and peering state.

There is no data migration. Reverting this PR is sufficient to roll back the feature; older code will continue using the existing fixed SRV priority.

Testing & Reproduction steps

  1. Checkout to the branch
  2. Start a consul dev server go run . agent -dev from the root directory.
  3. Register a service with priority set consul services register ./myservice.hcl
service {
    name = "my-service"
    id = "my-service-id"
    port = 8080
    priority = 100
}
  1. Query the service through curl localhost:8500/v1/catalog/service/my-service
<snip>
        "ServiceKind": "",
        "ServiceID": "my-service-id",
        "ServiceName": "my-service",
        "ServiceTags": [],
        "ServiceAddress": "",
        "ServiceWeights": {
            "Passing": 1,
            "Warning": 1
        },
        "ServicePriority": 100,
        "ServiceMeta": {},
        "ServicePort": 8080,
<snip>
  1. Query SRV records via DNS dig @127.0.0.1 -p 8600 my-service.service.consul. SRV
;; QUESTION SECTION:
;my-service.service.consul.	IN	SRV

;; ANSWER SECTION:
my-service.service.consul. 0	IN	SRV	100 1 8080 baddad-devthang.node.dc1.consul.

Links

Resolves #23728

PR Checklist

  • updated test coverage
  • external facing docs updated - will update in a separate PR
  • appropriate backport labels added - N/A; no backport is currently planned for this new feature
  • 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.
    • No additional rollback procedure or data migration is required.
  • If applicable, I've documented the impact of any changes to security controls.
    • Not applicable. This change does not modify access control, authentication, authorization, audit logging, or other security controls.

@github-actions github-actions Bot added theme/api Relating to the HTTP API interface theme/config Relating to Consul Agent configuration, including reloading labels Jul 11, 2026
@drawks
drawks marked this pull request as ready for review July 11, 2026 01:22
@drawks
drawks requested review from a team as code owners July 11, 2026 01:22
@drawks

drawks commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

@nitin-sachdev-29 @hashi-derek @srahul3 I see the 3 of you as reviewers and/or code owners in other similar PRs that have been merged. Is there anything I can do to get a reviewer assigned to this?

@drawks

drawks commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

ping... Anyone want to give me a review here?

I hate to sound like a broken record, but it is still kind of maddening that hashicorp maintainers are so generally unresponsive to external contributions, while clearly being active in various other PRs. My last, single line PR, took 2 months before it got a review. I'll repeat what I said then, It is ridiculous that hashicorp was very eager to send me a t-shirt that proclaims that I am a "core contributor" while also seeming to have no interest in even commenting on my contributions.

  1. Add optional per-service priority to config, registration, catalog,
     transaction, and protobuf service models.
  2. Use configured priorities in SRV responses while preserving the
     default priority of 1.

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

Labels

theme/api Relating to the HTTP API interface theme/config Relating to Consul Agent configuration, including reloading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support configurable "priority" field for services, expose via DNS for RFC compliant behavior

1 participant