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 on couch down #3

Open
lelvisl opened this issue Mar 15, 2018 · 0 comments
Open

panic on couch down #3

lelvisl opened this issue Mar 15, 2018 · 0 comments

Comments

@lelvisl
Copy link
Contributor

lelvisl commented Mar 15, 2018

Example:

func getClusterStats(couch *cbmgr.Couchbase) {
	clstInf, err := couch.ClusterInfo()
	if err != nil {
		log.Printf("getClusterStats error:%s", err.Error())
	}
	if clstInf.Balanced {
		ClusterStats.WithLabelValues("balanced").Set(0)
	} else {
		ClusterStats.WithLabelValues("balanced").Set(1)
	}

if node down, we have panic on clstInf.Balanced (nil pointer dereference)

2018/03/15 19:52:21 [Get http://localhost:8091/pools/default/buckets/: dial tcp 127.0.0.1:8091: connect: connection refused]
2018/03/15 19:52:21 getClusterStats error:[Get http://localhost:8091/pools/default: dial tcp 127.0.0.1:8091: connect: connection refused]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x6b8e7d]

goroutine 9 [running]:
main.getClusterStats(0xc420096240)
        /Users/elvis/prog/go/src/github.com/lelvisl/couchbase_exporter/couchbase_stats.go:47 +0x5d
main.main.func1(0xc420096240)
        /Users/elvis/prog/go/src/github.com/lelvisl/couchbase_exporter/couchbase_exporter.go:56 +0x39
created by main.main
        /Users/elvis/prog/go/src/github.com/lelvisl/couchbase_exporter/couchbase_exporter.go:53 +0x227
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

1 participant