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

discovery interval data race #33

Closed
rlankfo opened this issue Jul 28, 2022 · 0 comments · Fixed by #34
Closed

discovery interval data race #33

rlankfo opened this issue Jul 28, 2022 · 0 comments · Fixed by #34

Comments

@rlankfo
Copy link
Member

rlankfo commented Jul 28, 2022

A race is detected when setting the object discovery interval to a non-zero value.

go test -v -race ./...
?       github.com/grafana/vmware_exporter      [no test files]
=== RUN   TestExporter
2022/07/28 11:06:54 http: TLS handshake error from 127.0.0.1:50863: EOF
==================
WARNING: DATA RACE
Write at 0x00c0001e5c48 by goroutine 62:
  github.com/grafana/vmware_exporter/vsphere.(*endpoint).discover()
      /Users/robertlankford/code/grafana/vmware_exporter/vsphere/endpoint.go:256 +0x16f7
  github.com/grafana/vmware_exporter/vsphere.(*endpoint).startDiscovery.func1()
      /Users/robertlankford/code/grafana/vmware_exporter/vsphere/endpoint.go:171 +0x164

Previous read at 0x00c0001e5c48 by goroutine 73:
  github.com/grafana/vmware_exporter/vsphere.(*vsphereCollector).collectResource()
      /Users/robertlankford/code/grafana/vmware_exporter/vsphere/collector.go:80 +0x4e6
  github.com/grafana/vmware_exporter/vsphere.(*vsphereCollector).Collect.func1()
      /Users/robertlankford/code/grafana/vmware_exporter/vsphere/collector.go:56 +0x15b
  github.com/grafana/vmware_exporter/vsphere.(*vsphereCollector).Collect·dwrap·2()
      /Users/robertlankford/code/grafana/vmware_exporter/vsphere/collector.go:57 +0x66

Goroutine 62 (running) created at:
  github.com/grafana/vmware_exporter/vsphere.(*endpoint).startDiscovery()
      /Users/robertlankford/code/grafana/vmware_exporter/vsphere/endpoint.go:167 +0x15b
  github.com/grafana/vmware_exporter/vsphere.(*endpoint).initialDiscovery()
      /Users/robertlankford/code/grafana/vmware_exporter/vsphere/endpoint.go:162 +0x43a
  github.com/grafana/vmware_exporter/vsphere.(*endpoint).init()
      /Users/robertlankford/code/grafana/vmware_exporter/vsphere/endpoint.go:151 +0xc8
  github.com/grafana/vmware_exporter/vsphere.newVSphereCollector()
      /Users/robertlankford/code/grafana/vmware_exporter/vsphere/collector.go:232 +0x4f
  github.com/grafana/vmware_exporter/vsphere.NewExporter()
      /Users/robertlankford/code/grafana/vmware_exporter/vsphere/exporter.go:50 +0x5c6
  github.com/grafana/vmware_exporter/vsphere.TestExporter()
      /Users/robertlankford/code/grafana/vmware_exporter/vsphere/exporter_test.go:49 +0x352
  testing.tRunner()
      /Users/robertlankford/.gvm/gos/go1.17.7/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /Users/robertlankford/.gvm/gos/go1.17.7/src/testing/testing.go:1306 +0x47

Goroutine 73 (running) created at:
  github.com/grafana/vmware_exporter/vsphere.(*vsphereCollector).Collect()
      /Users/robertlankford/code/grafana/vmware_exporter/vsphere/collector.go:54 +0x1253
  github.com/prometheus/client_golang/prometheus.(*Registry).Gather.func1()
      /Users/robertlankford/code/grafana/vmware_exporter/vendor/github.com/prometheus/client_golang/prometheus/registry.go:448 +0x14d
==================
    exporter_test.go:81: Expected metrics to contain 'vsphere_VirtualMachine_disk_maxTotalLatency_latest'
    testing.go:1152: race detected during execution of test
--- FAIL: TestExporter (3.68s)
=== CONT
    testing.go:1152: race detected during execution of test
FAIL
FAIL    github.com/grafana/vmware_exporter/vsphere      4.004s
FAIL
make: *** [Makefile:23: test] Error 1
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

Successfully merging a pull request may close this issue.

1 participant