local provider destroy-environment sometimes fails with a weird error

Tim Penhey tim.penhey at canonical.com
Sun Apr 13 23:52:56 UTC 2014


Hi folks,

I noticed this at the end of last week, but shelved the thoughts until
this weed as other things were taking priority.

$ juju destroy-environment local -y
[sudo] password for tim:
ERROR readdirent: no such file or directory
ERROR failed to destroy environment "local"

If the environment is unusable, then you may run

    juju destroy-environment --force

to forcefully destroy the environment. Upon doing so, review
your environment provider console for any resources that need
to be cleaned up.

ERROR exit status 1


The first error there had me really confused:
ERROR readdirent: no such file or directory


After hacking the source locally to add a bucket load of debug
statements, I found that it is actually the last part of the local
provider Destroy method that is failing:

	logger.Debugf("remove root dir: %v", env.config.rootDir())
	// Finally, remove the data-dir.
	if err := os.RemoveAll(env.config.rootDir()); err != nil &&
!os.IsNotExist(err) {
		logger.Debugf("remove root dir failed: %v", err)
		return err
	}

The logging statements there is mine.  Running the command I get:

2014-04-13 23:45:21 DEBUG juju.provider.local environ.go:461 remove root
dir: /home/tim/.juju/local
2014-04-13 23:45:21 DEBUG juju.provider.local environ.go:469 remove root
dir failed: readdirent: no such file or directory

but immediately after, I looked in the datadir:

$ find /home/tim/.juju/local/
find: `/home/tim/.juju/local/': No such file or directory

So it looks like os.RemoveAll returned an error, and for what I'm not
sure, but it did actually work.

My first thought is to just ignore any error and hope that root is good
enough to remove it, however that just feels icky.

Suggestions anyone?

Tim



More information about the Juju-dev mailing list