#2641: Added a check for software health state in db service + tests
This commit is contained in:
@@ -197,7 +197,11 @@ class DatabaseService(Service):
|
||||
status_code = 503 # service unavailable
|
||||
if self.health_state_actual == SoftwareHealthState.OVERWHELMED:
|
||||
self.sys_log.error(f"{self.name}: Connect request for {src_ip=} declined. Service is at capacity.")
|
||||
if self.health_state_actual == SoftwareHealthState.GOOD:
|
||||
if self.health_state_actual in [
|
||||
SoftwareHealthState.GOOD,
|
||||
SoftwareHealthState.FIXING,
|
||||
SoftwareHealthState.COMPROMISED,
|
||||
]:
|
||||
if self.password == password:
|
||||
status_code = 200 # ok
|
||||
connection_id = self._generate_connection_id()
|
||||
@@ -244,6 +248,10 @@ class DatabaseService(Service):
|
||||
self.sys_log.error(f"{self.name}: Failed to run {query} because the database file is missing.")
|
||||
return {"status_code": 404, "type": "sql", "data": False}
|
||||
|
||||
if self.health_state_actual is not SoftwareHealthState.GOOD:
|
||||
self.sys_log.error(f"{self.name}: Failed to run {query} because the database service is unavailable.")
|
||||
return {"status_code": 500, "type": "sql", "data": False}
|
||||
|
||||
if query == "SELECT":
|
||||
if self.db_file.health_status == FileSystemItemHealthStatus.CORRUPT:
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user