Skip to content

prometheus sizer breaks when hostname is an ipv6 address #96

@csnook

Description

@csnook

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions