upbound / up

The @upbound CLI
Apache License 2.0
49 stars 42 forks source link

ctx: Improve performance and make UI more responsive #552

Closed adamwg closed 4 weeks ago

adamwg commented 4 weeks ago

Description of your changes

Use a timeout of 2 seconds when trying to fetch the ingress information for a disconnected Space and attempt to fetch them all in parallel. This should prevent us from hanging forever if a particular kubeconfig context is unreachable or misbehaving. To further help with slow contexts, avoid the overhead of controller-runtime's REST mapping by using the typed client-go client to fetch the ingress ConfigMap.

To make the UI feel more responsive when requests are slow, update the item list asynchronously to the main update loop of the TUI and trigger an update once we have our items. This lets us run a spinner while the items are being updated. As part of this change, switch from generating our own title to using the list widget's built-in title bar, which doesn't change how the TUI looks at all, but lets us leverage the built-in spinner capability of the list widget.

Fixes #549

I have:

How has this code been tested

To test the handling of slow or broken contexts, I did the following:

  1. Added 50 contexts to my kubeconfig pointing at localhost:65432, which doesn't have any cluster listening on it.
  2. Ran nc -kl 65432 to simulate a server accepting requests but not responding.

This lets me observe the new timeout, which I verified we're hitting by adding some temporary debug logging.

Also tested navigating through the tree and selecting contexts as normal to ensure the spinner change didn't break anything.