k8sgpt-ai / k8sgpt

Giving Kubernetes Superpowers to everyone
http://k8sgpt.ai
Apache License 2.0
5.82k stars 675 forks source link

Can not analyze EKS: invalid memory address or nil pointer dereference #566

Closed raulmartinezr closed 1 year ago

raulmartinezr commented 1 year ago

Checklist

Affected Components

K8sGPT Version

k8sgpt: 0.3.12 (9d2bee9), built at: unknown

Kubernetes Version

No response

Host OS and its Version

Ubuntu 22.04

Steps to reproduce

1.- k8sgpt installed following the instructions for Ubuntu based systems (k8sgpt_amd64.deb) 2.- OpenAI aoikey added with: k8sgpt auth add --backend openai -m gpt-3.5-turbo 3.- Kubecondig refreshed with aws eks cli: aws eks update-kubeconfig 4.- Analysis triggered:  k8sgpt analyze

Expected behaviour

k8s analyzes EKS cluster and results are obtained

Actual behaviour

Suddenly an error ir raised:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1e7dc4a]

goroutine 78 [running]:
github.com/k8sgpt-ai/k8sgpt/pkg/analyzer.MutatingWebhookAnalyzer.Analyze({}, {0xc000b8e300, {0x2c3f640, 0xc00012e018}, {0x0, 0x0}, {0x2c3fd78, 0x3f76e40}, 0x0, {0x0, ...}, ...})
    /home/runner/work/k8sgpt/k8sgpt/pkg/analyzer/mutating_webhook.go:58 +0x60a
github.com/k8sgpt-ai/k8sgpt/pkg/analysis.(*Analysis).RunAnalysis.func1({0x2c24160, 0x3fb63d8}, 0xc0009ef670?, 0x6?)
    /home/runner/work/k8sgpt/k8sgpt/pkg/analysis/analysis.go:171 +0xd8
created by github.com/k8sgpt-ai/k8sgpt/pkg/analysis.(*Analysis).RunAnalysis
    /home/runner/work/k8sgpt/k8sgpt/pkg/analysis/analysis.go:169 +0xa1d

Additional Information

KubeConfig contents. Kubectl working properly with it

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: CA Content..
    server: https://C8239EF7106434D729A7370A4FB7FBEC.gr7.eu-west-1.eks.amazonaws.com
  name: arn:aws:eks:eu-west-1:562348615205:cluster/tests_kubedapr-eu-west-1-eks-a257c3
- cluster:
    certificate-authority-data: CA Content..
    server: https://B548A5671FACA20E095BE3560FA461D4.gr7.eu-west-1.eks.amazonaws.com
  name: arn:aws:eks:eu-west-1:562348615205:cluster/eks-tests-kubedapr-eu-west-1-a257c3
- cluster:
    certificate-authority-data: CA Content..
    server: https://18340870F12F460368AC8CB2C85E2B9A.sk1.eu-west-1.eks.amazonaws.com
  name: arn:aws:eks:eu-west-1:562348615205:cluster/kube-kubedapr-eu-west-1-a257
contexts:
- context:
    cluster: arn:aws:eks:eu-west-1:562348615205:cluster/tests_kubedapr-eu-west-1-eks-a257c3
    user: arn:aws:eks:eu-west-1:562348615205:cluster/tests_kubedapr-eu-west-1-eks-a257c3
  name: tests_kubedapr-eu-west-1-eks-a257c3
- context:
    cluster: arn:aws:eks:eu-west-1:562348615205:cluster/eks-tests-kubedapr-eu-west-1-a257c3
    user: arn:aws:eks:eu-west-1:562348615205:cluster/eks-tests-kubedapr-eu-west-1-a257c3
  name: eks-tests-kubedapr-eu-west-1-a257c3
- context:
    cluster: arn:aws:eks:eu-west-1:562348615205:cluster/kube-kubedapr-eu-west-1-a257
    user: arn:aws:eks:eu-west-1:562348615205:cluster/kube-kubedapr-eu-west-1-a257
  name: kube-kubedapr-eu-west-1-a257
current-context: kube-kubedapr-eu-west-1-a257
kind: Config
preferences: {}
users:
- name: arn:aws:eks:eu-west-1:562348615205:cluster/tests_kubedapr-eu-west-1-eks-a257c3
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      args:
      - --region
      - eu-west-1
      - eks
      - get-token
      - --cluster-name
      - tests_kubedapr-eu-west-1-eks-a257c3
      - --output
      - json
      command: aws
      env:
      - name: AWS_PROFILE
        value: play
- name: arn:aws:eks:eu-west-1:562348615205:cluster/eks-tests-kubedapr-eu-west-1-a257c3
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      args:
      - --region
      - eu-west-1
      - eks
      - get-token
      - --cluster-name
      - eks-tests-kubedapr-eu-west-1-a257c3
      - --output
      - json
      command: aws
      env:
      - name: AWS_PROFILE
        value: play
- name: arn:aws:eks:eu-west-1:562348615205:cluster/kube-kubedapr-eu-west-1-a257
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      args:
      - --region
      - eu-west-1
      - eks
      - get-token
      - --cluster-name
      - kube-kubedapr-eu-west-1-a257
      - --output
      - json
      command: aws
      env:
      - name: AWS_PROFILE
        value: play
arbreezy commented 1 year ago

it's most likely happening, cause one of your mutating webhooks are missing the service attribute, try to de activate the mutating-webhook analyser until we throw a new release.

AlexsJones commented 1 year ago

Please upgrade to https://github.com/k8sgpt-ai/k8sgpt/releases/tag/v0.3.13

brew upgrade k8sgpt which has fixes for this