allow `NeverTested` > `Working` transition for EL connection (#4991)

Since #4960, the EL connection status can no longer transition from
`NeverTested` to `Working`. Fix that, and also consider `NeverTested`
connections as online for the purpose of the `el_offline` REST response.
This commit is contained in:
Etan Kissling 2023-05-25 09:39:47 +02:00 committed by GitHub
parent 74b670a4c9
commit f16c368f5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -327,13 +327,16 @@ proc setDegradedState(connection: ELConnection,
proc setWorkingState(connection: ELConnection) = proc setWorkingState(connection: ELConnection) =
case connection.state case connection.state
of NeverTested:
connection.hysteresisCounter = 0
connection.state = Working
of Degraded: of Degraded:
if connection.increaseCounterTowardsStateChange(): if connection.increaseCounterTowardsStateChange():
info "Connection to EL node restored", info "Connection to EL node restored",
url = url(connection.engineUrl) url = url(connection.engineUrl)
connection.state = Working connection.state = Working
of NeverTested, Working: of Working:
connection.decreaseCounterTowardsStateChange() connection.decreaseCounterTowardsStateChange()
proc trackEngineApiRequest(connection: ELConnection, proc trackEngineApiRequest(connection: ELConnection,
@ -1973,7 +1976,7 @@ func hasConnection*(m: ELManager): bool =
m.elConnections.len > 0 m.elConnections.len > 0
func hasAnyWorkingConnection*(m: ELManager): bool = func hasAnyWorkingConnection*(m: ELManager): bool =
m.elConnections.anyIt(it.state == Working) m.elConnections.anyIt(it.state == Working or it.state == NeverTested)
func hasProperlyConfiguredConnection*(m: ELManager): bool = func hasProperlyConfiguredConnection*(m: ELManager): bool =
for connection in m.elConnections: for connection in m.elConnections: