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, just let it block on teardown.  We can "fix" it later, if/when it
is important.


On Wed, Aug 6, 2014 at 12:00 AM, 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{}) {
>
> How, in this case, would we have a single function call perform a
> synchronous move (to ensure the namespace is no longer occupied) followed
> by an asynchronous teardown so that the kubelet doesn't block on longer
> teardowns? It seems difficult to preserve this behavior without either
> separating it into two procedures and letting the caller decide what is run
> asynchronously, or just incorporating the goroutine within the function
> itself.
>
> --
> Reply to this email directly or view it on GitHub
> <https://github.com/GoogleCloudPlatform/kubernetes/pull/688/files#r15858640>
> .
>