Skip to content

Commit

Permalink
fix(#67): avoid panic when reading maps (#68)
Browse files Browse the repository at this point in the history
* fix(#67): avoid panic when reading maps

* docs: update changelog
  • Loading branch information
neufeldtech authored Jul 30, 2021
1 parent 4e34e4d commit b276d19
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ Example Format Below:
- Fix Markdown links to tag comparison URL with footnote-style links.
-->
## [Unreleased]

### Fixed
- avoid panic when reading maps #68
## [0.6.1] - 2021-05-25
### Added
- Call the SF API concurrently for scrape speed improvement #62
Expand Down
17 changes: 12 additions & 5 deletions pkg/prom/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ func (c *SolidfireCollector) collectVolumeStats(ctx context.Context, ch chan<- p
if err != nil {
return err
}
mu.Lock()
defer mu.Unlock()
for _, vol := range volumeStats.Result.VolumeStats {
ch <- prometheus.MustNewConstMetric(
MetricDescriptions.VolumeActualIOPS,
Expand Down Expand Up @@ -551,7 +553,8 @@ func (c *SolidfireCollector) collectClusterFaults(ctx context.Context, ch chan<-
if err != nil {
return err
}

mu.Lock()
defer mu.Unlock()
for _, f := range ClusterActiveFaults.Result.Faults {
ch <- prometheus.MustNewConstMetric(
MetricDescriptions.ClusterActiveFaults,
Expand All @@ -576,7 +579,8 @@ func (c *SolidfireCollector) collectClusterNodeStats(ctx context.Context, ch cha
if err != nil {
return err
}

mu.Lock()
defer mu.Unlock()
for _, stats := range ClusterNodeStats.Result.NodeStats.Nodes {
SsLoadHistogram := map[float64]uint64{
0: stats.SsLoadHistogram.Bucket0,
Expand Down Expand Up @@ -739,7 +743,8 @@ func (c *SolidfireCollector) collectVolumeQosHistograms(ctx context.Context, ch
if err != nil {
return err
}

mu.Lock()
defer mu.Unlock()
for _, h := range VolumeQoSHistograms.Result.QosHistograms {
// Below Min IOPS Percentage
BelowMinIopsPercentages := map[float64]uint64{
Expand Down Expand Up @@ -1178,7 +1183,8 @@ func (c *SolidfireCollector) collectDriveDetails(ctx context.Context, ch chan<-
if err != nil {
return err
}

mu.Lock()
defer mu.Unlock()
for _, d := range ListDrives.Result.Drives {
for _, ds := range possibleDriveStatuses {
var driveStatusValue float64 = 0
Expand Down Expand Up @@ -1218,7 +1224,8 @@ func (c *SolidfireCollector) collectISCSISessions(ctx context.Context, ch chan<-
if err != nil {
return err
}

mu.Lock()
defer mu.Unlock()
sessions := make(map[int]map[int]float64)

for _, session := range ListISCSISessions.Result.Sessions {
Expand Down

0 comments on commit b276d19

Please sign in to comment.