Permalink
Browse files

Add health and info endpoints

Fixes issue 689 by enabling /healthz and /system/info, see
swagger for more details.

Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
  • Loading branch information...
alexellis committed May 20, 2018
1 parent fa3ae74 commit 4123270235540f3c8ffc5012d44a1be70c210e60
Showing with 29 additions and 2 deletions.
  1. +24 −1 api-docs/swagger.yml
  2. +5 −1 gateway/server.go
@@ -1,7 +1,7 @@
swagger: '2.0'
info:
description: OpenFaaS API documentation
version: 0.8.0
version: 0.8.1
title: OpenFaaS API Gateway
license:
name: MIT
@@ -213,6 +213,29 @@ paths:
description: Function not found
'500':
description: Error querying function
'/system/info':
get:
summary: Get info such as provider version number and provider orchestrator
produces:
- application/json
responses:
'200':
description: Info result
examples:
application/json: |-
{"provider":"faas-swarm","version":{"sha":"7108418d9dd6b329ddff40e7393b3166f8160a88","release":"0.2.6"},"orchestration":"swarm"}
'404':
description: Provider does not support info endpoint
'500':
description: Error finding info
'/healthz':
get:
summary: Healthcheck
responses:
'200':
description: Healthy
'500':
description: Not healthy
definitions:
DeleteFunctionRequest:
type: object
@@ -28,7 +28,7 @@ func main() {
log.Printf("HTTP Write Timeout: %s", config.WriteTimeout)
if !config.UseExternalProvider() {
log.Fatalln("As of this version of OpenFaaS, you must use external provider even for Docker Swarm.")
log.Fatalln("You must provide an external provider via 'functions_provider_url' env-var.")
}
log.Printf("Binding to external function provider: %s", config.FunctionsProviderURL)
@@ -92,6 +92,8 @@ func main() {
r.HandleFunc("/function/{name:[-a-zA-Z_0-9]+}", faasHandlers.Proxy)
r.HandleFunc("/function/{name:[-a-zA-Z_0-9]+}/", faasHandlers.Proxy)
r.HandleFunc("/system/info", handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver)).Methods(http.MethodGet)
r.HandleFunc("/system/alert", faasHandlers.Alert)
r.HandleFunc("/system/function/{name:[-a-zA-Z_0-9]+}", queryFunction).Methods(http.MethodGet)
@@ -117,6 +119,8 @@ func main() {
metricsHandler := metrics.PrometheusHandler()
r.Handle("/metrics", metricsHandler)
r.HandleFunc("/healthz", handlers.MakeForwardingProxyHandler(reverseProxy, forwardingNotifiers, urlResolver)).Methods(http.MethodGet)
r.Handle("/", http.RedirectHandler("/ui/", http.StatusMovedPermanently)).Methods(http.MethodGet)
tcpPort := 8080

0 comments on commit 4123270

Please sign in to comment.