Volume reconciliation loop

Implements a reconciliation loop that tears down volumes that are no longer in use by any pod.

The set of valid volumes are determined by iterating through the list of manifests. The set of active, or mounted, volumes are determined by traversing the root working directory path for any existing volumes. These maps are compared, and if an active volume does not have a match, it is unmounted and removed.

This allows a kubelet to properly remove mounted volumes and clean up after itself in the event of a crash/restart.
For now it's fine.  We'll need to do better long term


On Thu, Jul 31, 2014 at 3:46 PM, Danny Jones <notifications@github.com>
wrote:

> In pkg/kubelet/kubelet.go:
>
> > +		return nil
> > +	})
> > +	return activeVolumes
> > +}
> > +
> > +// Compares the map of active volumes to the map of valid volumes.
> > +// If an active volume does not have a respective valid volume, clean it up.
> > +func (kl *Kubelet) reconcileVolumes(pods []Pod) error {
> > +	validVolumes := determineValidVolumes(pods)
> > +	activeVolumes := kl.determineActiveVolumes()
> > +	glog.Infof("ValidVolumes: %v", validVolumes)
> > +	glog.Infof("ActiveVolumes: %v", activeVolumes)
> > +	for name, volume := range activeVolumes {
> > +		if _, ok := validVolumes[name]; !ok {
> > +			glog.Infof("Orphaned volume %s found, tearing down volume", name)
> > +			err := volume.TearDown()
>
> @thockin <https://github.com/thockin> is there anything that a TearDown()
> needs to/should specifically block on or vice versa? Or can each volume's
> TearDown procedure can run completely asynchronously after removing the
> volume from the namespace?
>
> --
> Reply to this email directly or view it on GitHub
> <https://github.com/GoogleCloudPlatform/kubernetes/pull/688/files#r15674533>
> .
>