Skip to content

Commit 721da0f

Browse files
authored
Merge pull request #280 from KatharaFramework/develop
Kathará v3.7.4
2 parents d9d60aa + 1c487f9 commit 721da0f

File tree

21 files changed

+354
-63
lines changed

21 files changed

+354
-63
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ body:
2222
attributes:
2323
label: Kathará Version
2424
description: "Please provide the Kathará version you are using (`kathara -v`)."
25-
placeholder: "3.7.3"
25+
placeholder: "3.7.4"
2626
validations:
2727
required: true
2828
- type: textarea

SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ We release patches for security vulnerabilities only for the last version:
66

77
| Version | Supported Versions |
88
|---------|--------------------|
9-
| 3.7.3 | :white_check_mark: |
9+
| 3.7.4 | :white_check_mark: |
1010

1111
## Reporting a Vulnerability
1212

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "kathara"
3-
version = "3.7.3"
3+
version = "3.7.4"
44
description = "A lightweight container-based network emulation tool."
55
readme = "README.md"
66
requires-python = ">=3.9"

scripts/Linux-Deb/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/make -f
22

3-
VERSION=3.7.3
3+
VERSION=3.7.4
44
DEBIAN_PACKAGE_VERSION=1
55
LAUNCHPAD_NAME=user
66
NO_BINARY_PACKAGES=pyroute2|pyuv|deepdiff

scripts/Linux-Deb/debian/changelog

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
kathara (__VERSION__-__DEBIAN_PACKAGE_VERSION____UBUNTU_VERSION__) __UBUNTU_VERSION__; urgency=low
22

3-
* New CLI UI using "rich" library!
4-
* (Docker) Show progress during Docker image pull, similarly to the official "docker pull" command
5-
* (Docker) It is now correctly possible to specify a "linux/amd64" image on Apple Silicon (which can be run using Rosetta)
6-
* Add "gnome-terminal" as official supported terminal emulator
7-
* Several API improvements and bug fixes
3+
* (Docker) Fix "rp_filter" on "eth0" that was causing startup errors on some distributions
4+
* (Megalos) Fix watch methods while starting/stopping devices that were causing "lstart"/"lclean" to hang indefinitely
5+
* Minor fixes
86

97
-- Kathara Team <[email protected]> __DATE__

scripts/Linux-Pkg/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/make -f
22

3-
VERSION=3.7.3
3+
VERSION=3.7.4
44
PACKAGE_VERSION=1
55
AUR_NAME=user
66
+3-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
__DATE__ Kathara Team <******@kathara.org>
22

33
* Release v__VERSION__
4-
* New CLI UI using "rich" library!
5-
* (Docker) Show progress during Docker image pull, similarly to the official "docker pull" command
6-
* (Docker) It is now correctly possible to specify a "linux/amd64" image on Apple Silicon (which can be run using Rosetta)
7-
* Add "gnome-terminal" as official supported terminal emulator
8-
* Several API improvements and bug fixes
4+
* (Docker) Fix "rp_filter" on "eth0" that was causing startup errors on some distributions
5+
* (Megalos) Fix watch methods while starting/stopping devices that were causing "lstart"/"lclean" to hang indefinitely
6+
* Minor fixes

scripts/Linux-Rpm/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/make -f
22

3-
VERSION=3.7.3
3+
VERSION=3.7.4
44
PACKAGE_VERSION=1
55

66
.PHONY: all clean docker-build-image prepare-source prepare-man-pages prepare-bash-completion pack-source build

scripts/Linux-Rpm/rpm/kathara.spec

+3-5
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ chmod g+s %{_libdir}/kathara/kathara
6868

6969
%changelog
7070
* __DATE__ Kathara Team <******@kathara.org> - __VERSION__-__PACKAGE_VERSION__
71-
- New CLI UI using "rich" library!
72-
- (Docker) Show progress during Docker image pull, similarly to the official "docker pull" command
73-
- (Docker) It is now correctly possible to specify a "linux/amd64" image on Apple Silicon (which can be run using Rosetta)
74-
- Add "gnome-terminal" as official supported terminal emulator
75-
- Several API improvements and bug fixes
71+
- (Docker) Fix "rp_filter" on "eth0" that was causing startup errors on some distributions
72+
- (Megalos) Fix watch methods while starting/stopping devices that were causing "lstart"/"lclean" to hang indefinitely
73+
- Minor fixes

scripts/OSX/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/make -s
22

33
PRODUCT=Kathara
4-
VERSION=3.7.3
4+
VERSION=3.7.4
55
TARGET_DIRECTORY=Output
66
APPLE_DEVELOPER_CERTIFICATE_ID=FakeID
77
ROFF_DIR=../../docs/Roff

scripts/Windows/installer.iss

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "Kathara"
5-
#define MyAppVersion "3.7.3"
5+
#define MyAppVersion "3.7.4"
66
#define MyAppPublisher "Kathara Team"
77
#define MyAppURL "https://www.kathara.org"
88
#define MyAppExeName "kathara.exe"

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = kathara
3-
version = 3.7.3
3+
version = 3.7.4
44
author = Kathara Framework
55
author_email = [email protected]
66
description = A lightweight container-based network emulation tool.

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
package_dir={'': 'src'},
88
packages=find_packages('src'),
99
py_modules=['kathara'],
10-
version='3.7.3',
10+
version='3.7.4',
1111
license='gpl-3.0',
1212
description='A lightweight container-based network emulation tool.',
1313
author='Kathara Framework',
1414
author_email='[email protected]',
1515
url='https://www.kathara.org',
16-
download_url='https://github.com/KatharaFramework/Kathara/archive/refs/tags/3.7.3.tar.gz',
16+
download_url='https://github.com/KatharaFramework/Kathara/archive/refs/tags/3.7.4.tar.gz',
1717
keywords=['NETWORK-EMULATION', 'CONTAINERS', 'NFV'],
1818
install_requires=[
1919
"binaryornot>=0.4.4",

src/Kathara/exceptions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, path: str) -> None:
2828

2929
class DockerDaemonConnectionError(Exception):
3030
def __init__(self, message: str) -> None:
31-
super().__init__(f"Cannot connect to Docker Daemon: {message}")
31+
super().__init__(f"Cannot connect to Docker Daemon, this may indicate that it is not running. {message}")
3232

3333

3434
class NotSupportedError(Exception):

src/Kathara/manager/docker/DockerMachine.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,20 @@ def create(self, machine: Machine) -> None:
237237

238238
# Sysctl params to pass to the container creation
239239
sysctl_parameters = {RP_FILTER_NAMESPACE % x: 0 for x in ["all", "default", "lo"]}
240+
sysctl_parameters["net.ipv4.ip_forward"] = 1
241+
sysctl_parameters["net.ipv4.icmp_ratelimit"] = 0
240242

243+
sysctl_first_interface = {}
241244
if first_machine_iface:
242-
sysctl_parameters[RP_FILTER_NAMESPACE % "eth0"] = 0
245+
def sysctl_linux():
246+
if utils.is_wsl_platform():
247+
return {RP_FILTER_NAMESPACE % "eth0": 0}
248+
return {}
243249

244-
sysctl_parameters["net.ipv4.ip_forward"] = 1
245-
sysctl_parameters["net.ipv4.icmp_ratelimit"] = 0
250+
def sysctl_windows():
251+
return {RP_FILTER_NAMESPACE % "eth0": 0}
252+
253+
sysctl_first_interface = utils.exec_by_platform(sysctl_linux, sysctl_windows, lambda: {})
246254

247255
if machine.is_ipv6_enabled():
248256
sysctl_parameters["net.ipv6.conf.all.forwarding"] = 1
@@ -252,7 +260,7 @@ def create(self, machine: Machine) -> None:
252260
sysctl_parameters["net.ipv6.conf.all.disable_ipv6"] = 0
253261

254262
# Merge machine sysctls
255-
sysctl_parameters = {**sysctl_parameters, **machine.meta['sysctls']}
263+
sysctl_parameters = {**sysctl_parameters, **machine.meta['sysctls'], **sysctl_first_interface}
256264

257265
volumes = {}
258266

src/Kathara/manager/docker/DockerManager.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import docker
66
import docker.models.containers
77
import docker.models.networks
8+
from docker.errors import DockerException
89
from requests.exceptions import ConnectionError as RequestsConnectionError
910

1011
from .DockerImage import DockerImage
@@ -59,13 +60,16 @@ class DockerManager(IManager):
5960
@check_docker_status
6061
def __init__(self) -> None:
6162
remote_url = Setting.get_instance().remote_url
62-
if remote_url is None:
63-
self.client: docker.DockerClient = docker.from_env(timeout=None, max_pool_size=utils.get_pool_size())
64-
else:
65-
tls_config = docker.tls.TLSConfig(ca_cert=Setting.get_instance().cert_path)
66-
self.client: docker.DockerClient = docker.DockerClient(base_url=remote_url, timeout=None,
67-
max_pool_size=utils.get_pool_size(),
68-
tls=tls_config)
63+
try:
64+
if remote_url is None:
65+
self.client: docker.DockerClient = docker.from_env(timeout=None, max_pool_size=utils.get_pool_size())
66+
else:
67+
tls_config = docker.tls.TLSConfig(ca_cert=Setting.get_instance().cert_path)
68+
self.client: docker.DockerClient = docker.DockerClient(
69+
base_url=remote_url, timeout=None, max_pool_size=utils.get_pool_size(), tls=tls_config
70+
)
71+
except DockerException as e:
72+
raise DockerDaemonConnectionError(str(e))
6973

7074
docker_plugin = DockerPlugin(self.client)
7175
docker_plugin.check_and_download_plugin()

src/Kathara/manager/kubernetes/KubernetesMachine.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ def deploy_machines(self, lab: Lab, selected_machines: Set[str] = None) -> None:
157157
# Do not open terminals on Megalos
158158
Setting.get_instance().open_terminals = False
159159

