Fix Kubernetes namespaces for dotted usernames
Build and publish Docker image / build-and-publish (push) Successful in 8s

This commit is contained in:
wfalkowski committed 2026-10-20 19:38:31 +00:00
1 parent 522e5c5634
commit 6732ee9d47
8 files changed
+70 -19

No files matched your search

+6 -5
View File
@@ -4,6 +4,7 @@
from database_service import database_connection
from kubernetes import client
from kubernetes_service import apps_v1, custom_objects_api, k8s_manager, v1
from namespace_utils import user_namespace
from runtime_config import (
logger,
)
@@ -59,7 +60,7 @@ def delete_server(server_id: str, user_id: str) -> bool:
pass
return True
namespace = f"user-{owner['username']}".lower()
namespace = server.get('namespace') or user_namespace(owner['username'])
try:
custom_objects_api.delete_namespaced_custom_object(
@@ -165,7 +166,7 @@ def start_server(server_id: str, user_id: str) -> bool:
update_server_status(server_id, 'Running')
return True
namespace = f"user-{owner['username']}".lower()
namespace = server.get('namespace') or user_namespace(owner['username'])
try:
patch = {'spec': {'runStrategy': 'Always'}}
@@ -232,7 +233,7 @@ def stop_server(server_id: str, user_id: str) -> bool:
update_server_status(server_id, 'Stopped')
return True
namespace = f"user-{owner['username']}".lower()
namespace = server.get('namespace') or user_namespace(owner['username'])
try:
patch = {'spec': {'runStrategy': 'Halted'}}
@@ -317,7 +318,7 @@ def restart_server(server_id: str, user_id: str, skip_checks: bool = False) -> b
update_server_status(server_id, 'Running')
return True
namespace = f"user-{owner['username']}".lower()
namespace = server.get('namespace') or user_namespace(owner['username'])
update_server_status(server_id, 'Restarting')
try:
@@ -721,7 +722,7 @@ def adjust_server_parameters(server_id: str, user_id: str, new_cpu: str, new_ram
conn.commit()
# Update server resources in Kubernetes
namespace = f"user-{user['username']}".lower()
namespace = server.get('namespace') or user_namespace(user['username'])
if k8s_manager.connected:
if not update_server_resources_in_k8s(server, new_cpu, new_ram, new_storage, namespace):
logger.warning(f"Failed to update server resources in K8s, but database was updated")