Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
logs and metrics for k8s api 5XX responses (#1687)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaoWen authored Nov 28, 2022
1 parent beae590 commit 28802b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions waiter/src/waiter/scheduler/kubernetes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@
{:keys [body error status] :as response} (clj-http/get url request-options)]
(when error
(throw error))
(when (hu/status-5XX? status)
(log/warn "received 5XX response from k8s api server streaming request" {:url url :response response})
(counters/inc! (metrics/waiter-counter "k8s-api" "5XX")))
(when-not (hu/status-2XX? status)
(ss/throw+ response))
(-> body
Expand Down Expand Up @@ -577,6 +580,9 @@
(ss/throw+ response))
(catch [:client http-client] response
(log/error "request to K8s API server failed: " url options body response)
(when (hu/status-5XX? (:status response))
(log/warn "received 5XX response from k8s api server request" {:url url :response response})
(counters/inc! (metrics/waiter-counter "k8s-api" "5XX")))
(ss/throw+ response))))

(defn api-request-async
Expand Down
6 changes: 6 additions & 0 deletions waiter/src/waiter/util/http_utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
(and (integer? status)
(<= http-200-ok status 299)))

(defn status-5XX?
"Returns true if the status is in the range [500, 599]."
[status]
(and (integer? status)
(<= http-500-internal-server-error status 599)))

(defn http-streaming-request-async
"This wraps the qbits.jet.client.http/request function and makes a streaming request. An abort-ch can be provided to
abort the streaming response when a message is pushed to it.
Expand Down

0 comments on commit 28802b7

Please sign in to comment.