@@ -78,7 +78,8 @@ async def _check_available(self):
7878 self .available_storages .remove (storage )
7979 except :
8080 logger .ttraceback ("storage.error.check_available" , type = storage .type , path = storage .path , url = getattr (storage , "url" , None ))
81- self .available_storages .remove (storage )
81+ if storage in self .available_storages :
82+ self .available_storages .remove (storage )
8283 if res :
8384 if storage not in self .available_storages :
8485 self .available_storages .append (storage )
@@ -573,6 +574,7 @@ def __init__(self):
573574 self .cluster_id_tables : dict [str , 'Cluster' ] = {}
574575 self .file_manager = FileListManager (self )
575576 self .storage_manager = StorageManager (self )
577+ self .clusters_certificate : dict [str , ClusterCertificate ] = {}
576578
577579 def add_cluster (self , cluster : 'Cluster' ):
578580 self .cluster_id_tables [cluster .id ] = cluster
@@ -585,10 +587,11 @@ async def start(self):
585587 self .storage_manager .init ()
586588 logger .tdebug ("cluster.debug.base_url" , base_url = config .const .base_url )
587589
588- cert = await self .get_certificate ()
589- await web .start_ssl_server (
590- cert .cert , cert .key
591- )
590+ certificates = await self .get_certificates ()
591+ for cert in certificates :
592+ await web .start_private_server (
593+ cert .cert , cert .key
594+ )
592595 # start web ssl
593596 public_port = config .const .public_port
594597 public_host = cert .host
@@ -617,17 +620,26 @@ def byoc(self):
617620 return True
618621 return False
619622
620- async def get_certificate (self ):
623+ async def get_certificates (self , cluster_id : Optional [ str ] = None ):
621624 if config .const .ssl_cert and config .const .ssl_key :
622625 main = ClusterCertificate (
623626 config .const .host ,
624627 Path (config .const .ssl_cert ),
625628 Path (config .const .ssl_key )
626629 )
627630 if main .is_valid :
628- return main
629- await asyncio .gather (* [cluster .request_cert () for cluster in self .clusters ])
630- return [cluster .certificate for cluster in self .clusters ][0 ]
631+ return [
632+ main
633+ ]
634+ if not self .clusters_certificate :
635+ await asyncio .gather (* [cluster .request_cert () for cluster in self .clusters ])
636+ for cluster in self .clusters :
637+ self .clusters_certificate [cluster .id ] = cluster .certificate
638+ if cluster_id is None :
639+ return list (self .clusters_certificate .values ())
640+ if cluster_id in self .clusters_certificate :
641+ return [self .clusters_certificate [cluster_id ]]
642+ return []
631643
632644 async def stop (self ):
633645 await asyncio .gather (* [cluster .disable (True ) for cluster in self .clusters ])
@@ -736,7 +748,7 @@ async def request_cert(self):
736748 key .write (result .ack ["key" ])
737749
738750 async def enable (self ):
739- cert = await clusters .get_certificate ( )
751+ cert = await clusters .get_certificates ( self . id )
740752 scheduler .cancel (self .delay_enable_task )
741753 if self .want_enable :
742754 return
@@ -747,7 +759,7 @@ async def enable(self):
747759 result = await self .socket_io .emit (
748760 "enable" , {
749761 "host" : config .const .host ,
750- "port" : config .const .public_port ,
762+ "port" : config .const .public_port or config . const . port ,
751763 "byoc" : clusters .byoc (),
752764 "version" : API_VERSION ,
753765 "noFastEnable" : True ,
0 commit comments