Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Plugins load failed!" when no current context #2651

Open
dewe opened this issue Apr 4, 2024 · 8 comments
Open

"Plugins load failed!" when no current context #2651

dewe opened this issue Apr 4, 2024 · 8 comments

Comments

@dewe
Copy link

dewe commented Apr 4, 2024




Describe the bug
When starting k9s without a current context set, there's an error telling me that Plugins load failed!. But when having a current context set, or specifying the --context flag when starting k9s, it works as expected. I have no plugins.

To Reproduce

$ kubectl config unset current-context
Property "current-context" unset.

$ k9s
...
Screenshot 2024-04-04 at 09 15 44

Historical Documents

k9s logs:

�[90m9:25AM�[0m �[32mINF�[0m �[1m🐶 K9s starting up...�[0m
�[90m9:25AM�[0m �[31mERR�[0m �[1mFail to locate metrics-server�[0m �[36merror=�[0m�[31m�[1m"Get \"http://localhost:8080/api\": dial tcp [::1]:8080: connect: connection refused"�[0m�[0m
�[90m9:25AM�[0m �[31mERR�[0m �[1mconfig refine failed�[0m �[36merror=�[0m�[31m�[1m"unable to activate context \"\": getcontext - invalid context specified: \"\""�[0m�[0m
�[90m9:25AM�[0m �[31mERR�[0m �[1mcan't connect to cluster�[0m �[36merror=�[0m�[31m�[1m"Get \"http://localhost:8080/version?timeout=15s\": dial tcp [::1]:8080: connect: connection refused"�[0m�[0m
�[90m9:25AM�[0m �[32mINF�[0m �[1m✅ Kubernetes connectivity�[0m
�[90m9:25AM�[0m �[33mWRN�[0m �[1mSave failed. no active config detected�[0m
�[90m9:25AM�[0m �[31mERR�[0m �[1mFail to load global/context configuration�[0m �[36merror=�[0m�[31m�[1m"Get \"http://localhost:8080/api\": dial tcp [::1]:8080: connect: connection refused\nunable to activate context \"\": getcontext - invalid context specified: \"\"\ncannot connect to context: \nk8s connection failed for context: "�[0m�[0m
�[90m9:25AM�[0m �[31mERR�[0m �[1mUnable to assert active namespace. Using default�[0m �[36merror=�[0m�[31m�[1m"getcontext - invalid context specified: \"\""�[0m�[0m
�[90m9:25AM�[0m �[31mERR�[0m �[1mLoad cluster resources - No API server connection�[0m
�[90m9:25AM�[0m �[31mERR�[0m �[1mfailed to list contexts�[0m �[36merror=�[0m�[31m�[1m"no connection"�[0m�[0m
�[90m9:25AM�[0m �[33mWRN�[0m �[1mUnable to dial discovery API�[0m �[36merror=�[0m�[31m�[1m"no connection to dial"�[0m�[0m
�[90m9:25AM�[0m �[31mERR�[0m �[1mUnable to assert active namespace. Using default�[0m �[36merror=�[0m�[31m�[1m"getcontext - invalid context specified: \"\""�[0m�[0m
�[90m9:25AM�[0m �[31mERR�[0m �[1mUnable to assert active namespace. Using default�[0m �[36merror=�[0m�[31m�[1m"getcontext - invalid context specified: \"\""�[0m�[0m
�[90m9:25AM�[0m �[31mERR�[0m �[1mUnable to assert active namespace. Using default�[0m �[36merror=�[0m�[31m�[1m"getcontext - invalid context specified: \"\""�[0m�[0m
�[90m9:25AM�[0m �[31mERR�[0m �[1mUnable to assert active namespace. Using default�[0m �[36merror=�[0m�[31m�[1m"getcontext - invalid context specified: \"\""�[0m�[0m
�[90m9:25AM�[0m �[31mERR�[0m �[1mcan't connect to cluster�[0m �[36merror=�[0m�[31m�[1m"Get \"http://localhost:8080/version?timeout=15s\": dial tcp [::1]:8080: connect: connection refused"�[0m�[0m
�[90m9:25AM�[0m �[31mERR�[0m �[1mLoad cluster resources - No API server connection�[0m
�[90m9:25AM�[0m �[33mWRN�[0m �[1mUnable to dial discovery API�[0m �[36merror=�[0m�[31m�[1m"no connection to dial"�[0m�[0m
�[90m9:25AM�[0m �[33mWRN�[0m �[1mPlugins load failed: getcontext - invalid context specified: ""�[0m
�[90m9:25AM�[0m �[33mWRN�[0m �[1mPlugins load failed: getcontext - invalid context specified: ""�[0m
�[90m9:25AM�[0m �[33mWRN�[0m �[1mPlugins load failed: getcontext - invalid context specified: ""�[0m
�[90m9:26AM�[0m �[31mERR�[0m �[1mfailed to list namespaces�[0m �[36merror=�[0m�[31m�[1m"user not authorized to list all namespaces"�[0m�[0m
�[90m9:26AM�[0m �[33mWRN�[0m �[1mSave failed. no active config detected�[0m
�[90m9:26AM�[0m �[31mERR�[0m �[1mnuking k9s shell pod�[0m �[36merror=�[0m�[31m�[1m"getcontext - invalid context specified: \"\""�[0m�[0m

Expected behavior
I'll end up in the k9s context meny with no error.

Versions (please complete the following information):

  • OS: OSX 14
  • K9s: v0.32.4
  • K8s: v1.29.3
@emilkor1
Copy link

emilkor1 commented Apr 5, 2024

Happens to me as well, both with and without plugins. It seems to block me from choosing context for ~5 seconds with the following error: "😡 no connection to cached dial". Does not happen with k9s --context ....

@wazazaby
Copy link

wazazaby commented Apr 9, 2024

Encountering the exact same problem as Emil, on K9s v0.32.4 and K8s v1.29.1.

@michaelfich
Copy link

I've also been encountering this issue. If I set a context explicitly prior to opening k9s, it's fine but I cannot switch to another context while in k9s without it breaking.

@jtnz
Copy link

jtnz commented May 1, 2024

Another way to reproduce this is:

KUBECONFIG='' k9s

Not only does this issue prevent you from selecting a context, but is also the cause of another long standing issue I've had that k9s will exit if you don't select a context fast enough.

We don't want to set a context (current-context: "") as we have many different k8s clusters and don't want any tooling connecting to one by default. We use the following as our ~/.kube/config file, as generated by:

$ KUBECONFIG='' kubectl config view
apiVersion: v1
clusters: null
contexts: null
current-context: ""
kind: Config
preferences: {}
users: null

We thenhave a standalone config file per cluster, joined together in $KUBECONFIG, e.g.

$ echo $KUBECONFIG
/home/foo/.kube/config:/home/foo/.kube/cluster-1:/home/foo/.kube/cluster-2:/home/foo/.kube/cluster-3

This all works 100% fine with kubectl --context context-1.

Also tested by wiping out ~/.local/share/k9s, ~/.local/state/k9s, and ~/.config/k9s.

Here's the full logs (KUBECONFIG='' k9s -l debug):

4:14PM INF 🐶 K9s starting up...
4:14PM ERR Fail to locate metrics-server error="Get \"http://localhost:8080/api\": dial tcp [::1]:8080: connect: connection refused"
4:14PM ERR config refine failed error="unable to activate context \"\": getcontext - invalid context specified: \"\""
4:14PM ERR can't connect to cluster error="Get \"http://localhost:8080/version?timeout=15s\": dial tcp [::1]:8080: connect: connection refused"
4:14PM INF ✅ Kubernetes connectivity
4:14PM WRN Save failed. no active config detected
4:14PM ERR Fail to load global/context configuration error="Get \"http://localhost:8080/api\": dial tcp [::1]:8080: connect: connection refused\nunable to activate context \"\": getcontext - invalid context specified: \"\"\ncannot connect to context: \nk8s connection failed for context: "
4:14PM DBG [Skin] Loading global skin ("skin")
4:14PM DBG Loading skin file: "/home/foo/.config/k9s/skins/skin.yaml"
4:14PM ERR Unable to assert active namespace. Using default error="getcontext - invalid context specified: \"\""
4:14PM DBG Factory START with ns `"default"
4:14PM ERR Load cluster resources - No API server connection
4:14PM ERR failed to list contexts error="no connection"
4:14PM DBG Fetching latest k9s rev...
4:14PM DBG K9s latest rev: "v0.32.4"
4:14PM DBG [Skin] Loading global skin ("skin")
4:14PM DBG Loading skin file: "/home/foo/.config/k9s/skins/skin.yaml"
4:14PM WRN Unable to dial discovery API error="no connection to dial"
4:14PM ERR Unable to assert active namespace. Using default error="getcontext - invalid context specified: \"\""
4:14PM ERR Unable to assert active namespace. Using default error="getcontext - invalid context specified: \"\""
4:14PM ERR Unable to assert active namespace. Using default error="getcontext - invalid context specified: \"\""
4:14PM ERR Unable to assert active namespace. Using default error="getcontext - invalid context specified: \"\""
4:14PM ERR can't connect to cluster error="Get \"http://localhost:8080/version?timeout=15s\": dial tcp [::1]:8080: connect: connection refused"
4:14PM ERR Load cluster resources - No API server connection
4:14PM WRN Unable to dial discovery API error="no connection to dial"
4:14PM WRN Plugins load failed: getcontext - invalid context specified: ""
4:14PM WRN Plugins load failed: getcontext - invalid context specified: ""
4:14PM WRN Plugins load failed: getcontext - invalid context specified: ""
4:14PM WRN Plugins load failed: getcontext - invalid context specified: ""
4:14PM WRN Plugins load failed: getcontext - invalid context specified: ""
4:14PM WRN Plugins load failed: getcontext - invalid context specified: ""
4:14PM WRN Plugins load failed: getcontext - invalid context specified: ""
4:14PM WRN Plugins load failed: getcontext - invalid context specified: ""
4:14PM ERR can't connect to cluster error="Get \"http://localhost:8080/version?timeout=15s\": dial tcp [::1]:8080: connect: connection refused"
4:14PM ERR ClusterUpdater failed error="conn check failed (1/5)"
4:14PM ERR can't connect to cluster error="Get \"http://localhost:8080/version?timeout=15s\": dial tcp [::1]:8080: connect: connection refused"
4:14PM ERR ClusterUpdater failed error="conn check failed (2/5)"
4:14PM ERR can't connect to cluster error="Get \"http://localhost:8080/version?timeout=15s\": dial tcp [::1]:8080: connect: connection refused"
4:14PM ERR ClusterUpdater failed error="conn check failed (3/5)"
4:14PM ERR can't connect to cluster error="Get \"http://localhost:8080/version?timeout=15s\": dial tcp [::1]:8080: connect: connection refused"
4:14PM ERR ClusterUpdater failed error="conn check failed (4/5)"
4:14PM ERR can't connect to cluster error="Get \"http://localhost:8080/version?timeout=15s\": dial tcp [::1]:8080: connect: connection refused"
4:14PM ERR Conn check failed (5/5). Bailing out!
4:14PM WRN Save failed. no active config detected
4:14PM ERR nuking k9s shell pod error="getcontext - invalid context specified: \"\""

@mahdizojaji
Copy link

i have this issue too

@bakgaard
Copy link

I got around my issue by specifying the context's namespace I had access to in my kube-config. I was not allowed to see all namespaces, but limiting it to a specific solved it.

@mahdizojaji
Copy link

I got around my issue by specifying the context's namespace I had access to in my kube-config. I was not allowed to see all namespaces, but limiting it to a specific solved it.

when we have mutiple cluster, we couldnt limit to specific namespace

tws-rdelatorre added a commit to tws-rdelatorre/k9s that referenced this issue May 22, 2024
When loading plugins, skip loading context-aware configurations if there
is no current context (i.e. when `current-context` in the kubeconfig is
empty).
@tws-rdelatorre
Copy link

tws-rdelatorre commented May 22, 2024

The issue seems to be at the point where k9s tries to load plugins based on the context when said context is empty. I gave a PR a shot by just ignoring the loading of plugins from the context-based directory if the context comes empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants