mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #24545 from swagiaal/rename-cleaner-tuple
Automatic merge from submit-queue Rename cleanerTuple to cleaner Rename cleanerTuple to cleaner. This is a follow up to address: https://github.com/kubernetes/kubernetes/pull/19503#discussion_r49538769 @saad-ali
This commit is contained in:
commit
7e430f543b
@ -1983,7 +1983,7 @@ func (kl *Kubelet) cleanupOrphanedVolumes(pods []*api.Pod, runningPods []*kubeco
|
|||||||
runningSet.Insert(string(pod.ID))
|
runningSet.Insert(string(pod.ID))
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, cleanerTuple := range currentVolumes {
|
for name, cleaner := range currentVolumes {
|
||||||
if _, ok := desiredVolumes[name]; !ok {
|
if _, ok := desiredVolumes[name]; !ok {
|
||||||
parts := strings.Split(name, "/")
|
parts := strings.Split(name, "/")
|
||||||
if runningSet.Has(parts[0]) {
|
if runningSet.Has(parts[0]) {
|
||||||
@ -1996,19 +1996,19 @@ func (kl *Kubelet) cleanupOrphanedVolumes(pods []*api.Pod, runningPods []*kubeco
|
|||||||
// TODO(yifan): Refactor this hacky string manipulation.
|
// TODO(yifan): Refactor this hacky string manipulation.
|
||||||
kl.volumeManager.DeleteVolumes(types.UID(parts[0]))
|
kl.volumeManager.DeleteVolumes(types.UID(parts[0]))
|
||||||
// Get path reference count
|
// Get path reference count
|
||||||
refs, err := mount.GetMountRefs(kl.mounter, cleanerTuple.Unmounter.GetPath())
|
refs, err := mount.GetMountRefs(kl.mounter, cleaner.Unmounter.GetPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Could not get mount path references %v", err)
|
return fmt.Errorf("Could not get mount path references %v", err)
|
||||||
}
|
}
|
||||||
//TODO (jonesdl) This should not block other kubelet synchronization procedures
|
//TODO (jonesdl) This should not block other kubelet synchronization procedures
|
||||||
err = cleanerTuple.Unmounter.TearDown()
|
err = cleaner.Unmounter.TearDown()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Could not tear down volume %q: %v", name, err)
|
glog.Errorf("Could not tear down volume %q: %v", name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// volume is unmounted. some volumes also require detachment from the node.
|
// volume is unmounted. some volumes also require detachment from the node.
|
||||||
if cleanerTuple.Detacher != nil && len(refs) == 1 {
|
if cleaner.Detacher != nil && len(refs) == 1 {
|
||||||
detacher := *cleanerTuple.Detacher
|
detacher := *cleaner.Detacher
|
||||||
err = detacher.Detach()
|
err = detacher.Detach()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Could not detach volume %q: %v", name, err)
|
glog.Errorf("Could not detach volume %q: %v", name, err)
|
||||||
|
@ -207,9 +207,9 @@ func (kl *Kubelet) getPodVolumes(podUID types.UID) ([]*volumeTuple, error) {
|
|||||||
return volumes, nil
|
return volumes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// cleanerTuple is a union struct to allow separating detaching from the cleaner.
|
// cleaner is a union struct to allow separating detaching from the cleaner.
|
||||||
// some volumes require detachment but not all. Unmounter cannot be nil but Detacher is optional.
|
// some volumes require detachment but not all. Unmounter cannot be nil but Detacher is optional.
|
||||||
type cleanerTuple struct {
|
type cleaner struct {
|
||||||
Unmounter volume.Unmounter
|
Unmounter volume.Unmounter
|
||||||
Detacher *volume.Detacher
|
Detacher *volume.Detacher
|
||||||
}
|
}
|
||||||
@ -217,12 +217,12 @@ type cleanerTuple struct {
|
|||||||
// getPodVolumesFromDisk examines directory structure to determine volumes that
|
// getPodVolumesFromDisk examines directory structure to determine volumes that
|
||||||
// are presently active and mounted. Returns a union struct containing a volume.Unmounter
|
// are presently active and mounted. Returns a union struct containing a volume.Unmounter
|
||||||
// and potentially a volume.Detacher.
|
// and potentially a volume.Detacher.
|
||||||
func (kl *Kubelet) getPodVolumesFromDisk() map[string]cleanerTuple {
|
func (kl *Kubelet) getPodVolumesFromDisk() map[string]cleaner {
|
||||||
currentVolumes := make(map[string]cleanerTuple)
|
currentVolumes := make(map[string]cleaner)
|
||||||
podUIDs, err := kl.listPodsFromDisk()
|
podUIDs, err := kl.listPodsFromDisk()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("Could not get pods from disk: %v", err)
|
glog.Errorf("Could not get pods from disk: %v", err)
|
||||||
return map[string]cleanerTuple{}
|
return map[string]cleaner{}
|
||||||
}
|
}
|
||||||
// Find the volumes for each on-disk pod.
|
// Find the volumes for each on-disk pod.
|
||||||
for _, podUID := range podUIDs {
|
for _, podUID := range podUIDs {
|
||||||
@ -245,7 +245,7 @@ func (kl *Kubelet) getPodVolumesFromDisk() map[string]cleanerTuple {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
tuple := cleanerTuple{Unmounter: unmounter}
|
tuple := cleaner{Unmounter: unmounter}
|
||||||
detacher, err := kl.newVolumeDetacherFromPlugins(volume.Kind, volume.Name, podUID)
|
detacher, err := kl.newVolumeDetacherFromPlugins(volume.Kind, volume.Name, podUID)
|
||||||
// plugin can be nil but a non-nil error is a legitimate error
|
// plugin can be nil but a non-nil error is a legitimate error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user