mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-24 19:12:02 +00:00
delete channel from the terminated after closing it
This commit is contained in:
parent
e5b64bdef7
commit
3c7cf370d0
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package kuberuntime
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
@ -34,6 +35,8 @@ type terminationOrdering struct {
|
||||
// prereqs is a map from container name to a list of channel that the container
|
||||
// must wait on to ensure termination ordering
|
||||
prereqs map[string][]chan struct{}
|
||||
|
||||
lock sync.Mutex
|
||||
}
|
||||
|
||||
// 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
|
||||
return time.Since(start).Seconds()
|
||||
}
|
||||
|
||||
// containerTerminated should be called once the container with the speecified name has exited.
|
||||
// containerTerminated should be called once the container with the specified name has exited.
|
||||
func (o *terminationOrdering) containerTerminated(name string) {
|
||||
o.lock.Lock()
|
||||
defer o.lock.Unlock()
|
||||
if ch, ok := o.terminated[name]; ok {
|
||||
close(ch)
|
||||
delete(o.terminated, name)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user