Skip to content

Commit

Permalink
Fix swagger and improve StatusService logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rtitle committed Nov 3, 2017
1 parent a907af7 commit 9686876
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 28 deletions.
49 changes: 26 additions & 23 deletions src/main/resources/swagger/api-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -393,28 +393,31 @@ definitions:
must have an entry point named 'main'. For more information on notebook extensions,
see: http://jupyter-notebook.readthedocs.io/en/latest/extending/frontend_extensions.html.
SubsystemStatus:
description: status of a subsystem Leonardo depends on
properties:
ok:
type: boolean
description: whether this system is up or down from Leonardo's point of view
messages:
type: array
items:
type: string
SubsystemStatus:
description: status of a subsystem Leonardo depends on
type: object
required:
- ok
properties:
ok:
type: boolean
description: whether this system is up or down from Leonardo's point of view
messages:
type: array
items:
type: string

SystemStatus:
description: status of each subsystem Leonardo depends on
type: object
required:
- ok
- systems
properties:
ok:
type: boolean
description: true if everything is ok, false if anything is amiss
systems:
type: object
description: Map[String, SubsystemStatus]
SystemStatus:
description: status of each subsystem Leonardo depends on
type: object
required:
- ok
- systems
properties:
ok:
type: boolean
description: true if everything is ok, false if anything is amiss
systems:
type: object
description: Map[String, SubsystemStatus]

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.broadinstitute.dsde.workbench.util.health.Subsystems._

import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.duration._
import scala.util.{Failure, Success}

/**
* Created by rtitle on 10/26/17.
Expand All @@ -36,22 +37,33 @@ class StatusService(gdDAO: DataprocDAO,
GoogleDataproc -> checkGoogleDataproc,
Sam -> checkSam,
Database -> checkDatabase
)
).map(logFailures.tupled)
}

// Logs warnings if a subsystem status check fails
def logFailures: (Subsystem, Future[SubsystemStatus]) => (Subsystem, Future[SubsystemStatus]) = (subsystem, statusFuture) =>
subsystem -> statusFuture.andThen {
case Success(status) if !status.ok =>
logger.warn(s"Subsystem [$subsystem] reported error status: $status")
case Failure(e) =>
logger.warn(s"Failure checking status for subsystem [$subsystem]: ${e.getMessage}")
}


private def checkGoogleDataproc(): Future[SubsystemStatus] = {
logger.info("Checking Google Dataproc connection")
// Does a 'list clusters' in Leo's project
// Does a 'list clusters' in Leo's project.
// Doesn't look at results, just checks if the request was successful.
logger.debug("Checking Google Dataproc connection")
gdDAO.listClusters(dataprocConfig.leoGoogleProject).map(_ => HealthMonitor.OkStatus)
}

private def checkDatabase: Future[SubsystemStatus] = {
logger.info("Checking database")
logger.debug("Checking database connection")
dbRef.inTransaction(_.sqlDBStatus()).map(_ => HealthMonitor.OkStatus)
}

private def checkSam: Future[SubsystemStatus] = {
logger.info("Checking Sam")
logger.debug("Checking Sam status")
samDAO.getStatus()
}

Expand Down

0 comments on commit 9686876

Please sign in to comment.