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.
To be clear, I don't want two calls.  I'd rather one sync call, and let the
caller 'go' it.


On Tue, Aug 5, 2014 at 11:05 PM, Daniel Smith <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{}) {
>
> Yeah, sorry to make you put it back. If you have a two phase process I
> think you should model that by having two function calls. Returning a
> channel like this seems great at first but (as Tim observes) it's hard to
> test and it removes all flexibility from the caller-- for example, this
> makes it very difficult to use a sync.WaitGroup.
>
> --
> Reply to this email directly or view it on GitHub
> <https://github.com/GoogleCloudPlatform/kubernetes/pull/688/files#r15857333>
> .
>