Merge pull request #114071 from Mskxn/master

Fix a potential goroutine leak
This commit is contained in:
Kubernetes Prow Robot 2022-12-10 06:04:17 -08:00 committed by GitHub
commit 89f6cb39d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,10 +66,10 @@ func (r *EtcdMigrateServer) Start(version *EtcdVersion) error {
}
interval := time.NewTicker(time.Millisecond * 500)
defer interval.Stop()
done := make(chan bool, 1)
done := make(chan bool)
go func() {
time.Sleep(time.Minute * 2)
done <- true
close(done)
}()
for {
select {
@ -108,7 +108,7 @@ func (r *EtcdMigrateServer) Stop() error {
timedout := make(chan bool)
go func() {
time.Sleep(gracefulWait)
timedout <- true
close(timedout)
}()
go func() {
select {
@ -121,7 +121,7 @@ func (r *EtcdMigrateServer) Stop() error {
}
}()
err = r.cmd.Wait()
stopped <- true
close(stopped)
if exiterr, ok := err.(*exec.ExitError); ok {
klog.Infof("etcd server stopped (signal: %s)", exiterr.Error())
// stopped