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

"yaml: line 15: could not find expected ':'" error #2435

Closed
huang-jy opened this issue Jan 8, 2024 · 19 comments
Closed

"yaml: line 15: could not find expected ':'" error #2435

huang-jy opened this issue Jan 8, 2024 · 19 comments
Labels
bug Something isn't working question Further information is requested

Comments

@huang-jy
Copy link

huang-jy commented Jan 8, 2024




Describe the bug
yaml: line 15: could not find expected ':'

To Reproduce
Steps to reproduce the behavior:

  1. Open k9s v0.30.8
  2. Try to access all namespaces (0 on keyboard)
  3. yaml: line 15: could not find expected ':' message

k9s log shows the following:

9:18AM INF 🐶 K9s starting up...
9:18AM ERR refine failed error="yaml: line 15: could not find expected ':'"
9:18AM INF ✅ Kubernetes connectivity
9:18AM ERR Unable to assert active namespace. Using default error="context config is not set"
9:18AM WRN CustomView watcher failed error="open /home/{username}/.config/k9s/views.yaml: no such file or directory"
9:18AM ERR Unable to assert active namespace. Using default error="context config is not set"
9:18AM ERR Unable to assert active namespace. Using default error="context config is not set"
9:18AM ERR Unable to assert active namespace. Using default error="context config is not set"
9:18AM ERR Unable to assert active namespace. Using default error="context config is not set"
9:18AM ERR Unable to assert active namespace. Using default error="context config is not set"
9:18AM ERR Unable to assert active namespace. Using default error="context config is not set"
9:18AM ERR Unable to assert active namespace. Using default error="context config is not set"
9:18AM ERR yaml: line 15: could not find expected ':'

Expected behavior
No errors

Screenshots
image

Versions (please complete the following information):

  • OS: Linux (Fedora 39)
  • K9s: 1.27.6 (GKE)
  • K8s: 0.30.8

Additional context
I have tried wiping the k9s config folder, and also wiping and regenerating my kube config. I'm not sure which yaml k9s is referring to.

@fly82
Copy link

fly82 commented Jan 8, 2024

OS: Rocky Linux 9.3
K9s: v0.30.8
K8s: v1.28.4+rke2r1
the same problem.

@Mabex
Copy link

Mabex commented Jan 8, 2024

OS: Windows 10
K9s Rev: v0.30.8
K8s Rev: v1.23.17-eks-8cb36c9

Same problem. It seems to be related to the config file generated for the cluster (k9s/clusters/[yourCluster]/config.yaml).
At the end of the file a broken line "alhost" (row ~14-15) seems to be automatically be added. Removing it fixed it for me.

@huang-jy
Copy link
Author

huang-jy commented Jan 8, 2024

Same problem. It seems to be related to the config file generated for the cluster (k9s/clusters/[yourCluster]/config.yaml). At the end of the file a broken line "alhost" (row ~14-15) seems to be automatically be added. Removing it fixed it for me.

I also wiped the config folder and still got it, so I'm not sure where it's finding that yaml, unless its somewhere else on my system

@derailed
Copy link
Owner

derailed commented Jan 9, 2024

@huang-jy Looks like something else if going on with your kubeconfig?? since no current context seems to be set.
Does kubectl works with the existing kubeconfig?

@derailed derailed added bug Something isn't working question Further information is requested and removed bug Something isn't working labels Jan 9, 2024
@huang-jy
Copy link
Author

huang-jy commented Jan 9, 2024

@huang-jy Looks like something else if going on with your kubeconfig?? since no current context seems to be set.
Does kubectl works with the existing kubeconfig?

Yes it does still work, I deleted the config and regenerated it using the gcloud binary (my cluster is a gke based cluster)

@derailed
Copy link
Owner

derailed commented Jan 9, 2024

@huang-jy Tx for the details! Are we still unhappy after the kubeconfig regen?
Best I can tell the k8s api client config call is erroring out fetching the current context out of your kubeconfig?? ie something about the yaml is out of wack??

@huang-jy
Copy link
Author

huang-jy commented Jan 9, 2024

Side note, I see a new version of k9s which errored on first boot:

panic: k9s config file "/home/{username}/.config/k9s/config.yaml" load failed:
Additional property fullScreenLogs is not allowed

goroutine 1 [running]:
github.com/derailed/k9s/cmd.Execute(...)
	github.com/derailed/k9s/cmd/root.go:60
main.main()
	github.com/derailed/k9s/main.go:32 +0x3c

Wiping the folder, also panics

panic: save failed. no active config detected

goroutine 1 [running]:
github.com/derailed/k9s/cmd.Execute(...)
	github.com/derailed/k9s/cmd/root.go:60
main.main()
	github.com/derailed/k9s/main.go:32 +0x3c

@huang-jy
Copy link
Author

huang-jy commented Jan 9, 2024

@huang-jy Tx for the details! Are we still unhappy after the kubeconfig regen? Best I can tell the k8s api client config call is erroring out fetching the current context out of your kubeconfig?? ie something about the yaml is out of wack??

I'm able to use OpenLens/Lens with that config without issue (and indeed that's my alternative while I can't use k9s)

@ugref
Copy link

ugref commented Jan 9, 2024

OS : Centos 9
K9s Rev: v0.30.8 ⚡v0.31.1
K8s Rev: v1.28.5
Same 😡 yaml: line 15: could not find expected ':'

@huang-jy
Copy link
Author

huang-jy commented Jan 9, 2024

@derailed so, interesting finding.

I debugged this and tried to get k9s running in an archlinux container. The version of the app available on the archlinux repository is 0.29.1 (a few versions behind), but after a bit of tinkering, k9s loaded,

so I tested 0.29.1 on my local machine, and it WORKED. So between 0.29.1 and 0.30.8 something broke. Testing all versions leads me to this:

0.29.1: ✅
0.30.0: ❌

At 0.30.0, k9s bails on boot:

./k9s
Error: yaml: line 15: could not find expected ':'
Usage:
  k9s [flags]
  k9s [command]

Available Commands:
.....

Use "k9s [command] --help" for more information about a command.

panic: yaml: line 15: could not find expected ':'

goroutine 1 [running]:
github.com/derailed/k9s/cmd.Execute(...)
	github.com/derailed/k9s/cmd/root.go:60
main.main()
	github.com/derailed/k9s/main.go:32 +0x3c

So I guess in the meantime, people should use 0.29.1

@derailed
Copy link
Owner

derailed commented Jan 9, 2024

@huang-jy Thank you for the details! Interesting!! I've tested on gke as well and can't seem to repro ;(

The latest error is expected as your root k9s config is not up to snuff (see v0.31.0) rel notes Breaking Bad or video: https://youtu.be/X3444KfjguE

Could you update to v0.31.1 and share the following outputs:
o k9s info
o k9s -l debug
o k9s -l debug --context XXX
o your root k9s config.yaml and kubeconfig current context config.yaml

Thanks you for your patience and helping us zero in on root cause!
Also going to push v0.31.2 (likely not going to solve this but added debug info to hopefully see where we bomb??)

@derailed derailed added the bug Something isn't working label Jan 9, 2024
@huang-jy
Copy link
Author

huang-jy commented Jan 9, 2024

k9s info

 ____  __.________
|    |/ _/   __   \______
|      < \____    /  ___/
|    |  \   /    /\___ \
|____|__ \ /____//____  >
        \/            \/

Version:           v0.31.1
Config:            /home/{username}/.config/k9s/config.yaml
Custom Views:      /home/{username}/.config/k9s/views.yaml
Plugins:           /home/{username}/.config/k9s/plugins.yaml
Hotkeys:           /home/{username}/.config/k9s/hotkeys.yaml
Aliases:           /home/{username}/.config/k9s/aliases.yaml
Skins:             /home/{username}/.config/k9s/skins
Context Configs:   /home/{username}/.local/share/k9s/clusters
Logs:              /home/{username}/.local/state/k9s/k9s.log
Benchmarks:        /home/{username}/.local/state/k9s/benchmarks
ScreenDumps:       /home/{username}/.local/state/k9s/screen-dumps

k9s -l debug

Error: k9s config file "/home/{username}/.config/k9s/config.yaml" load failed:
Additional property blackList is not allowed
Additional property fullScreenLogs is not allowed
Usage:
  k9s [flags]
  k9s [command]
...

k9s -l debug --context XXX

Error: k9s config file "/home/{username}/.config/k9s/config.yaml" load failed:
Additional property blackList is not allowed
Additional property fullScreenLogs is not allowed
Usage:
  k9s [flags]
  k9s [command]
...

k9s config (/home/{username}/.config/k9s/config.yaml)

k9s:
  liveViewAutoRefresh: false
  screenDumpDir: /home/{username}/.local/state/k9s/screen-dumps
  refreshRate: 2
  maxConnRetry: 5
  readOnly: false
  noExitOnCtrlC: false
  ui:
    enableMouse: false
    headless: false
    logoless: false
    crumbsless: false
    noIcons: false
  skipLatestRevCheck: false
  disablePodCounting: false
  shellPod:
    image: busybox:1.35.0
    namespace: default
    limits:
      cpu: 100m
      memory: 100Mi
  imageScans:
    enable: false
    blackList:
      namespaces: []
      labels: {}
  logger:
    tail: 100
    buffer: 5000
    sinceSeconds: -1
    fullScreenLogs: false
    textWrap: false
    showTime: false
  thresholds:
    cpu:
      critical: 90
      warn: 70
    memory:
      critical: 90
      warn: 70

kubeconfig current context config.yaml (since I wiped this and regenerated it, there's only really one item -- have redacted cluster names, etc.)

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: [REDACTED]
    server: https://[REDACTED]
  name: gke_[REDACTED]
contexts:
- context:
    cluster: gke_[REDACTED]
    user: gke_[REDACTED]
  name: gke_[REDACTED]
current-context: gke_[REDACTED]
kind: Config
preferences: {}
users:
- name: gke_[REDACTED]
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      command: gke-gcloud-auth-plugin
      installHint: Install gke-gcloud-auth-plugin for use with kubectl by following
        https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke
      provideClusterInfo: true

@derailed
Copy link
Owner

derailed commented Jan 9, 2024

@huang-jy Thank you for the details! Ok let's see if we can get back to the original error...

o Please update k9s to the latest rev v0.31.2 should be out.
o Move or delete your home/{username}/.config/k9s/config.yaml -> home/{username}/.config/k9s/config-old.yaml
I expect a new proper root config will be generated.
o Run: k9s -l debug and attach the logs.

@huang-jy
Copy link
Author

huang-jy commented Jan 9, 2024

./k9s -l debug
Error: unable to activate context "": validation failed for "/home/johnny/.local/share/k9s/clusters/gke_[REDACTED]/gke_[REDACTED]/config.yaml": yaml: line 14: could not find expected ':'
Usage:
  k9s [flags]
  k9s [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  info        List K9s configurations info
  version     Print version/build info

And inside the yaml..... we have the culprit :-)

k9s:
  cluster: gke_[REDACTED]
  readOnly: false
  namespace:
    active: default
    lockFavorites: false
    favorites:
    - default
  view:
    active: po
  featureGates:
    nodeShell: false
  portForwardAddress: localhost
calhost

Yes, there's an erroneous calhost there for some reason, similar to what was mentioned in this comment. Removing that stray line allows k9s to work.

Next question to answer is how it got there in the first place

@derailed
Copy link
Owner

derailed commented Jan 9, 2024

@huang-jy Thank you so much for reporting back and your details here!
Did the /home/johnny/.local/share/k9s/clusters/gke_[REDACTED]/gke_[REDACTED]/config.yaml existed prior to the last k9s update or was it freshly generated?

@huang-jy
Copy link
Author

@huang-jy Thank you so much for reporting back and your details here! Did the /home/johnny/.local/share/k9s/clusters/gke_[REDACTED]/gke_[REDACTED]/config.yaml existed prior to the last k9s update or was it freshly generated?

it existed, I didn't think to check or delete this file because I didn't know k9s stored a config in ~/.local/share/

derailed added a commit that referenced this issue Jan 10, 2024
derailed added a commit that referenced this issue Jan 10, 2024
* allow k9s to run with errors

* fixes #2459 #2458 #2454 #2435

* v0.31.3 rel notes
@derailed
Copy link
Owner

@huang-jy Not sure if this is a flake or not? I think I may have found an issue?? Please give v0.31.3 a rinse.
Please keep and eye out for potential future config corruptions...
Thank you for the details and your support thru this!

@Tarald93
Copy link

Tarald93 commented Feb 8, 2024

K9s Rev: v0.31.8
K8s Rev: v1.27.3
K9s throgh brew on WSL2 Ubuntu 20.04.6 LTS
Saw reports of the added "calhost", in their config. /home/USER/.local/share/k9s/clusters/REDACTED/REDACTED/config.yaml

  featureGates:
    nodeShell: false
  portForwardAddress: localhost
  Gates:
    nodeShell: false
  portForwardAddress: localhost

Worked after removing "Gates" and everything underneath.
Not sure if it's supposed to be there or not. But took a hail mary after not seeing it in others config.

@sudippain
Copy link

Check log from below file :
/home/<user_name>/.local/state/k9s/k9s.log

Then delete target cluster directory :
rm -rf /home/ngxpdev/.local/share/k9s/clusters/<cluster_name>

thejoeejoee pushed a commit to thejoeejoee/k9s that referenced this issue Feb 23, 2024
* allow k9s to run with errors

* fixes derailed#2459 derailed#2458 derailed#2454 derailed#2435

* v0.31.3 rel notes
placintaalexandru pushed a commit to placintaalexandru/k9s that referenced this issue Apr 3, 2024
* allow k9s to run with errors

* fixes derailed#2459 derailed#2458 derailed#2454 derailed#2435

* v0.31.3 rel notes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants