Skip to content

Commit

Permalink
Separate api/health from data/health and tracings/health (#5601)
Browse files Browse the repository at this point in the history
* Separate api/health from data/halth and tracings/health

* changelog + migration guide

* add pr num
  • Loading branch information
fm3 authored Jul 7, 2021
1 parent a72a8ca commit 094a75e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- The "Mapping" setting was moved to the segmentation layer in the left sidebar.
- The status bar contains additional elements for (editable) information, such as the active tree id (previously positioned in the left sidebar).
- Some UI elements were less spacious by favoring icons instead of labels. Hover these elements to get an helpful tooltip.
- The health check at api/health does not longer include checking data/health and tracings/health if the respective local modules are enabled. Consider monitoring those routes separately. [#5601](https://github.com/scalableminds/webknossos/pull/5601)

### Fixed
- Fixed that a disabled "Center new Nodes" option didn't work correctly in merger mode. [#5538](https://github.com/scalableminds/webknossos/pull/5538)
Expand Down
1 change: 1 addition & 0 deletions MIGRATIONS.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ SET recommendedconfiguration = jsonb_set(
array['useLegacyBindings'],
to_jsonb('true'::boolean))
```
- The health check at api/health does not longer include checking data/health and tracings/health if the respective local modules are enabled. Consider monitoring those routes separately.

### Postgres Evolutions:
- [072-jobs-manually-repaired.sql](conf/evolutions/072-jobs-manually-repaired.sql)
39 changes: 2 additions & 37 deletions app/controllers/Application.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,43 +64,8 @@ class Application @Inject()(multiUserDAO: MultiUserDAO,
Ok(conf.raw.underlying.getConfig("features").resolve.root.render(ConfigRenderOptions.concise()))
}

def health: Action[AnyContent] = sil.UserAwareAction.async { implicit request =>
def checkDatastoreHealthIfEnabled: Fox[Option[Long]] =
if (storeModules.localDataStoreEnabled) {
for {
before <- Fox.successful(System.currentTimeMillis())
response <- rpc(s"http://localhost:${conf.Http.port}/data/health").get
if response.status == 200
after = System.currentTimeMillis()
} yield Some(after - before)
} else Fox.successful(None)

def checkTracingstoreHealthIfEnabled: Fox[Option[Long]] =
if (storeModules.localTracingStoreEnabled) {
for {
before <- Fox.successful(System.currentTimeMillis())
response <- rpc(s"http://localhost:${conf.Http.port}/tracings/health").get
if response.status == 200
after = System.currentTimeMillis()
} yield Some(after - before)
} else Fox.successful(None)

def logDuration(before: Long, dataStoreDuration: Option[Long], tracingStoreDuration: Option[Long]): Unit = {
val dataStoreLabel = dataStoreDuration.map(dd => s"local Datastore $dd ms")
val tracingStoreLabel = tracingStoreDuration.map(td => s"local Tracingstore $td ms")
val localStoresLabel = List(dataStoreLabel, tracingStoreLabel).flatten.mkString(", ")
val localStoresLabelWrapped = if (localStoresLabel.isEmpty) "" else s" ($localStoresLabel)"
val after = System.currentTimeMillis()
logger.info(s"Answering ok for wK health check, took ${after - before} ms$localStoresLabelWrapped")
}
log() {
for {
before <- Fox.successful(System.currentTimeMillis())
dataStoreDuration <- checkDatastoreHealthIfEnabled ?~> "dataStore.unavailable"
tracingStoreDuration <- checkTracingstoreHealthIfEnabled ?~> "tracingStore.unavailable"
_ = logDuration(before, dataStoreDuration, tracingStoreDuration)
} yield Ok
}
def health: Action[AnyContent] = sil.UserAwareAction { implicit request =>
Ok
}

}
Expand Down

0 comments on commit 094a75e

Please sign in to comment.