linkedin / linkedin/kafka-tools

prometheus sizer breaks when hostname is an ipv6 address

Open
#96 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
599
Forks
145
PR merge metrics
No merged PRs in 30d

Description

The prometheus sizer renders the prometheus url with this string interpolation:

`url = 'http://{}:{}{}'.format(hostname, port, path)`

Unfortunately, in the case where hostname is an ipv6 address, this causes the port number to be interpreted as part of the ipv6 address, causing connections to fail. The fix requires adding square brackets around the hostname when it's an ipv6 address.

I'm still working on the most graceful way to implement the fix. Pulling in an ipv6 address validating library would probably be an unnecessary dependency. Adding brackets around the hostname unconditionally isn't expected to work in general, but it might for urlopen. Adding brackets whenever the hostname has a colon in it should suffice, but could break cases where someone uses username:password@hostname as the hostname for HTTP basic auth. Adding brackets whenever the hostname has two colons in it should work fine (all ipv6 addresses have at least two colons), and I can't think of a downside, but I need to test.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the prometheus sizer code containing the shown URL interpolation and inspect how hostname values are handled. Exercise URL construction with an IPv6 hostname and existing hostname formats, then verify that the generated URL connects successfully with the port parsed separately.

Written by the indexing model from the issue text.

Assessment

Tech stack
prometheus, python
Domain
observability
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.