Skip to content

Commit 29d491e

Browse files
Fix goroutine leak at silence bulk import (#4556)
* Fix goroutine leak --------- Signed-off-by: moonyoung <[email protected]>
1 parent 4ea517b commit 29d491e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cli/silence_import.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ func (c *silenceImportCmd) bulkImport(ctx context.Context, _ *kingpin.ParseConte
9898

9999
amclient := NewAlertmanagerClient(alertmanagerURL)
100100
silencec := make(chan *models.PostableSilence, 100)
101+
defer close(silencec)
102+
101103
errc := make(chan error, 100)
104+
defer close(errc)
105+
102106
var wg sync.WaitGroup
103107
for w := 0; w < c.workers; w++ {
104108
wg.Add(1)
@@ -134,9 +138,7 @@ func (c *silenceImportCmd) bulkImport(ctx context.Context, _ *kingpin.ParseConte
134138
count++
135139
}
136140

137-
close(silencec)
138141
wg.Wait()
139-
close(errc)
140142

141143
if errCount > 0 {
142144
return fmt.Errorf("couldn't import %v out of %v silences", errCount, count)

0 commit comments

Comments
 (0)