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.
I am still learning how concurrency in go works.  I defer to those more
seasoned in it.  Daniel's suggestion is easier to implement and test.  We
can make the caller concurrent if/when we need to.
On Aug 5, 2014 7:21 PM, "Danny Jones" <notifications@github.com> wrote:

> In pkg/volume/volume.go:
>
> >  func (emptyDir *EmptyDirectory) GetPath() string {
> >  	return path.Join(emptyDir.RootDir, emptyDir.PodID, "volumes", "empty", emptyDir.Name)
> >  }
> >
> > +func (emptyDir *EmptyDirectory) renameDirectory() (string, error) {
> > +	oldPath := emptyDir.GetPath()
> > +	newPath, err := ioutil.TempDir(path.Dir(oldPath), emptyDir.Name+".deleting~")
> > +	if err != nil {
> > +		return "", err
> > +	}
> > +	err = os.Rename(oldPath, newPath)
> > +	if err != nil {
> > +		return "", err
> > +	}
> > +	return newPath, nil
> > +}
> > +
> > +// Simply delete everything in the directory.
> > +func (emptyDir *EmptyDirectory) TearDown() (error, chan struct{}) {
>
> I previously had the function as synchronous, and had a separate Prepare()
> function that performed the quick work to remove the volume from the
> namespace, then had the the rest of TearDown() called in a goroutine. The
> channel was implemented per @thockin <https://github.com/thockin>'s
> suggestions of having TearDown() itself determine what is asynchronous and
> use the channel only for testing.
>
> --
> Reply to this email directly or view it on GitHub
> <https://github.com/GoogleCloudPlatform/kubernetes/pull/688/files#r15853323>
> .
>