Skip to content

Commit

Permalink
16419 FIX Support IPv6/IPv4 Dual Stack
Browse files Browse the repository at this point in the history
For Kubernetes clusters running a IPv6/IPv4 dual stack, the collectors would display the following
error:

C+:
File "/home/solo/git/checkmk_kube_agent/.venv/lib/python3.10/site-packages/requests/sessions.py", line 794, in get_adapter
    raise InvalidSchema(f"No connection adapters were found for {url!r}")
requests.exceptions.InvalidSchema: No connection adapters were found for '::'
C-:

This has been fixed.

Change-Id: I2e09841bb307393115caa21be7b277c3a392ab22
  • Loading branch information
SoloJacobs committed Apr 8, 2024
1 parent 4dcdcaa commit f487942
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .werks/16419
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Title: Support IPv6/IPv4 Dual Stack
Class: fix
Compatible: compat
Component: cluster-collector
Date: 1712156163
Knowledge: doc
Level: 1
Version: 2.0.0-alpha.1

For Kubernetes clusters running a IPv6/IPv4 dual stack, the node collectors would display the
following error:

C+:
File "/home/solo/git/checkmk_kube_agent/.venv/lib/python3.10/site-packages/requests/sessions.py", line 794, in get_adapter
raise InvalidSchema(f"No connection adapters were found for {url!r}")
requests.exceptions.InvalidSchema: No connection adapters were found for '::'
C-:

This has been fixed.

Moreover, the cluster collector was hardcoded to bind to a socket with address family AF_INET. This
is now configurable with the values.yaml file via the option '.clusterCollector.address'.
2 changes: 1 addition & 1 deletion src/checkmk_kube_agent/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def _check_token_review_content(
return None


def _join_host_port(host: str, port: str) -> str: # pragma: no cover
def _join_host_port(host: str, port: str) -> str:
# reference implementation
# https://cs.opensource.google/go/go/+/refs/tags/go1.22.1:src/net/ipsock.go;l=235
if ":" in host:
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
StandaloneApplication,
TokenError,
_init_app_state,
_join_host_port,
_raise_from_token_error,
app,
authenticate,
Expand Down Expand Up @@ -841,3 +842,10 @@ def test_send_metadata(
machine_sections_collection.metadata,
],
)


def test_join_host_port() -> None:
"""Test IpV4 and IpV6."""

assert _join_host_port("127.0.0.1", "8000") == "127.0.0.1:8000"
assert _join_host_port("::", "8000") == "[::]:8000"

0 comments on commit f487942

Please sign in to comment.