Apply suggestions

This commit is contained in:
Duc Trung LE
2023-07-04 15:13:40 +02:00
parent 9034de28f9
commit aa754a1a2c
3 changed files with 12 additions and 7 deletions

View File

@@ -2486,6 +2486,7 @@ class JupyterHub(Application):
if key not in traits: if key not in traits:
raise AttributeError("No such service field: %s" % key) raise AttributeError("No such service field: %s" % key)
setattr(service, key, value) setattr(service, key, value)
print('###### updateing', key, value)
orm_service.update_column(key, value) orm_service.update_column(key, value)
if service.api_token: if service.api_token:
@@ -3256,9 +3257,9 @@ class JupyterHub(Application):
service_name, service_name,
status, status,
) )
break return False
else: else:
break return True
else: else:
self.log.error( self.log.error(
"Cannot connect to %s service %s at %s. Is it running?", "Cannot connect to %s service %s at %s. Is it running?",
@@ -3266,6 +3267,7 @@ class JupyterHub(Application):
service_name, service_name,
service.url, service.url,
) )
return False
return True return True
def toggle_service_health_check(self) -> None: def toggle_service_health_check(self) -> None:
@@ -3284,6 +3286,7 @@ class JupyterHub(Application):
# the periodic callback. # the periodic callback.
if self._check_services_health_callback is not None: if self._check_services_health_callback is not None:
self._check_services_health_callback.stop() self._check_services_health_callback.stop()
self._check_services_health_callback = None
async def start(self): async def start(self):
"""Start the whole thing""" """Start the whole thing"""
@@ -3370,10 +3373,8 @@ class JupyterHub(Application):
# start the service(s) # start the service(s)
for service_name, service in self._service_map.items(): for service_name, service in self._service_map.items():
service_status = await self.start_service( service_ready = await self.start_service(service_name, service, ssl_context)
service_name, service, ssl_context if not service_ready:
)
if not service_status:
if service.from_config: if service.from_config:
# Stop the application if a config-based service failed to start. # Stop the application if a config-based service failed to start.
self.exit(1) self.exit(1)
@@ -3381,7 +3382,7 @@ class JupyterHub(Application):
# Only warn for database-based service, so that admin can connect # Only warn for database-based service, so that admin can connect
# to hub to remove the service. # to hub to remove the service.
self.log.error( self.log.error(
"Failed to start database-based service %s", "Failed to reach externally managed service %s",
service_name, service_name,
exc_info=True, exc_info=True,
) )

View File

@@ -676,6 +676,9 @@ class JupyterHubOAuthServer(WebApplicationServer):
if orm_client is not None: if orm_client is not None:
self.db.delete(orm_client) self.db.delete(orm_client)
self.db.commit() self.db.commit()
app_log.info("Removed client %s", client_id)
else:
app_log.warning("No such client %s", client_id)
def fetch_by_client_id(self, client_id): def fetch_by_client_id(self, client_id):
"""Find a client by its id""" """Find a client by its id"""

View File

@@ -490,6 +490,7 @@ class Service(Base):
returns `False` otherwise. returns `False` otherwise.
""" """
if self._check_data_only_column(column_name): if self._check_data_only_column(column_name):
print('NOT ForeignKey', column_name)
setattr(self, column_name, value) setattr(self, column_name, value)
return True return True
else: else: