newrelic / newrelic/newrelic-python-agent
Error in K8S ipv6 addresses validation `CommonUtilization.valid_chars()` / `VALID_CHARS_RE`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 210
- Forks
- 137
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 12
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in newrelic/common/utilization.py at VALID_CHARS_RE (line 27), valid_chars() (line 127), and KubernetesUtilization detection (lines 153-157). Reproduce with KUBERNETES_SERVICE_HOST set to fd95:b6e3:daad::1 and verify that IPv6 Kubernetes addresses are accepted while existing validation remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kubernetes, python
- Domain
- infrastructure, observability-sre
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100