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: assignment to entry in nil map #178

Closed
Evalle opened this issue Jul 11, 2018 · 3 comments
Closed

panic: assignment to entry in nil map #178

Evalle opened this issue Jul 11, 2018 · 3 comments

Comments

@Evalle
Copy link

Evalle commented Jul 11, 2018

Hi folks!

I use guard v0.2.0 and I try to integrate it with our LDAP server (I did everything according to the official guide), however when I try to obtain a token I've got the error:

$ guard get token -o ldap --ldap.auth-choice 0 --ldap.username=evgeny.shmarnev --ldap.password=foobar -v=3 --analytics=false
I0711 10:31:22.971536    9002 logs.go:19] FLAG: --alsologtostderr="false"
I0711 10:31:22.973452    9002 logs.go:19] FLAG: --analytics="false"
I0711 10:31:22.973482    9002 logs.go:19] FLAG: --help="false"
I0711 10:31:22.973499    9002 logs.go:19] FLAG: --ldap.auth-choice="0"
I0711 10:31:22.973513    9002 logs.go:19] FLAG: --ldap.disable-pa-fx-fast="true"
I0711 10:31:22.973527    9002 logs.go:19] FLAG: --ldap.krb5-config="/etc/krb5.conf"
I0711 10:31:22.973538    9002 logs.go:19] FLAG: --ldap.password="foobar"
I0711 10:31:22.973549    9002 logs.go:19] FLAG: --ldap.realm=""
I0711 10:31:22.973559    9002 logs.go:19] FLAG: --ldap.spn=""
I0711 10:31:22.973570    9002 logs.go:19] FLAG: --ldap.username="evgeny.shmarnev"
I0711 10:31:22.973586    9002 logs.go:19] FLAG: --log_backtrace_at=":0"
I0711 10:31:22.973599    9002 logs.go:19] FLAG: --log_dir=""
I0711 10:31:22.973612    9002 logs.go:19] FLAG: --logtostderr="false"
I0711 10:31:22.973623    9002 logs.go:19] FLAG: --organization="ldap"
I0711 10:31:22.973636    9002 logs.go:19] FLAG: --stderrthreshold="0"
I0711 10:31:22.973647    9002 logs.go:19] FLAG: --v="3"
I0711 10:31:22.973660    9002 logs.go:19] FLAG: --vmodule=""
panic: assignment to entry in nil map

goroutine 1 [running]:
github.com/appscode/guard/util/kubeconfig.AddAuthInfo(0x7fffaea93203, 0xf, 0xc42063c000, 0x6e61443530333237, 0x6c6969)
	/home/tamal/go/src/github.com/appscode/guard/util/kubeconfig/utils.go:41 +0x10b
github.com/appscode/guard/auth/providers/ldap.(*TokenOptions).addAuthInfo(0xc4203170b0, 0xc420043bf0, 0x24, 0xc4203e4dc0, 0xc4205ec630)
	/home/tamal/go/src/github.com/appscode/guard/auth/providers/ldap/kubectl.go:148 +0x75
github.com/appscode/guard/auth/providers/ldap.(*TokenOptions).IssueToken(0xc4203170b0, 0x4, 0x7fffaea931d9)
	/home/tamal/go/src/github.com/appscode/guard/auth/providers/ldap/kubectl.go:76 +0x94
github.com/appscode/guard/commands.NewCmdGetToken.func1(0xc4205f2780, 0xc4200de700, 0x0, 0x8)
	/home/tamal/go/src/github.com/appscode/guard/commands/token.go:51 +0x152
github.com/appscode/guard/vendor/github.com/spf13/cobra.(*Command).execute(0xc4205f2780, 0xc4200de400, 0x8, 0x8, 0xc4205f2780, 0xc4200de400)
	/home/tamal/go/src/github.com/appscode/guard/vendor/github.com/spf13/cobra/command.go:766 +0x2c1
github.com/appscode/guard/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc4201b7400, 0xc4205f2f00, 0xc4205f2c80, 0xc4205a0570)
	/home/tamal/go/src/github.com/appscode/guard/vendor/github.com/spf13/cobra/command.go:852 +0x30a
github.com/appscode/guard/vendor/github.com/spf13/cobra.(*Command).Execute(0xc4201b7400, 0x1841c00, 0xc42004c118)
	/home/tamal/go/src/github.com/appscode/guard/vendor/github.com/spf13/cobra/command.go:800 +0x2b
main.main()
	/home/tamal/go/src/github.com/appscode/guard/main.go:14 +0x48

My setup:

  • kubernetes v1.9.7 (deployed via kubeadm)
  • guard v0.2.0 - deployed inside of kubernetes cluster
$ kubectl get po -n kube-system | grep guard
guard-5f678c4ddd-xh9jk                                          1/1       Running   0          57m

If you need any additional info, feel free to ask me.

@nightfury1204
Copy link
Contributor

@Evalle do you have $HOME/.kube/config file. If not, then probably that's why this panic occurred.
can you please check that?

@Evalle
Copy link
Author

Evalle commented Jul 11, 2018

@nightfury1204 exactly, there was no such file:

$ ls $HOME/.kube/config
ls: cannot access /root/.kube/config: No such file or directory

$ touch $HOME/.kube/config

$ guard get token -o ldap --ldap.auth-choice 0 --ldap.username=evgeny.shmarnev --ldap.password=foobar -v=3 --analytics=false
I0711 12:29:56.360547    6028 logs.go:19] FLAG: --alsologtostderr="false"
I0711 12:29:56.362566    6028 logs.go:19] FLAG: --analytics="false"
I0711 12:29:56.362625    6028 logs.go:19] FLAG: --help="false"
I0711 12:29:56.362671    6028 logs.go:19] FLAG: --ldap.auth-choice="0"
I0711 12:29:56.362714    6028 logs.go:19] FLAG: --ldap.disable-pa-fx-fast="true"
I0711 12:29:56.362757    6028 logs.go:19] FLAG: --ldap.krb5-config="/etc/krb5.conf"
I0711 12:29:56.362814    6028 logs.go:19] FLAG: --ldap.password="foobar"
I0711 12:29:56.362865    6028 logs.go:19] FLAG: --ldap.realm=""
I0711 12:29:56.362916    6028 logs.go:19] FLAG: --ldap.spn=""
I0711 12:29:56.362980    6028 logs.go:19] FLAG: --ldap.username="evgeny.shmarnev"
I0711 12:29:56.363026    6028 logs.go:19] FLAG: --log_backtrace_at=":0"
I0711 12:29:56.363083    6028 logs.go:19] FLAG: --log_dir=""
I0711 12:29:56.363123    6028 logs.go:19] FLAG: --logtostderr="false"
I0711 12:29:56.363176    6028 logs.go:19] FLAG: --organization="ldap"
I0711 12:29:56.363215    6028 logs.go:19] FLAG: --stderrthreshold="0"
I0711 12:29:56.363253    6028 logs.go:19] FLAG: --v="3"
I0711 12:29:56.363291    6028 logs.go:19] FLAG: --vmodule=""
Current Kubeconfig is backed up as /root/.kube/config.bak.2018-07-11T12-29.
Configuration has been written to /root/.kube/config

Thanks!

It can be a good idea to add the check of a config file in the $HOME directory.

@whites11
Copy link

By the way, the same problem arises if there is no .kube directory in user's home

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

3 participants