Skip to content

Commit c506337

Browse files
authored
fix: Sanitize URLs to remove prepended dots in allocator and client services (#199)
1 parent 9599bde commit c506337

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

packages/allocator/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ description = "VM Allocator Service Package for Lablink"
2424
name = "lablink-allocator-service"
2525
readme = "README.md"
2626
requires-python = ">=3.9"
27-
version = "0.0.3a1"
27+
version = "0.0.3a2"
2828

2929
[project.optional-dependencies]
3030
dev = ["twine", "build", "pytest", "ruff", "pytest-cov"]

packages/allocator/src/lablink_allocator_service/utils/config_helpers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ def get_allocator_url(cfg, allocator_ip: str) -> Tuple[str, str]:
7474
host = allocator_ip
7575

7676
base_url = f"{protocol}://{host}"
77+
78+
# Sanitize URL to remove prepended dots
79+
base_url = base_url.replace("://.", "://")
80+
7781
return base_url, protocol
7882

7983

packages/client/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ keywords = ["vm", "docker", "postgres", "tutorial", "AWS"]
2222
name = "lablink-client-service"
2323
readme = "README.md"
2424
requires-python = ">=3.8"
25-
version = "0.0.8a2"
25+
version = "0.0.8a3"
2626

2727
[project.optional-dependencies]
2828
dev = ["twine", "build", "pytest", "ruff", "pytest-cov"]

packages/client/src/lablink_client_service/check_gpu.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def check_gpu_health(allocator_url: str, interval: int = 20):
2222
"""
2323
logger.debug("Starting GPU health check...")
2424
last_status = None
25-
base_url = allocator_url.rstrip('/')
25+
base_url = allocator_url.rstrip("/")
26+
base_url = base_url.replace("://.", "://")
2627

2728
while True:
2829
curr_status = None
@@ -105,6 +106,8 @@ def main(cfg: Config) -> None:
105106
else:
106107
allocator_url = f"http://{cfg.allocator.host}:{cfg.allocator.port}"
107108

109+
allocator_url_env = allocator_url_env.replace("://.", "://")
110+
108111
check_gpu_health(allocator_url=allocator_url)
109112

110113

packages/client/src/lablink_client_service/update_inuse_status.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,13 @@ def main(cfg: Config) -> None:
113113
# otherwise use host:port with HTTP
114114
allocator_url = os.getenv("ALLOCATOR_URL")
115115
if allocator_url:
116-
base_url = allocator_url.rstrip('/')
116+
base_url = allocator_url.rstrip("/")
117117
else:
118118
base_url = f"http://{cfg.allocator.host}:{cfg.allocator.port}"
119119
url = f"{base_url}/api/update_inuse_status"
120120

121+
url = url.replace("://.", "://")
122+
121123
# Start listening for the process
122124
listen_for_process(
123125
process_name=cfg.client.software,

0 commit comments

Comments
 (0)