Skip to content

Add lab hash to Docker networks names #256

@tcaiazzi

Description

@tcaiazzi

Description:
The current implementation of DockerLink in Kathará lacks the inclusion of the lab_hash in the names of Docker networks.
This omission can lead to collision domains sharing the same name when multiple network scenarios, run by the same user, collide in the namespace.

@staticmethod
def get_network_name(name: str) -> str:
"""Return the name of a Docker network.
Args:
name (str): The name of a Kathara collision domain.
Returns:
str: The name of the Docker network in the format "|net_prefix|_|username_prefix|_|name|".
If shared collision domains, the format is: "|net_prefix|_|lab_hash|".
"""
username_prefix = "_%s" % utils.get_current_user_name() if not Setting.get_instance().shared_cd else ""
return "%s%s_%s" % (Setting.get_instance().net_prefix, username_prefix, name)

This not only contradicts the model where Link objects have a reference to their lab but also introduces potential issues, as observed in #253.

Proposed Solution:
To resolve this issue and improve the consistency of network naming within the Kathará framework, we need to add the lab_hash in the name of Docker networks.
Then, we need to add an option in the Kathará settings to allow users to share collision domains between the network scenarios (without adding the lab_hash), as we already have for sharing collision domains between users.

Metadata

Metadata

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions