mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-25 11:31:44 +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
|
package kuberuntime
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
v1 "k8s.io/api/core/v1"
|
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
|
// prereqs is a map from container name to a list of channel that the container
|
||||||
// must wait on to ensure termination ordering
|
// must wait on to ensure termination ordering
|
||||||
prereqs map[string][]chan struct{}
|
prereqs map[string][]chan struct{}
|
||||||
|
|
||||||
|
lock sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// newTerminationOrdering constructs a terminationOrdering based on the pod spec and the currently running containers.
|
// 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()
|
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) {
|
func (o *terminationOrdering) containerTerminated(name string) {
|
||||||
|
o.lock.Lock()
|
||||||
|
defer o.lock.Unlock()
|
||||||
if ch, ok := o.terminated[name]; ok {
|
if ch, ok := o.terminated[name]; ok {
|
||||||
close(ch)
|
close(ch)
|
||||||
|
delete(o.terminated, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user