mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Avoid panics during executor shutdown due to write to closed channel
This commit is contained in:
parent
9366ac4143
commit
6af86cbaad
@ -107,7 +107,7 @@ type KubernetesExecutor struct {
|
|||||||
state stateType
|
state stateType
|
||||||
tasks map[string]*kuberTask
|
tasks map[string]*kuberTask
|
||||||
pods map[string]*api.Pod
|
pods map[string]*api.Pod
|
||||||
lock sync.RWMutex
|
lock sync.Mutex
|
||||||
sourcename string
|
sourcename string
|
||||||
client *client.Client
|
client *client.Client
|
||||||
done chan struct{} // signals shutdown
|
done chan struct{} // signals shutdown
|
||||||
@ -269,6 +269,11 @@ func (k *KubernetesExecutor) onInitialRegistration() {
|
|||||||
defer close(k.initialRegComplete)
|
defer close(k.initialRegComplete)
|
||||||
|
|
||||||
// emit an empty update to allow the mesos "source" to be marked as seen
|
// emit an empty update to allow the mesos "source" to be marked as seen
|
||||||
|
k.lock.Lock()
|
||||||
|
defer k.lock.Unlock()
|
||||||
|
if k.isDone() {
|
||||||
|
return
|
||||||
|
}
|
||||||
k.updateChan <- kubetypes.PodUpdate{
|
k.updateChan <- kubetypes.PodUpdate{
|
||||||
Pods: []*api.Pod{},
|
Pods: []*api.Pod{},
|
||||||
Op: kubetypes.SET,
|
Op: kubetypes.SET,
|
||||||
@ -397,6 +402,9 @@ func (k *KubernetesExecutor) handleChangedApiserverPod(pod *api.Pod) {
|
|||||||
oldPod.DeletionTimestamp = pod.DeletionTimestamp
|
oldPod.DeletionTimestamp = pod.DeletionTimestamp
|
||||||
oldPod.DeletionGracePeriodSeconds = pod.DeletionGracePeriodSeconds
|
oldPod.DeletionGracePeriodSeconds = pod.DeletionGracePeriodSeconds
|
||||||
|
|
||||||
|
if k.isDone() {
|
||||||
|
return
|
||||||
|
}
|
||||||
update := kubetypes.PodUpdate{
|
update := kubetypes.PodUpdate{
|
||||||
Op: kubetypes.UPDATE,
|
Op: kubetypes.UPDATE,
|
||||||
Pods: []*api.Pod{oldPod},
|
Pods: []*api.Pod{oldPod},
|
||||||
@ -570,6 +578,9 @@ func (k *KubernetesExecutor) launchTask(driver bindings.ExecutorDriver, taskId s
|
|||||||
k.pods[podFullName] = pod
|
k.pods[podFullName] = pod
|
||||||
|
|
||||||
// send the new pod to the kubelet which will spin it up
|
// send the new pod to the kubelet which will spin it up
|
||||||
|
if k.isDone() {
|
||||||
|
return
|
||||||
|
}
|
||||||
update := kubetypes.PodUpdate{
|
update := kubetypes.PodUpdate{
|
||||||
Op: kubetypes.ADD,
|
Op: kubetypes.ADD,
|
||||||
Pods: []*api.Pod{pod},
|
Pods: []*api.Pod{pod},
|
||||||
@ -775,6 +786,9 @@ func (k *KubernetesExecutor) removePodTask(driver bindings.ExecutorDriver, tid,
|
|||||||
delete(k.pods, pid)
|
delete(k.pods, pid)
|
||||||
|
|
||||||
// tell the kubelet to remove the pod
|
// tell the kubelet to remove the pod
|
||||||
|
if k.isDone() {
|
||||||
|
return
|
||||||
|
}
|
||||||
update := kubetypes.PodUpdate{
|
update := kubetypes.PodUpdate{
|
||||||
Op: kubetypes.REMOVE,
|
Op: kubetypes.REMOVE,
|
||||||
Pods: []*api.Pod{pod},
|
Pods: []*api.Pod{pod},
|
||||||
|
Loading…
Reference in New Issue
Block a user