Fix Kubernetes namespaces for dotted usernames
Build and publish Docker image / build-and-publish (push) Successful in 8s
Build and publish Docker image / build-and-publish (push) Successful in 8s
This commit is contained in:
1 parent
522e5c5634
commit
6732ee9d47
8 files changed
+70
-19
No files matched your search
@@ -6,6 +6,7 @@ from datetime import datetime, timedelta, timezone
|
||||
import json
|
||||
from kubernetes import client
|
||||
from kubernetes_service import apps_v1, custom_objects_api, k8s_manager, v1
|
||||
from namespace_utils import user_namespace
|
||||
import random
|
||||
import re
|
||||
from runtime_config import (
|
||||
@@ -75,7 +76,7 @@ def change_server_version(server_id: str, user_id: str, new_version: str, java_v
|
||||
logger.info(f"✓ Changed version for server {server_id} to {new_version} (billing date unchanged)")
|
||||
return cursor.rowcount > 0
|
||||
|
||||
namespace = f"user-{owner['username']}".lower()
|
||||
namespace = server.get('namespace') or user_namespace(owner['username'])
|
||||
|
||||
if not k8s_manager.connected:
|
||||
# If K8s not connected, just update database
|
||||
@@ -368,7 +369,7 @@ def reinstall_server(server_id: str, user_id: str) -> bool:
|
||||
if not owner:
|
||||
raise Exception("Server owner not found")
|
||||
|
||||
namespace = f"user-{owner['username']}".lower()
|
||||
namespace = server.get('namespace') or user_namespace(owner['username'])
|
||||
|
||||
if not k8s_manager.connected:
|
||||
update_server_status(server_id, 'Running')
|
||||
@@ -1949,7 +1950,7 @@ def create_server(config: Dict, user_id: str, progress_callback=None) -> Dict:
|
||||
'ip': NODE_IP,
|
||||
'ports': ports,
|
||||
'ownerId': user_id,
|
||||
'namespace': f"user-{user['username']}".lower(),
|
||||
'namespace': user_namespace(user['username']),
|
||||
'k8s_name': server_id,
|
||||
'is_demo': is_demo,
|
||||
'demo_expires_at': demo_expires_at,
|
||||
@@ -1964,7 +1965,7 @@ def create_server(config: Dict, user_id: str, progress_callback=None) -> Dict:
|
||||
server = create_server_record(server_data)
|
||||
|
||||
else:
|
||||
namespace = f"user-{user['username']}".lower()
|
||||
namespace = user_namespace(user['username'])
|
||||
sanitized_name = config['name'].lower().replace(' ', '-').replace('_', '-')[:20]
|
||||
server_id = f"{sanitized_name}-{str(uuid.uuid4())[:8]}"
|
||||
|
||||
|
||||
Reference in new issue
Block a user