Skip to content

Add port in HostDBRecord#12856

Merged
masaori335 merged 3 commits intoapache:masterfrom
masaori335:hostdb-status-port
Feb 5, 2026
Merged

Add port in HostDBRecord#12856
masaori335 merged 3 commits intoapache:masterfrom
masaori335:hostdb-status-port

Conversation

@masaori335
Copy link
Contributor

To clarify HostDB records by traffic_ctl hostdb status cmd.

Prior to the change, port is one of key to calculate hash. However, HostDBRecord doesn't store it, so in the list of HostDBRecored, it was unclear which entry is which.

New traffic_ctl hostdb status result is below. port and hash_key is the new fields.

$ traffic_ctl hostdb status | jq .
{
  "metadata": {
    "timestamp": "1770159540",
    "version": "Apache Traffic Server - traffic_server - 10.2.0 - (build # 0 on Feb  3 2026 at 14:35:43)"
  },
  "partitions": [
    {
      "id": "53",
      "records": [
        {
          "metadata": {
            "name": "example.com",
            "port": "80", ///< new field
            "type": "ADDR",
            "af_familiy": "AF_INET",
            "failed": "false",
            "ip_timestamp": "1770159530936784",
            "hash_key": "1577356654191421173" ///< new field
          },
          "info": [
            {
              "ip": "127.0.0.1",
              "health": {
                "last_failure": "0",
                "fail_count": "0"
              }
            }
          ]
        }
      ]
    },
    {
      "id": "59",
      "records": [
        {
          "metadata": {
            "name": "example.com",
            "port": "443", ///< new field
            "type": "ADDR",
            "af_familiy": "AF_INET",
            "failed": "false",
            "ip_timestamp": "1770159532935310",
            "hash_key": "16495443420271430523" ///< new field
          },
          "info": [
            {
              "ip": "127.0.0.1",
              "health": {
                "last_failure": "0",
                "fail_count": "0"
              }
            }
          ]
        }
      ]
    }
  ]
}

@masaori335 masaori335 added this to the 10.2.0 milestone Feb 3, 2026
@masaori335 masaori335 self-assigned this Feb 3, 2026
@masaori335 masaori335 added HostDB traffic_ctl traffic_ctl related work. labels Feb 3, 2026
#include "swoc/Scalar.h"

HostDBRecord *
HostDBRecord::alloc(swoc::TextView query_name, unsigned int rr_count, size_t srv_name_size)
Copy link
Contributor Author

@masaori335 masaori335 Feb 3, 2026

Choose a reason for hiding this comment

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

Note: this is duplicated change with in HostDB.cc. However, this avoids issue with ld. #12851

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds port number tracking to HostDBRecord to improve the clarity of traffic_ctl hostdb status output. Since port is part of the hash key calculation but wasn't previously stored in the record, it was unclear which entry corresponded to which port in the output.

Changes:

  • Added _port field to HostDBRecord class to store the port number
  • Updated HostDBRecord::alloc() signature to accept port parameter
  • Enhanced JSON output with "port" and "hash_key" fields for better record identification
  • Added empty partition filtering to avoid outputting empty partitions in JSON

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
include/iocore/hostdb/HostDBProcessor.h Added _port private field, port() getter method, and updated alloc() signature with port parameter
src/iocore/hostdb/HostDB.cc Updated alloc() implementation to initialize _port field and modified callsites to pass port values
src/iocore/hostdb/test_HostFile.cc Updated test version of alloc() to match new signature
src/mgmt/rpc/handlers/hostdb/HostDB.cc Added port and hash_key to JSON output metadata and added empty partition filtering

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@brbzull0 brbzull0 left a comment

Choose a reason for hiding this comment

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

looks good!

@masaori335 masaori335 merged commit fea8566 into apache:master Feb 5, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

HostDB traffic_ctl traffic_ctl related work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants