Skip to content

Commit

Permalink
Properly handle "proxy server not fully initialized" scenario (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinnovation authored Apr 5, 2024
1 parent f67b959 commit 5bfa4fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion docs/references/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ versioning][semver].

- Fixed a bug where `kele-mode` errors out when the kubeconfig file does not
exist yet
- Fixed a bug where `curl` errors are not properly caught, resulting in attempts
to query the kubectl proxy server before it is ready

### Changed

- Bumped dependency `plz` from `0.3` to `0.4`
- Bumped dependency `plz` from `0.3` to `0.7.3`

## 0.4.1

Expand Down
16 changes: 9 additions & 7 deletions kele.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
;; Homepage: https://github.com/jinnovation/kele.el
;; Keywords: kubernetes tools
;; SPDX-License-Identifier: Apache-2.0
;; Package-Requires: ((emacs "28.1") (async "1.9.7") (dash "2.19.1") (f "0.20.0") (ht "2.3") (plz "0.4") (s "1.13.0") (yaml "0.5.1"))
;; Package-Requires: ((emacs "28.1") (async "1.9.7") (dash "2.19.1") (f "0.20.0") (ht "2.3") (plz "0.7.3") (s "1.13.0") (yaml "0.5.1"))

;;; Commentary:

Expand Down Expand Up @@ -456,11 +456,13 @@ TIMER, if non-nil, is the cleanup timer."
Returns nil on any curl error."
(let ((ready-addr (format "%s/readyz" (kele--url proxy)))
(live-addr (format "%s/livez" (kele--url proxy))))
(when-let* ((resp-ready (plz 'get ready-addr :as 'response :else 'ignore))
(resp-live (plz 'get live-addr :as 'response :else 'ignore))
(status-ready (plz-response-status resp-ready))
(status-live (plz-response-status resp-live)))
(and (= 200 status-ready) (= 200 status-live)))))
(condition-case _err
(when-let* ((resp-ready (plz 'get ready-addr :as 'response :else 'ignore))
(resp-live (plz 'get live-addr :as 'response :else 'ignore))
(status-ready (plz-response-status resp-ready))
(status-live (plz-response-status resp-live)))
(and (= 200 status-ready) (= 200 status-live)))
(error nil))))

(defclass kele--proxy-manager ()
((records
Expand Down Expand Up @@ -1040,7 +1042,7 @@ If CONTEXT is not provided, use the current context."
kele--global-discovery-cache
(kele--groupversion-string group version)
kind)))
(signal 'user-error '()))
(user-error "Attempted to fetch un-namespaced resource `%s' as namespaced" kind))

(let* ((ctx (or context (kele-current-context-name)))
(port (kele--proxy-record-port
Expand Down

0 comments on commit 5bfa4fc

Please sign in to comment.