Skip to content

Commit 3c7cf37

Browse files
committed
delete channel from the terminated after closing it
1 parent e5b64bd commit 3c7cf37

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pkg/kubelet/kuberuntime/kuberuntime_termination_order.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package kuberuntime
1818

1919
import (
20+
"sync"
2021
"time"
2122

2223
v1 "k8s.io/api/core/v1"
@@ -34,6 +35,8 @@ type terminationOrdering struct {
3435
// prereqs is a map from container name to a list of channel that the container
3536
// must wait on to ensure termination ordering
3637
prereqs map[string][]chan struct{}
38+
39+
lock sync.Mutex
3740
}
3841

3942
// newTerminationOrdering constructs a terminationOrdering based on the pod spec and the currently running containers.
@@ -106,9 +109,12 @@ func (o *terminationOrdering) waitForTurn(name string, gracePeriod int64) float6
106109
return time.Since(start).Seconds()
107110
}
108111

109-
// containerTerminated should be called once the container with the speecified name has exited.
112+
// containerTerminated should be called once the container with the specified name has exited.
110113
func (o *terminationOrdering) containerTerminated(name string) {
114+
o.lock.Lock()
115+
defer o.lock.Unlock()
111116
if ch, ok := o.terminated[name]; ok {
112117
close(ch)
118+
delete(o.terminated, name)
113119
}
114120
}

0 commit comments

Comments
 (0)