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

[bug] Error: flags cannot be placed before plugin name: --context #66

Closed
jacksgt opened this issue Oct 4, 2021 · 3 comments
Closed

Comments

@jacksgt
Copy link

jacksgt commented Oct 4, 2021

Hi there,
thank you for this excellent Emacs package! I've been using it since half a year and the experience is simply great.

Recently, I updated my system components and now I'm running a more recent version of Kubernetes / kubectl.
With this version, I'm getting the following error message:
Error: flags cannot be placed before plugin name: --context
Unfortunately, this completely breaks the package, since no other action can be performed.

*kubel-process* says the following:

[kubectl-command]
command: kubectl config current-context
[kubectl-command]
command: kubectl --context error: current-context is not set get Pods
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.2", GitCommit:"8b5a19147530eaac9476b0ab82980b4088bbc1b2", GitTreeState:"archive", BuildDate:"2021-09-16T09:21:16Z", GoVersion:"go1.17.1", Compiler:"gc", Platform:"linux/amd64"}

I found this kubectl issue due to which this behavior was apparently introduced: kubernetes/kubectl#884

@abrochard
Copy link
Owner

Hey @jacksgt ,
Thank you for reporting this.
Looking at the *kubel-process*, I have a theory as to what is happening:

  1. we run kubectl config current-context to try to determine which context you are using
  2. that command fails and kubectl actually returns error: current-context is not set
  3. we don't detect an error and set kubel-context to error: current-context is not set
  4. we try to bring up the list of pods which runs kubectl --context $kubel-context get pods where $kubel-context is incorrectly set to that error message

To validate the theory (and also as a workaround), you can try setting your context to default with either:

  1. kubectl config set-context default in your shell before running kubel
  2. (setq kubel-context "default")

Let me know if this works.

@jacksgt
Copy link
Author

jacksgt commented Oct 5, 2021

Hi, thanks for getting back to me so quickly!

Indeed, I have the kubeconfig in a "non-standard" location (basically I'm using a separate kubeconfig for each project).
My plan was to invoke M-x kubel and then use K to set the location of that kubeconfig.
But that resulted in the above error.
Also calling kubectl config set-context default results in the same error message, even though kubectl then creates an empty kubeconfig:

apiVersion: v1
clusters: null
contexts:
- context:
    cluster: ""
    user: ""
  name: default
current-context: ""
kind: Config
preferences: {}
users: null

When I run (setq kubel-context "default") I get the error message Error in configuration: context was not found for specified context: default. However, now I can set my custom kubeconfig with K and afterwards switch to the appropriate context with C.

So in the end I think this was just user error. Though maybe the error message could be improved.
Thanks for taking the time to investigate!

@jacksgt jacksgt closed this as completed Oct 5, 2021
@abrochard
Copy link
Owner

Awesome. Thank you for letting me know. Hopefully we can strengthen our error message in the future.

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

2 participants