Commit 24df692b authored by Victor Marmol's avatar Victor Marmol

Merge pull request #6872 from yujuhong/fix_lock

Fix locking issue in pod manager
parents 1ea2c3ba 967405f0
...@@ -249,22 +249,25 @@ func (self *basicPodManager) TranslatePodUID(uid types.UID) types.UID { ...@@ -249,22 +249,25 @@ func (self *basicPodManager) TranslatePodUID(uid types.UID) types.UID {
return uid return uid
} }
func (self *basicPodManager) getFullNameMaps() (map[string]*api.Pod, map[string]*api.Pod) { func (self *basicPodManager) getOrphanedMirrorPodNames() []string {
self.lock.RLock() self.lock.RLock()
defer self.lock.RUnlock() defer self.lock.RUnlock()
return self.podByFullName, self.mirrorPodByFullName var podFullNames []string
for podFullName := range self.mirrorPodByFullName {
if _, ok := self.podByFullName[podFullName]; !ok {
podFullNames = append(podFullNames, podFullName)
}
}
return podFullNames
} }
// Delete all mirror pods which do not have associated static pods. This method // Delete all mirror pods which do not have associated static pods. This method
// sends deletion requets to the API server, but does NOT modify the internal // sends deletion requets to the API server, but does NOT modify the internal
// pod storage in basicPodManager. // pod storage in basicPodManager.
func (self *basicPodManager) DeleteOrphanedMirrorPods() { func (self *basicPodManager) DeleteOrphanedMirrorPods() {
podByFullName, mirrorPodByFullName := self.getFullNameMaps() podFullNames := self.getOrphanedMirrorPodNames()
for _, podFullName := range podFullNames {
for podFullName := range mirrorPodByFullName { self.mirrorClient.DeleteMirrorPod(podFullName)
if _, ok := podByFullName[podFullName]; !ok {
self.mirrorClient.DeleteMirrorPod(podFullName)
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment