Error in K8S ipv6 addresses validation `CommonUtilization.valid_chars()` / `VALID_CHARS_RE`
akaRem opened this issue · 2 comments
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
As a temporary solution, you can override the ENV variable in K8S pod configs, which works, with a hostname instead of the assigned IP.
I'll forward this along to the architecture group and we'll get all the agents updated to support ipv6 for K8s.