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

k8sgpt v0.3.11 or later crashes on Linux when running --filter ValidatingWebhookConfiguration #647

Closed
3 of 4 tasks
upr-kmd opened this issue Sep 12, 2023 · 6 comments · Fixed by #652
Closed
3 of 4 tasks

Comments

@upr-kmd
Copy link

upr-kmd commented Sep 12, 2023

Checklist

  • I've searched for similar issues and couldn't find anything matching
  • I've included steps to reproduce the behavior

Affected Components

  • K8sGPT (CLI)
  • K8sGPT Operator

K8sGPT Version

v0.3.14

Kubernetes Version

v1.25.11+1485cc9

Host OS and its Version

Ubuntu 22.04.3, RHEL 9.2

Steps to reproduce

  1. Install (or update to) k8sgpt v0.3.14 on Linux (tested on Ubuntu and RHEL 9.2)
  2. Run an analyze command

Red Hat Enterprise Linux 9:

$ k8sgpt analyze -e
panic: runtime error: slice bounds out of range [:-1]

goroutine 33 [running]:
github.com/k8sgpt-ai/k8sgpt/pkg/util.MapToString(0x0?)
        /home/runner/work/k8sgpt/k8sgpt/pkg/util/util.go:220 +0x165
github.com/k8sgpt-ai/k8sgpt/pkg/analyzer.ValidatingWebhookAnalyzer.Analyze({}, {0xc000a64480, {0x2c6a2c0, 0xc000120028}, {0x0, 0x0}, {0x2c6a9f8, 0x3fb9840}, 0x0, {0x0, ...}, ...})
        /home/runner/work/k8sgpt/k8sgpt/pkg/analyzer/validating_webhook.go:81 +0x988
github.com/k8sgpt-ai/k8sgpt/pkg/analysis.(*Analysis).RunAnalysis.func1({0x2c4e520, 0x3ff8de0}, 0x0?, 0x0?)
        /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

Ubuntu 22.04:

$ k8sgpt analyze -e
panic: runtime error: slice bounds out of range [:-1]

goroutine 32 [running]:
github.com/k8sgpt-ai/k8sgpt/pkg/util.MapToString(0x0?)
        /home/runner/work/k8sgpt/k8sgpt/pkg/util/util.go:220 +0x165
github.com/k8sgpt-ai/k8sgpt/pkg/analyzer.ValidatingWebhookAnalyzer.Analyze({}, {0xc0004a0c30, {0x2c6a2c0, 0xc00011a028}, {0x0, 0x0}, {0x2c6a9f8, 0x3fb9840}, 0x0, {0x0, ...}, ...})
        /home/runner/work/k8sgpt/k8sgpt/pkg/analyzer/validating_webhook.go:81 +0x988
github.com/k8sgpt-ai/k8sgpt/pkg/analysis.(*Analysis).RunAnalysis.func1({0x2c4e520, 0x3ff8de0}, 0x0?, 0x0?)
        /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

Expected behaviour

Getting any working output

Actual behaviour

a panic runtime error

Additional Information

No response

@upr-kmd
Copy link
Author

upr-kmd commented Sep 12, 2023

Ubuntu's case was an update from a previous version, RHEL's case was a clean installation.

@AlexsJones
Copy link
Member

I believe this is occurring when you have a service without a selector on it.
It's certainly a bug that it crashes but I need to know more about the services it might be catching on.

@upr-kmd
Copy link
Author

upr-kmd commented Sep 12, 2023

I've managed to find a version without this bug.

pk@host01:~$ ./k8sgpt version
ks8gpt: 0.3.5 (a236cc4), built at: unknown
pk@host01:~$ ./k8sgpt analyze
AI Provider: openai

0 hive/hive-clustersync(hive-clustersync)
- Error: StatefulSet uses the service hive/ which does not exist.

1 openshift-gitops/openshift-gitops-application-controller(openshift-gitops-application-controller)
- Error: StatefulSet uses the service openshift-gitops/openshift-gitops-application-controller which does not exist.

2 openshift-terminal/workspace0fe27d119c8b40cd-service(workspace0fe27d119c8b40cd-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspace0fe27d119c8b40cd

3 openshift-terminal/workspace469bc0f3143541c0-service(workspace469bc0f3143541c0-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspace469bc0f3143541c0

4 openshift-terminal/workspace668879ddd05246e2-service(workspace668879ddd05246e2-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspace668879ddd05246e2

5 openshift-terminal/workspacef68eddaf8a5647f4-service(workspacef68eddaf8a5647f4-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspacef68eddaf8a5647f4

6 open-cluster-management/insights-client(insights-client)
- Error: Service has no endpoints, expected label app=policyreport
- Error: Service has no endpoints, expected label component=insights-client
- Error: Service has no endpoints, expected label release=policyreport

7 openshift-operators/gitops-operator-controller-manager-metrics-service(gitops-operator-controller-manager-metrics-service)
- Error: Service has no endpoints, expected label control-plane=argocd-operator

8 openshift-terminal/workspace0dcc9b68fae54cb7-service(workspace0dcc9b68fae54cb7-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspace0dcc9b68fae54cb7

@upr-kmd
Copy link
Author

upr-kmd commented Sep 12, 2023

Bug exists in version 0.3.11 or later
./k8sgpt version
k8sgpt: 0.3.11 (ee83aa1), built at: unknown

@upr-kmd
Copy link
Author

upr-kmd commented Sep 12, 2023

Version 0.3.9 doesn't have this bug

$ ./k8sgpt version
k8sgpt: 0.3.9 (ad112ea), built at: unknown
pk@host2:~$ ./k8sgpt analyze
AI Provider: openai

0 nmdt02/mysql-router-7d75b7c5fb-glswz(Deployment/mysql-router)
- Error: back-off 5m0s restarting failed container=mysql-router pod=mysql-router-7d75b7c5fb-glswz_nmdt02(54d71a39-11e8-4bbd-8888-a321c7f6af58)

1 rhacs-operator/collector-lwvbm(collector)
- Error: back-off 5m0s restarting failed container=compliance pod=collector-lwvbm_rhacs-operator(f9374db1-28b5-4928-84d8-d2824d6df62c)

2 rhacs-operator/collector-slmc4(collector)
- Error: back-off 5m0s restarting failed container=compliance pod=collector-slmc4_rhacs-operator(3070dcad-4839-4fef-883c-75181dbc085a)

3 rhacs-operator/sensor-7595bcf76f-bn5xh(sensor)
- Error: Readiness probe failed: Get "https://10.130.3.116:9443/ready": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

4 hive/hive-clustersync(hive-clustersync)
- Error: StatefulSet uses the service hive/ which does not exist.

5 openshift-gitops/openshift-gitops-application-controller(openshift-gitops-application-controller)
- Error: StatefulSet uses the service openshift-gitops/openshift-gitops-application-controller which does not exist.

6 openshift-user-workload-monitoring/thanos-ruler-user-workload(thanos-ruler-user-workload)
- Error: StatefulSet uses the service openshift-user-workload-monitoring/ which does not exist.

7 ansible-automation-platform/aactrl-postgres-13(aactrl-postgres-13)
- Error: StatefulSet uses the service ansible-automation-platform/aactrl which does not exist.

8 stackrox/admission-control(admission-control)
- Error: Service has no endpoints, expected label app=admission-control

9 openshift-terminal/workspace3c2f8899b6cd4e08-service(workspace3c2f8899b6cd4e08-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspace3c2f8899b6cd4e08

10 openshift-terminal/workspacec36e22d5d4ec41e5-service(workspacec36e22d5d4ec41e5-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspacec36e22d5d4ec41e5

11 openshift-terminal/workspaceff691f56cdb0461d-service(workspaceff691f56cdb0461d-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspaceff691f56cdb0461d

12 openshift-terminal/workspacef8cab1b156664037-service(workspacef8cab1b156664037-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspacef8cab1b156664037

13 nmd-web-app/tescik(tescik)
- Error: Service has no endpoints, expected label deployment=tescik

14 open-cluster-management/ocm-webhook(ocm-webhook)
- Error: Service has no endpoints, expected label app=ocm-webhook

15 openshift-terminal/workspace7147ab4326734f49-service(workspace7147ab4326734f49-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspace7147ab4326734f49

16 openshift-operators/simpleservice(simpleservice)
- Error: Service has no endpoints, expected label app=sise

17 nmdt02/mysql-router(mysql-router)
- Error: Service has not ready endpoints, pods: [Pod/mysql-
18 openshift-operators/gitops-operator-controller-manager-metrics-service(gitops-operator-controller-manager-metrics-service)
- Error: Service has no endpoints, expected label control-plane=argocd-operator

19 openshift-terminal/workspace557846210b4a4e4e-service(workspace557846210b4a4e4e-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspace557846210b4a4e4e

20 openshift-terminal/workspacebf07822895e34b7f-service(workspacebf07822895e34b7f-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspacebf07822895e34b7f

21 rhacs-operator/sensor(sensor)
- Error: Service has not ready endpoints, pods: [Pod/sensor-7595bcf76f-bn5xh], expected 1

22 cicd/gogs(gogs)
- Error: Service has no endpoints, expected label app=gogs
- Error: Service has no endpoints, expected label name=gogs

23 cicd/gogs-postgresql(gogs-postgresql)
- Error: Service has no endpoints, expected label app=gogs
- Error: Service has no endpoints, expected label name=gogs-postgresql

24 nmd-is/dbapp(dbapp)
- Error: Service has no endpoints, expected label deployment=dbapp

25 openshift-terminal/workspace34db7c7195564878-service(workspace34db7c7195564878-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspace34db7c7195564878

26 openshift-terminal/workspacea246c1c33d69449f-service(workspacea246c1c33d69449f-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspacea246c1c33d69449f

27 pdw-webconsole/workspaceb70b9faa852747f2-service(workspaceb70b9faa852747f2-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspaceb70b9faa852747f2

28 openshift-operators/spring-petclinic(spring-petclinic)
- Error: Service has no endpoints, expected label app=spring-petclinic

29 openshift-operators/test-simpleservice(test-simpleservice)
- Error: Service has no endpoints, expected label app=sise

30 openshift-terminal/workspace2bcceb708eb84bfa-service(workspace2bcceb708eb84bfa-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspace2bcceb708eb84bfa

31 openshift-terminal/workspacec59abbb26e874d81-service(workspacec59abbb26e874d81-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspacec59abbb26e874d81

32 stackrox/sensor-webhook(sensor-webhook)
- Error: Service has no endpoints, expected label app=sensor

33 cicd/spring-petclinic(spring-petclinic)
- Error: Service has no endpoints, expected label app=spring-petclinic

34 nmd-web-app/tescior(tescior)
- Error: Service has no endpoints, expected label deployment=tescior

35 open-cluster-management/insights-client(insights-client)
- Error: Service has no endpoints, expected label app=policyreport
- Error: Service has no endpoints, expected label component=insights-client
- Error: Service has no endpoints, expected label release=policyreport

36 rhacs-operator/sensor-webhook(sensor-webhook)
- Error: Service has not ready endpoints, pods: [Pod/sensor-7595bcf76f-bn5xh], expected 1

37 stackrox/sensor(sensor)
- Error: Service has no endpoints, expected label app=sensor

38 nmd-web-app/web-app(web-app)
- Error: Service has no endpoints, expected label deployment=web-app

39 openshift-operators/dev-simpleservice(dev-simpleservice)
- Error: Service has no endpoints, expected label app=sise

40 openshift-terminal/workspacec3b274203a6f487a-service(workspacec3b274203a6f487a-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspacec3b274203a6f487a

41 open-cluster-management/ocm-proxyserver(ocm-proxyserver)
- Error: Service has no endpoints, expected label app=ocm-proxyserver

42 openshift-terminal/workspace2e0a62a8fa42403b-service(workspace2e0a62a8fa42403b-service)
- Error: Service has no endpoints, expected label controller.devfile.io/devworkspace_id=workspace2e0a62a8fa42403b

@upr-kmd
Copy link
Author

upr-kmd commented Sep 12, 2023

I've ran all filters one by one, and only 1 of them produced this error.

pk@host01:~$ ./k8sgpt version
k8sgpt: 0.3.11 (ee83aa1), built at: unknown
pk@host01:~$ ./k8sgpt analyze --filter MutatingWebhookConfiguration
AI Provider: openai

No problems detected

pk@host01:~$ ./k8sgpt analyze --filter ValidatingWebhookConfiguration
AI Provider: openai

No problems detected

panic: runtime error: slice bounds out of range [:-1]

goroutine 13 [running]:
github.com/k8sgpt-ai/k8sgpt/pkg/util.MapToString(0x0?)
        /home/runner/work/k8sgpt/k8sgpt/pkg/util/util.go:220 +0x165
github.com/k8sgpt-ai/k8sgpt/pkg/analyzer.ValidatingWebhookAnalyzer.Analyze({}, {0xc000a2f500, {0x2a780d0, 0xc000054128}, {0x0, 0x0}, {0x2a787d0, 0x3d99c60}, 0x0, {0x0, ...}, ...})
        /home/runner/work/k8sgpt/k8sgpt/pkg/analyzer/validating_webhook.go:79 +0x9a5
github.com/k8sgpt-ai/k8sgpt/pkg/analysis.(*Analysis).RunAnalysis.func2({0x2a5cdc0?, 0x3dd91b8?}, {0xc0006474e0, 0x1e})
        /home/runner/work/k8sgpt/k8sgpt/pkg/analysis/analysis.go:198 +0xe2
created by github.com/k8sgpt-ai/k8sgpt/pkg/analysis.(*Analysis).RunAnalysis
        /home/runner/work/k8sgpt/k8sgpt/pkg/analysis/analysis.go:196 +0x8df

@upr-kmd upr-kmd changed the title k8sgpt 0.3.14 crashes on Linux k8sgpt 0.3.11 or later crashes on Linux when running --filter ValidatingWebhookConfiguration Sep 12, 2023
@upr-kmd upr-kmd changed the title k8sgpt 0.3.11 or later crashes on Linux when running --filter ValidatingWebhookConfiguration k8sgpt v0.3.11 or later crashes on Linux when running --filter ValidatingWebhookConfiguration Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants