Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions kr8s/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ async def _check_version(self) -> None:
)
return

# We only care about major/minor version differences, so we truncate the patch version
version = parse_version(f"{version.major}.{version.minor}")
if (
version < KUBERNETES_MINIMUM_SUPPORTED_VERSION
or version > KUBERNETES_MAXIMUM_SUPPORTED_VERSION
Expand Down
25 changes: 25 additions & 0 deletions kr8s/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: BSD 3-Clause License
import queue
import threading
import warnings
from contextlib import asynccontextmanager
from unittest.mock import AsyncMock

Expand All @@ -11,6 +12,10 @@
import kr8s
import kr8s.asyncio
from kr8s._async_utils import anext
from kr8s._constants import (
KUBERNETES_MAXIMUM_SUPPORTED_VERSION,
KUBERNETES_MINIMUM_SUPPORTED_VERSION,
)
from kr8s._exceptions import APITimeoutError
from kr8s.asyncio.objects import Pod, Service, Table
from kr8s.objects import Pod as SyncPod
Expand Down Expand Up @@ -520,6 +525,7 @@ def test_create_sync(example_pod_spec, example_service_spec):
"v1.27.0",
"1.27.0-eks-113cf36",
"v1.27.0-eks-113cf36",
f"{KUBERNETES_MAXIMUM_SUPPORTED_VERSION.major}.{KUBERNETES_MAXIMUM_SUPPORTED_VERSION.minor+1}",
"asdkjhaskdjhasd",
],
)
Expand All @@ -532,6 +538,25 @@ async def test_bad_kubernetes_version(version):
api.async_version = keep


@pytest.mark.parametrize(
"version",
[
str(KUBERNETES_MINIMUM_SUPPORTED_VERSION),
str(KUBERNETES_MAXIMUM_SUPPORTED_VERSION),
f"{KUBERNETES_MAXIMUM_SUPPORTED_VERSION.major}.{KUBERNETES_MAXIMUM_SUPPORTED_VERSION.minor}.15",
f"{KUBERNETES_MINIMUM_SUPPORTED_VERSION}-eks-113cf36",
],
)
async def test_good_kubernetes_version(version):
api = await kr8s.asyncio.api()
keep = api.async_version
api.async_version = AsyncMock(return_value={"gitVersion": version})
with warnings.catch_warnings(record=True) as w:
await api._check_version()
assert w == []
api.async_version = keep


async def test_crd_caching(example_crd_spec):
api = await kr8s.asyncio.api()

Expand Down