160+
wait_thread = threading.Thread(
161+
target=self._wait_machines_startup,
162+
args=(lab, selected_machines if selected_machines else None)
163+
)
164+
wait_thread.start()
165+
160166
# Deploy all lab machines.
161167
# If there is no lab.dep file, machines can be deployed using multithreading.
162168
# If not, they're started sequentially
@@ -171,7 +177,7 @@ def deploy_machines(self, lab: Lab, selected_machines: Set[str] = None) -> None:
171177
for item in machines:
172178
self._deploy_machine(item)
173179

174-
self._wait_machines_startup(lab, selected_machines if selected_machines else None)
180+
wait_thread.join()
175181

176182
def _wait_machines_startup(self, lab: Lab, selected_machines: Set[str]) -> None:
177183
"""Wait the startup of the selected machines. Return when the selected machines become `Ready`.
@@ -492,14 +498,17 @@ def undeploy(self, lab_hash: str, selected_machines: Optional[Set[str]] = None)
492498
selected_machines = {item.metadata.labels["name"] for item in pods}
493499

494500
if len(pods) > 0:
501+
wait_thread = threading.Thread(target=self._wait_machines_shutdown, args=(lab_hash, selected_machines))
502+
wait_thread.start()
503+
495504
pool_size = utils.get_pool_size()
496505
items = utils.chunk_list(pods, pool_size)
497506

498507
with Pool(pool_size) as machines_pool:
499508
for chunk in items:
500509
machines_pool.map(func=self._undeploy_machine, iterable=chunk)
501510

502-
self._wait_machines_shutdown(lab_hash, selected_machines)
511+
wait_thread.join()
503512

504513
def _wait_machines_shutdown(self, lab_hash: str, selected_machines: Set[str]):
505514
"""Wait the shutdown of the selected machines. Return when all the selected machines are terminated.
@@ -576,24 +585,15 @@ def _delete_machine(self, pod_api_object: client.V1Pod) -> None:
576585
try:
577586
shell_env_value = self.get_env_var_value_from_pod(pod_api_object, "_MEGALOS_SHELL")
578587
shell = shell_env_value if shell_env_value else Setting.get_instance().device_shell
579-
output = self.exec(machine_namespace,
580-
machine_name,
581-
command=[shell, '-c', shutdown_commands_string],
582-
)
583-
584-
try:
585-
next(output)
586-
except StopIteration:
587-
pass
588-
589-
deployment_name = self.get_deployment_name(machine_name)
590-
self.kubernetes_config_map.delete_for_machine(deployment_name, machine_namespace)
591-
592-
self.client.delete_namespaced_deployment(name=deployment_name,
593-
namespace=machine_namespace
594-
)
588+
self.exec(machine_namespace, machine_name, command=[shell, '-c', shutdown_commands_string], is_stream=False)
595589
except ApiException:
596-
return
590+
pass
591+
except MachineNotRunningError:
592+
pass
593+
594+
deployment_name = self.get_deployment_name(machine_name)
595+
self.kubernetes_config_map.delete_for_machine(deployment_name, machine_namespace)
596+
self.client.delete_namespaced_deployment(name=deployment_name, namespace=machine_namespace)
597597

598598
def connect(self, lab_hash: str, machine_name: str, shell: Union[str, List[str]] = None, logs: bool = False) \
599599
-> None:

src/Kathara/os/Networking.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ def remove_interface_ns(interface_name: str, switch_path: str, ns_pid: int) -> N
153153
logging.debug("Killing vde_ext process in namespace `%s`." % switch_path)
154154

155155
pid_path = os.path.join(switch_path, f"pid_{interface_name}")
156-
command = f"/bin/sh -c 'kill -2 $(cat {pid_path})'"
157-
156+
command = f"/bin/sh -c 'if [ -f \"{pid_path}\" ]; then kill -2 $(cat {pid_path}); fi'"
158157
logging.debug("Running command `%s` in namespace `%s`..." % (command, switch_path))
159158
nsenter(ns_pid, command, ns_types=['ipc', 'net', 'pid', 'uts'])
160159

src/Kathara/utils.py

+7
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ def is_platform(desired_platform: str) -> bool:
130130
return _platform == desired_platform
131131

132132

133+
def is_wsl_platform() -> bool:
134+
if _platform == LINUX or _platform == LINUX2:
135+
info = os.uname()
136+
return 'microsoft' in info.release.lower()
137+
return False
138+
139+
133140
def exec_by_platform(fun_linux: Callable, fun_windows: Callable, fun_mac: Callable) -> Any:
134141
if _platform == LINUX or _platform == LINUX2:
135142
return fun_linux()

src/Kathara/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Tuple
22

3-
CURRENT_VERSION = "3.7.3"
3+
CURRENT_VERSION = "3.7.4"
44

55

66
def parse(version: str) -> Tuple:

0 commit comments

Comments
 (0)