Skip to content

Error in K8S ipv6 addresses validation CommonUtilization.valid_chars() / VALID_CHARS_RE #1001

@akaRem

Description

@akaRem

Description
When running in K8S with ipv6 addresses, client fails with error like Invalid "kubernetes" data ("kubernetes_service_host"): "fd95:b6e3:daad::1"

Expected Behavior
Agent should accept ipv6 addresses

Troubleshooting or NR Diag results
After looking at code and at environment, I found that K8S injects the following variables:

...
KUBERNETES_SERVICE_HOST=fd95:b6e3:daad::1
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_ADDR=fd95:b6e3:daad::1
...

The error happens in KubernetesUtilization class in detection process:
Detection https://github.com/newrelic/newrelic-python-agent/blob/main/newrelic/common/utilization.py#L153-L157 consist of fetching the data (reading envvar KUBERNETES_SERVICE_HOST) then validating it for correctness, one of the steps https://github.com/newrelic/newrelic-python-agent/blob/main/newrelic/common/utilization.py#L127 is checking valid chars https://github.com/newrelic/newrelic-python-agent/blob/main/newrelic/common/utilization.py#L27 , the agent does not expect : and fails

Steps to Reproduce
Run in K8S with ipv6

Your Environment
EKS with ipv6

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestRequest for new or enhanced features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions