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

panic: interface conversion: interface {} is nil, not string #124

Closed
swaroop1012 opened this issue Apr 5, 2021 · 8 comments · Fixed by #198
Closed

panic: interface conversion: interface {} is nil, not string #124

swaroop1012 opened this issue Apr 5, 2021 · 8 comments · Fixed by #198
Assignees
Labels
bug Something isn't working
Milestone

Comments

@swaroop1012
Copy link

Running into the below issue while running kubent, can someone help?

panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
github.com/doitintl/kube-no-trouble/pkg/judge.(*RegoJudge).Eval(0xc00015fc10, 0xc000273500, 0x29c, 0x2a0, 0x29c, 0x2a0, 0x0, 0x1f4, 0xc0002f4390)
	/__w/kube-no-trouble/kube-no-trouble/pkg/judge/rego.go:76 +0x7c2
main.main()
	/__w/kube-no-trouble/kube-no-trouble/cmd/kubent/main.go:97 +0x3be

Go version - go1.15.5 darwin/amd64

kubent version - 0.3.2

@stepanstipl
Copy link
Contributor

Hi @swaroop1012, thanks for reporting this. Would you be able to share the complete output, incl. how you execute the kubent? This should help us to further debug the issue, thanks!

@stepanstipl stepanstipl added this to the Next Minor (0.5.0?) milestone Apr 9, 2021
@swaroop1012
Copy link
Author

Hi @stepanstipl thanks for the reply and apologies for the late reply, I missed the mail. I downloaded the tar file, unzipped it and ran the binary. Please find the full output below.

$ /usr/local/bin/kubent 
1:02PM INF >>> Kube No Trouble `kubent` <<<
1:02PM INF version 0.3.2 (git sha 919129b596890475965cda2b972cb6fded71f40b)
1:02PM INF Initializing collectors and retrieving data
1:02PM INF Retrieved 58 resources from collector name=Cluster
1:02PM INF Retrieved 994 resources from collector name="Helm v2"
1:02PM INF Retrieved 0 resources from collector name="Helm v3"
1:02PM INF Loaded ruleset name=deprecated-1-16.rego
1:02PM INF Loaded ruleset name=deprecated-1-22.rego
panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
github.com/doitintl/kube-no-trouble/pkg/judge.(*RegoJudge).Eval(0xc000c54430, 0xc00005ea00, 0x41c, 0x4a0, 0x41c, 0x4a0, 0x0, 0x1f4, 0xc0002d84e0)
	/__w/kube-no-trouble/kube-no-trouble/pkg/judge/rego.go:76 +0x7c2
main.main()
	/__w/kube-no-trouble/kube-no-trouble/cmd/kubent/main.go:97 +0x3be

If I use the below command, I get the output without any error but I'm not sure if the list is exhaustive.

/usr/local/bin/kubent --helm2=false

@ghost
Copy link

ghost commented May 19, 2021

After a deeper investigation, we believe this bug has been fixed by a previous release.

the line in question being:

m["Namespace"].(string),

PR which fixed it:

https://github.com/doitintl/kube-no-trouble/pull/95/files

Could you try again with the latest nightly and lets us know if the issue still occurs

@ghost ghost self-assigned this May 19, 2021
@stepanstipl stepanstipl added the bug Something isn't working label May 25, 2021
@joshclark
Copy link

I'm getting the same error using nightly-0.4.0-83-g055df4e

❌ . (none) kube-no-trouble ➤ ./kubent
5:28PM INF >>> Kube No Trouble `kubent` <<<
5:28PM INF version nightly-0.4.0-83-g055df4e (git sha 055df4e213a394ad107021724714c5130759b284)
5:28PM INF Initializing collectors and retrieving data
5:28PM INF Target K8s version is 1.15+
5:28PM WRN Failed to retrieve: networking.k8s.io/v1, Resource=ingressclasses: the server could not find the requested resource
5:28PM WRN Failed to retrieve: storage.k8s.io/v1, Resource=csidrivers: the server could not find the requested resource
5:28PM WRN Failed to retrieve: storage.k8s.io/v1, Resource=csinodes: the server could not find the requested resource
5:28PM WRN Failed to retrieve: authorization.k8s.io/v1, Resource=subjectaccessreviews: the server does not allow this method on the requested resource
5:28PM WRN Failed to retrieve: authorization.k8s.io/v1, Resource=selfsubjectaccessreviews: the server does not allow this method on the requested resource
5:28PM WRN Failed to retrieve: authorization.k8s.io/v1, Resource=localsubjectaccessreviews: the server could not find the requested resource
5:28PM WRN Failed to retrieve: authentication.k8s.io/v1, Resource=tokenreviews: the server does not allow this method on the requested resource
5:28PM WRN Failed to retrieve: certificates.k8s.io/v1, Resource=certificatesigningrequests: the server could not find the requested resource
5:28PM WRN Failed to retrieve: apiextensions.k8s.io/v1, Resource=customresourcedefinitions: the server could not find the requested resource
5:28PM WRN Failed to retrieve: admissionregistration.k8s.io/v1, Resource=mutatingwebhookconfigurations: the server could not find the requested resource
5:28PM WRN Failed to retrieve: admissionregistration.k8s.io/v1, Resource=validatingwebhookconfigurations: the server could not find the requested resource
5:28PM WRN Failed to retrieve: node.k8s.io/v1, Resource=runtimeclasses: the server could not find the requested resource
5:28PM WRN Failed to retrieve: policy/v1, Resource=poddisruptionbudgets: the server could not find the requested resource
5:28PM WRN Failed to retrieve: discovery.k8s.io/v1, Resource=endpointslices: the server could not find the requested resource
5:28PM WRN Failed to retrieve: batch/v1, Resource=cronjobs: the server could not find the requested resource
5:28PM INF Retrieved 58 resources from collector name=Cluster
5:28PM INF Retrieved 939 resources from collector name="Helm v2"
5:28PM INF Retrieved 24 resources from collector name="Helm v2"
5:28PM INF Loaded ruleset name=custom.rego.tmpl
5:28PM INF Loaded ruleset name=deprecated-1-16.rego
5:28PM INF Loaded ruleset name=deprecated-1-22.rego
5:28PM INF Loaded ruleset name=deprecated-1-25.rego
panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
github.com/doitintl/kube-no-trouble/pkg/judge.(*RegoJudge).Eval(0xc00063cc40, 0xc0011e0000, 0x3fd, 0x400, 0xc00063cc40, 0x0, 0x0, 0x0, 0xc0001c3350)
        /__w/kube-no-trouble/kube-no-trouble/pkg/judge/rego.go:55 +0x94d
main.main()
        /__w/kube-no-trouble/kube-no-trouble/cmd/kubent/main.go:135 +0x636

@stepanstipl
Copy link
Contributor

Hi @joshclark, @swaroop1012,
I'm looking into this issue and can't replicate it. I would really like to fix it though, so if you could help. I have added additional logging, and it's in the latest nightly release. If you could download the relevant binary and run it with trace log level:

$ kubent -l trace

You should get a log line starting with TRC parsing right before the panic, such as:

...
12:00PM TRC parsing +map[ApiVersion:storage.k8s.io/v1beta1 Kind:StorageClass Name:slow Namespace:default ReplaceWith:storage.k8s.io/v1 RuleSet:Deprecated APIs removed in 1.22 Since:1.6]

I would really be interested to see that, and the relevant manifest from your cluster... i.e. in the example above it would be StorageClass named slow.

This should allow me to debug this further.. thanks 🙏

@joshclark
Copy link

4:42PM TRC parsing +map[ApiVersion:extensions/v1beta1 Kind:DaemonSet Name:cattle-node-agent Namespace:cattle-system ReplaceWith:apps/v1 RuleSet:Deprecated APIs removed in 1.16 Since:1.9]
4:42PM TRC parsing +map[ApiVersion:extensions/v1beta1 Kind:Deployment Name:cattle-cluster-agent Namespace:cattle-system ReplaceWith:apps/v1 RuleSet:Deprecated APIs removed in 1.16 Since:1.9]
4:42PM TRC parsing +map[ApiVersion:apps/v1beta2 Kind:StatefulSet Name:azure-agent Namespace:azure-agent ReplaceWith:apps/v1 RuleSet:Deprecated APIs removed in 1.16 Since:1.9]
4:42PM TRC parsing +map[ApiVersion:extensions/v1beta1 Kind:DaemonSet Name:collection-fluent-bit Namespace:sumologic ReplaceWith:apps/v1 RuleSet:Deprecated APIs removed in 1.16 Since:1.9]
4:42PM TRC parsing +map[ApiVersion:extensions/v1beta1 Kind:DaemonSet Name:collection-falco Namespace:sumologic ReplaceWith:apps/v1 RuleSet:Deprecated APIs removed in 1.16 Since:1.9]
4:42PM TRC parsing +map[ApiVersion:apps/v1beta1 Kind:StatefulSet Name:rcm-journal-reporting-hardclose-service Namespace:<nil> ReplaceWith:apps/v1 RuleSet:Deprecated APIs removed in 1.16 Since:1.9]
panic: interface conversion: interface {} is nil, not string

stepanstipl added a commit that referenced this issue Jul 28, 2021
Add tests for extracted helm functions, and mainly for nil namespace
that should cover #124
@stepanstipl
Copy link
Contributor

Thanks @joshclark, I believe I've found the issue. I have merged a fix (#198) and triggered a nightly build - can you test that one in your environment, to verify the issue is fixed?

@joshclark
Copy link

success! It works. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants