Skip to content

Commit

Permalink
Merge pull request #40 from v3io/development
Browse files Browse the repository at this point in the history
Development --> Master (v2.8.0-1-v0.9.1)
  • Loading branch information
gtopper authored Apr 30, 2019
2 parents f3568a4 + 8c7a02d commit bbeea0d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,20 +341,22 @@ func New(logger log.Logger, o *Options) *Handler {
router.Get("/-/healthy", func(w http.ResponseWriter, r *http.Request) {
if o.V3ioConfig == nil {
w.WriteHeader(http.StatusInternalServerError)
level.Warn(h.logger).Log("msg", "Prometheus is Unhealthy: still waiting on V3IO storage.")
fmt.Fprintf(w, "Prometheus is Unhealthy: still waiting on V3IO storage.\n")
return
}
schemaUrl := "http://" + path.Join(o.V3ioConfig.WebApiEndpoint, o.V3ioConfig.Container, o.V3ioConfig.TablePath, ".schema")
req, err := http.NewRequest("GET", schemaUrl, nil)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
level.Warn(h.logger).Log("msg", "Prometheus is Unhealthy.", "error", err)
fmt.Fprintf(w, "Prometheus is Unhealthy: %v\n", err)
return
}
req.Header.Add("X-v3io-function", "GetItem")
req.Body = ioutil.NopCloser(strings.NewReader(`{AttibutesToGet:"__name"}`))
req.Body = ioutil.NopCloser(strings.NewReader(`{"AttributesToGet":"__name"}`))
if o.V3ioConfig.AccessKey != "" {
req.Header.Add("X-v3io-access-key", o.V3ioConfig.AccessKey)
req.Header.Add("X-v3io-session-key", o.V3ioConfig.AccessKey)
} else if o.V3ioConfig.Password != "" {
base64UserPassword := base64.StdEncoding.EncodeToString([]byte(o.V3ioConfig.Username + ":" + o.V3ioConfig.Password))
req.Header.Add("Authorization", "Basic "+base64UserPassword)
Expand All @@ -363,24 +365,29 @@ func New(logger log.Logger, o *Options) *Handler {
resp, err := client.Do(req)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
level.Warn(h.logger).Log("msg", "Prometheus is Unhealthy.", "error", err)
fmt.Fprintf(w, "Prometheus is Unhealthy: %v\n", err)
return
}
if resp.StatusCode != http.StatusOK {
w.WriteHeader(http.StatusInternalServerError)
level.Warn(h.logger).Log("msg", "Prometheus is Unhealthy because it could not find schema file.", "schemaUrl", schemaUrl, "response", resp)
fmt.Fprintf(w, "Prometheus is Unhealthy because it could not find %s: %+v\n", schemaUrl, resp)
return
}
w.WriteHeader(http.StatusOK)
level.Info(h.logger).Log("msg", "Prometheus is Healthy.")
fmt.Fprintf(w, "Prometheus is Healthy.\n")
})
router.Get("/-/ready", readyf(func(w http.ResponseWriter, r *http.Request) {
if o.V3ioConfig == nil {
w.WriteHeader(http.StatusInternalServerError)
level.Warn(h.logger).Log("msg", "Prometheus is not ready: still waiting on V3IO storage.")
fmt.Fprintf(w, "Prometheus is not ready: still waiting on V3IO storage.\n")
return
}
w.WriteHeader(http.StatusOK)
level.Info(h.logger).Log("msg", "Prometheus is Ready.")
fmt.Fprintf(w, "Prometheus is Ready.\n")
}))

Expand Down

0 comments on commit bbeea0d

Please sign in to comment.