upbound / up

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

`up ctx` shouldn't fail if the current context is unreachable #486

Closed RedbackThomson closed 1 month ago

RedbackThomson commented 2 months ago

What happened?

If the current-context is set, but it is unreachable, the user will see an error like the following:

up: error: ctx.Cmd.Run(): failed to get API group resources: unable to retrieve the complete list of server APIs: v1: Get "https://127.0.0.1:6443/api/v1": dial tcp 127.0.0.1:6443: connect: connection refused

This is expected because up is trying to determine whether we're pointed at a cloud context or a self-hosted spaces context, and it does so by querying the cluster. Ideally we would get this information from a cached source, rather than querying the live cluster.

How can we reproduce it?

Point your current-context at a cluster that isn't connected then run up ctx

What environment did it happen in?

RedbackThomson commented 1 month ago

Fixed by https://github.com/upbound/up/pull/498

DeriveNewState will always fall back to Root{} - so the experience should always start with cloud if the cluster is inaccessible.