~go-bot/juju-core/trunk

« back to all changes in this revision

Viewing changes to environs/open.go

[r=axwalk],[bug=1247152] cmd/juju: delete .jenv if bootstrap fails

If bootstrap fails, and the .jenv file did
not previously exist, then Juju will attempt
to destroy the environment in case of partial
creation. If this succeeds, the .jenv file
is destroyed. If it fails, an error message
is logged; we do not currently attempt to
forcefully remove the environment.

NOTE: if an environment is already prepared, say
by running sync-tools, then a failed bootstrap
will not attempt to destroy the environment.

Fixes lp:1247152

https://codereview.appspot.com/59560043/

Show diffs side-by-side

added added

removed removed

Lines of Context:
237
237
        if err := env.Destroy(); err != nil {
238
238
                return err
239
239
        }
240
 
        info, err := store.ReadInfo(name)
 
240
        return DestroyInfo(name, store)
 
241
}
 
242
 
 
243
// DestroyInfo destroys the configuration data for the named
 
244
// environment from the given store.
 
245
func DestroyInfo(envName string, store configstore.Storage) error {
 
246
        info, err := store.ReadInfo(envName)
241
247
        if err != nil {
242
248
                if errors.IsNotFoundError(err) {
243
249
                        return nil