Skip to content

Commit

Permalink
Fix cleanup leak in pipeline collectors
Browse files Browse the repository at this point in the history
Signed-off-by: Zhang Wei <[email protected]>
  • Loading branch information
zwpaper committed Dec 18, 2023
1 parent 512b16e commit e6cf58e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/dcgmexporter/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,25 @@ func NewMetricsPipeline(c *Config) (*MetricsPipeline, func(), error) {
return nil, func() {}, err
}

cleanups := []func(){}
gpuCollector, cleanup, err := NewDCGMCollector(counters, c, dcgm.FE_GPU)
if err != nil {
return nil, func() {}, err
}
cleanups = append(cleanups, cleanup)

switchCollector, cleanup, err := NewDCGMCollector(counters, c, dcgm.FE_SWITCH)
if err != nil {
logrus.Info("Not collecting switch metrics: ", err)
} else {
cleanups = append(cleanups, cleanup)
}

linkCollector, cleanup, err := NewDCGMCollector(counters, c, dcgm.FE_LINK)
if err != nil {
logrus.Info("Not collecting link metrics: ", err)
} else {
cleanups = append(cleanups, cleanup)
}

transformations := []Transform{}
Expand All @@ -71,7 +77,9 @@ func NewMetricsPipeline(c *Config) (*MetricsPipeline, func(), error) {
linkCollector: linkCollector,
transformations: transformations,
}, func() {
cleanup()
for _, cleanup := range cleanups {
cleanup()
}
}, nil
}

Expand Down

0 comments on commit e6cf58e

Please sign in to comment.