Skip to content

Commit

Permalink
Make sure Aerospike client is closed if the probe is stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
geobeau committed Jun 22, 2022
1 parent c92f288 commit 3899067
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/aerospike/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,8 @@ func (e *AerospikeEndpoint) Refresh() error {
}

func (e *AerospikeEndpoint) Close() error {
if e != nil {
e.Client.Close()
}
return nil
}
3 changes: 2 additions & 1 deletion pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func (pw *ProberWorker) runAllPendingChecks(lastChecks []time.Time) time.Duratio

func (pw *ProberWorker) StartProbing() {
level.Info(pw.logger).Log("msg", "starting probing")
defer pw.endpoint.Close() // Make sure the client is closed if the probe is stopped

if len(pw.checks) < 1 {
level.Error(pw.logger).Log("msg", "Probe not started no checks registered")
Expand Down Expand Up @@ -240,7 +241,7 @@ func (pw *ProberWorker) StartProbing() {
}
return
case <-refreshTicker.C:
level.Debug(pw.logger).Log("msg", "Probe endpoint refreshed")
level.Debug(pw.logger).Log("msg", "Refreshing probe endpoint")
err := pw.endpoint.Refresh()
if err != nil {
level.Error(pw.logger).Log("msg", "Error while refreshing", "err", err)
Expand Down

0 comments on commit 3899067

Please sign in to comment.