Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate api/health from data/health and tracings/health #5601

Merged
merged 3 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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