Skip to content

Commit

Permalink
Fixed a bug where podIP and hostIP weren't getting populated in reads…
Browse files Browse the repository at this point in the history
… from K8s. This has been corrected, and tests have been added to ensure that this continues to work properly. A classifier has also been updated to reflect that this is no longer an 'alpha' status package.
  • Loading branch information
haxsaw committed Apr 28, 2023
1 parent d1a00be commit a2146af
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
|logo|


Version 1.0.0
Version 1.0.1

|travis| |license| |versions| |coverage|

Expand Down
2 changes: 1 addition & 1 deletion hikaru/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
if type(v) == type and
k != HikaruBase]

__version__ = "1.0.0"
__version__ = "1.0.1"

__all__ = ["HikaruBase", "CatalogEntry", "get_json", "get_yaml", "get_python_source",
"get_clean_dict", "load_full_yaml", "get_processors", "TypeWarning",
Expand Down
5 changes: 3 additions & 2 deletions hikaru/naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,14 @@ def camel_to_pep8(name: str) -> str:
# turn them back into the upper case version without the leading '_'
if result[0] == "_":
result = result[1].upper() + result[2:]
# icky patch for when we've split apart 'API', 'CSI', or 'V<number>'
# icky patch for when we've split apart names that have a sequence of cap'd letters
return (result.replace("a_p_i", "api").replace("c_s_i", "csi").
replace('v_1', 'v1').replace('v_2', 'v2').replace('beta_1', 'beta1').
replace('beta_2', 'beta2').replace('alpha_1', 'alpha1').
replace('f_q_d_n', 'fqdn').replace('u_u_i_d', 'uuid').
replace('c_i_d_r', 'cidr').
replace('_i_d', '_id').replace('t_l_s', 'tls'))
replace('_i_d', '_id').replace('t_l_s', 'tls').replace('host_i_p', 'host_ip').
replace('pod_i_p', 'pod_ip'))


# mapping the group in apiVersion to the swagger group string
Expand Down
12 changes: 12 additions & 0 deletions release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
Release Notes
*************

v1.0.1
------

*Default K8s release:* 26.x

*Deprecated K8s release:* 23.x

**Bugfix release**

This is a quick release to fix a bug where PodStatus was not properly populating the podIP
and hostIP attributes. This has now been corrected.

v1.0.0
-------

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup

__version__ = "1.0.0"
__version__ = "1.0.1"


def get_long_desc():
Expand Down Expand Up @@ -60,7 +60,7 @@ def get_requirements():
keywords=["Kubernetes", "modelling", "YAML", "JSON", "modeling",
"translate", "translator", "reformatter", "transform"],
install_requires=get_requirements(),
classifiers=["Development Status :: 3 - Alpha",
classifiers=["Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Financial and Insurance Industry",
"Intended Audience :: Information Technology",
Expand Down
34 changes: 34 additions & 0 deletions tests/e2e/integration_rel_1_23.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import base64
from os import getcwd
from pathlib import Path
import re
import time
from typing import cast, Optional
from unittest import SkipTest
Expand Down Expand Up @@ -142,6 +143,39 @@ def test02():
_ = Pod.deleteNamespacedPod(p.metadata.name, e2e_namespace)


ip_regex = r"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"


def test02a():
"""
Create a pod and check for hostIP and podIP; must arrive w/in a minute
"""
path = base_path / "core-pod.yaml"
p: Pod = cast(Pod, load_full_yaml(path=str(path))[0])
p.metadata.name += '-2a'
res = p.createNamespacedPod(e2e_namespace)
try:
assert res.obj and isinstance(res.obj, Pod)
found_podIP: bool = False
found_hostIP: bool = False
for i in range(60):
time.sleep(1)
res = Pod.readNamespacedPod(p.metadata.name, e2e_namespace)
assert res.obj and isinstance(res.obj, Pod)
if not found_podIP and res.obj.status.podIP:
assert re.match(ip_regex, res.obj.status.podIP)
found_podIP = True
if not found_hostIP and res.obj.status.hostIP:
assert re.match(ip_regex, res.obj.status.hostIP)
found_hostIP = True
if found_hostIP and found_podIP:
break
else:
assert False, f"Found hostIP: {found_hostIP}, found podIP: {found_podIP}"
finally:
_ = Pod.deleteNamespacedPod(p.metadata.name, e2e_namespace)


def test03():
"""
Create, read, and delete a Service
Expand Down
34 changes: 34 additions & 0 deletions tests/e2e/integration_rel_1_24.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import base64
from os import getcwd
from pathlib import Path
import re
import time
from typing import cast, Optional
from unittest import SkipTest
Expand Down Expand Up @@ -142,6 +143,39 @@ def test02():
_ = Pod.deleteNamespacedPod(p.metadata.name, e2e_namespace)


ip_regex = r"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"


def test02a():
"""
Create a pod and check for hostIP and podIP; must arrive w/in a minute
"""
path = base_path / "core-pod.yaml"
p: Pod = cast(Pod, load_full_yaml(path=str(path))[0])
p.metadata.name += '-2a'
res = p.createNamespacedPod(e2e_namespace)
try:
assert res.obj and isinstance(res.obj, Pod)
found_podIP: bool = False
found_hostIP: bool = False
for i in range(60):
time.sleep(1)
res = Pod.readNamespacedPod(p.metadata.name, e2e_namespace)
assert res.obj and isinstance(res.obj, Pod)
if not found_podIP and res.obj.status.podIP:
assert re.match(ip_regex, res.obj.status.podIP)
found_podIP = True
if not found_hostIP and res.obj.status.hostIP:
assert re.match(ip_regex, res.obj.status.hostIP)
found_hostIP = True
if found_hostIP and found_podIP:
break
else:
assert False, f"Found hostIP: {found_hostIP}, found podIP: {found_podIP}"
finally:
_ = Pod.deleteNamespacedPod(p.metadata.name, e2e_namespace)


def test03():
"""
Create, read, and delete a Service
Expand Down
34 changes: 34 additions & 0 deletions tests/e2e/integration_rel_1_25.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import base64
from os import getcwd
from pathlib import Path
import re
import time
from typing import cast, Optional
from unittest import SkipTest
Expand Down Expand Up @@ -142,6 +143,39 @@ def test02():
_ = Pod.deleteNamespacedPod(p.metadata.name, e2e_namespace)


ip_regex = r"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"


def test02a():
"""
Create a pod and check for hostIP and podIP; must arrive w/in a minute
"""
path = base_path / "core-pod.yaml"
p: Pod = cast(Pod, load_full_yaml(path=str(path))[0])
p.metadata.name += '-2a'
res = p.createNamespacedPod(e2e_namespace)
try:
assert res.obj and isinstance(res.obj, Pod)
found_podIP: bool = False
found_hostIP: bool = False
for i in range(60):
time.sleep(1)
res = Pod.readNamespacedPod(p.metadata.name, e2e_namespace)
assert res.obj and isinstance(res.obj, Pod)
if not found_podIP and res.obj.status.podIP:
assert re.match(ip_regex, res.obj.status.podIP)
found_podIP = True
if not found_hostIP and res.obj.status.hostIP:
assert re.match(ip_regex, res.obj.status.hostIP)
found_hostIP = True
if found_hostIP and found_podIP:
break
else:
assert False, f"Found hostIP: {found_hostIP}, found podIP: {found_podIP}"
finally:
_ = Pod.deleteNamespacedPod(p.metadata.name, e2e_namespace)


def test03():
"""
Create, read, and delete a Service
Expand Down
34 changes: 34 additions & 0 deletions tests/e2e/integration_rel_1_26.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
It is based on having access to a Linux install of k3s.
"""
import base64
import re
from os import getcwd
from pathlib import Path
import time
Expand Down Expand Up @@ -142,6 +143,39 @@ def test02():
_ = Pod.deleteNamespacedPod(p.metadata.name, e2e_namespace)


ip_regex = r"[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"


def test02a():
"""
Create a pod and check for hostIP and podIP; must arrive w/in a minute
"""
path = base_path / "core-pod.yaml"
p: Pod = cast(Pod, load_full_yaml(path=str(path))[0])
p.metadata.name += '-2a'
res = p.createNamespacedPod(e2e_namespace)
try:
assert res.obj and isinstance(res.obj, Pod)
found_podIP: bool = False
found_hostIP: bool = False
for i in range(60):
time.sleep(1)
res = Pod.readNamespacedPod(p.metadata.name, e2e_namespace)
assert res.obj and isinstance(res.obj, Pod)
if not found_podIP and res.obj.status.podIP:
assert re.match(ip_regex, res.obj.status.podIP)
found_podIP = True
if not found_hostIP and res.obj.status.hostIP:
assert re.match(ip_regex, res.obj.status.hostIP)
found_hostIP = True
if found_hostIP and found_podIP:
break
else:
assert False, f"Found hostIP: {found_hostIP}, found podIP: {found_podIP}"
finally:
_ = Pod.deleteNamespacedPod(p.metadata.name, e2e_namespace)


def test03():
"""
Create, read, and delete a Service
Expand Down

0 comments on commit a2146af

Please sign in to comment.