21
21
22
22
from assemblyline_core .scaler .controllers .interface import ControllerInterface
23
23
24
-
25
- # How to identify the update volume as a whole, in a way that the underlying container system recognizes.
26
- CONTAINER_UPDATE_DIRECTORY = '/mount/updates/'
27
-
28
24
# RESERVE_MEMORY_PER_NODE = os.environ.get('RESERVE_MEMORY_PER_NODE')
29
25
30
26
API_TIMEOUT = 90
@@ -243,8 +239,7 @@ def core_config_mount(self, name, config_map, key, target_path):
243
239
def add_profile (self , profile , scale = 0 ):
244
240
"""Tell the controller about a service profile it needs to manage."""
245
241
self ._create_deployment (profile .name , self ._deployment_name (profile .name ),
246
- profile .container_config , profile .shutdown_seconds , scale ,
247
- mount_updates = profile .mount_updates )
242
+ profile .container_config , profile .shutdown_seconds , scale )
248
243
self ._external_profiles [profile .name ] = profile
249
244
250
245
def _loop_forever (self , function ):
@@ -442,7 +437,7 @@ def memory_info(self):
442
437
def _create_metadata (deployment_name : str , labels : Dict [str , str ]):
443
438
return V1ObjectMeta (name = deployment_name , labels = labels )
444
439
445
- def _create_volumes (self , service_name , mount_updates = False , core_mounts = False ):
440
+ def _create_volumes (self , core_mounts = False ):
446
441
volumes , mounts = [], []
447
442
448
443
# Attach the mount that provides the config file
@@ -461,15 +456,14 @@ def _create_containers(self, service_name: str, deployment_name: str, container_
461
456
memory = container_config .ram_mb
462
457
min_memory = min (container_config .ram_mb_min , container_config .ram_mb )
463
458
environment_variables : list [V1EnvVar ] = []
464
- # If we are launching a core container, include the scalers environment
459
+ # If we are launching a core container, include environment variables related to authentication for DBs
465
460
if core_container :
466
- environment_variables += [V1EnvVar (name = _n , value = _v ) for _n , _v in os .environ .items ()]
461
+ environment_variables += [V1EnvVar (name = _n , value = _v ) for _n , _v in os .environ .items ()
462
+ if any (term in _n for term in ['ELASTIC' , 'FILESTORE' , 'UI_SERVER' ])]
467
463
# Overwrite them with configured special environment variables
468
464
environment_variables += [V1EnvVar (name = _e .name , value = _e .value ) for _e in container_config .environment ]
469
465
# Overwrite those with special hard coded variables
470
466
environment_variables += [
471
- V1EnvVar (name = 'UPDATE_PATH' , value = CONTAINER_UPDATE_DIRECTORY ),
472
- V1EnvVar (name = 'FILE_UPDATE_DIRECTORY' , value = CONTAINER_UPDATE_DIRECTORY ),
473
467
V1EnvVar (name = 'AL_SERVICE_NAME' , value = service_name ),
474
468
V1EnvVar (name = 'LOG_LEVEL' , value = self .log_level )
475
469
]
@@ -491,7 +485,7 @@ def _create_containers(self, service_name: str, deployment_name: str, container_
491
485
492
486
def _create_deployment (self , service_name : str , deployment_name : str , docker_config ,
493
487
shutdown_seconds , scale : int , labels = None , volumes = None , mounts = None ,
494
- mount_updates = True , core_mounts = False ):
488
+ core_mounts = False ):
495
489
496
490
replace = False
497
491
resources = self .apps_api .list_namespaced_deployment (namespace = self .namespace , _request_timeout = API_TIMEOUT )
@@ -544,7 +538,7 @@ def _create_deployment(self, service_name: str, deployment_name: str, docker_con
544
538
all_labels ['section' ] = 'core'
545
539
all_labels .update (labels or {})
546
540
547
- all_volumes , all_mounts = self ._create_volumes (service_name , mount_updates , core_mounts )
541
+ all_volumes , all_mounts = self ._create_volumes (core_mounts )
548
542
all_volumes .extend (volumes or [])
549
543
all_mounts .extend (mounts or [])
550
544
metadata = self ._create_metadata (deployment_name = deployment_name , labels = all_labels )
@@ -636,8 +630,7 @@ def stop_container(self, service_name, container_id):
636
630
637
631
def restart (self , service ):
638
632
self ._create_deployment (service .name , self ._deployment_name (service .name ), service .container_config ,
639
- service .shutdown_seconds , self .get_target (service .name ),
640
- mount_updates = service .mount_updates )
633
+ service .shutdown_seconds , self .get_target (service .name ))
641
634
642
635
def get_running_container_names (self ):
643
636
pods = self .api .list_pod_for_all_namespaces (field_selector = 'status.phase==Running' ,
@@ -664,7 +657,7 @@ def new_events(self):
664
657
return new
665
658
666
659
def start_stateful_container (self , service_name : str , container_name : str ,
667
- spec , labels : dict [str , str ], mount_updates : bool = False ):
660
+ spec , labels : dict [str , str ]):
668
661
# Setup PVC
669
662
deployment_name = self ._dependency_name (service_name , container_name )
670
663
mounts , volumes = [], []
@@ -687,7 +680,7 @@ def start_stateful_container(self, service_name: str, container_name: str,
687
680
spec .container .environment .append ({'name' : 'AL_INSTANCE_KEY' , 'value' : instance_key })
688
681
self ._create_deployment (service_name , deployment_name , spec .container ,
689
682
30 , 1 , labels , volumes = volumes , mounts = mounts ,
690
- mount_updates = mount_updates , core_mounts = spec .run_as_core )
683
+ core_mounts = spec .run_as_core )
691
684
692
685
# Setup a service to direct to the deployment
693
686
try :
0 commit comments