Skip to content

Commit

Permalink
close client and metrics listeners firstly when shutting down etcd
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Jan 19, 2025
1 parent c9e85fd commit 86ce681
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions server/embed/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,16 @@ func (e *Etcd) Close() {
close(e.stopc)
})

for i := range e.Clients {
if e.Clients[i] != nil {
e.Clients[i].Close()
}
}

for i := range e.metricsListeners {
e.metricsListeners[i].Close()

Check warning on line 421 in server/embed/etcd.go

View check run for this annotation

Codecov / codecov/patch

server/embed/etcd.go#L421

Added line #L421 was not covered by tests
}

// close client requests with request timeout
timeout := 2 * time.Second
if e.Server != nil {
Expand All @@ -428,16 +438,6 @@ func (e *Etcd) Close() {
sctx.cancel()
}

for i := range e.Clients {
if e.Clients[i] != nil {
e.Clients[i].Close()
}
}

for i := range e.metricsListeners {
e.metricsListeners[i].Close()
}

// shutdown tracing exporter
if e.tracingExporterShutdown != nil {
e.tracingExporterShutdown()
Expand Down

0 comments on commit 86ce681

Please sign in to comment.