Skip to content

Commit

Permalink
Remove code to delete cached VMDKs from all datastores
Browse files Browse the repository at this point in the history
We no longer cache them in the datastore, instead they're used to
create a template VM that new VMs are cloned from.

This deletion is causing problems because if the user doesn't have
access to the datastore it fails and blocks controller teardown.
  • Loading branch information
babbageclunk committed Apr 14, 2020
1 parent 081ade7 commit 331b69d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
17 changes: 0 additions & 17 deletions provider/vsphere/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package vsphere

import (
"fmt"
"path"
"sync"

Expand Down Expand Up @@ -230,22 +229,6 @@ func (env *sessionEnviron) DestroyController(ctx callcontext.ProviderCallContext
HandleCredentialError(err, env, ctx)
return errors.Annotate(err, "destroying VM folder")
}

// Remove VMDK cache(s). The user can specify the datastore, and can
// change it over time; or if not specified, any accessible datastore
// will be used. We must check them all.
datastores, err := env.accessibleDatastores(ctx)
if err != nil {
return errors.Annotate(err, "listing datastores")
}
for _, ds := range datastores {
datastorePath := fmt.Sprintf("[%s] %s", ds.Name, path.Join(env.getVMFolder(), templateDirectoryName(controllerUUID)))
logger.Debugf("deleting: %s", datastorePath)
if err := env.client.DeleteDatastoreFile(env.ctx, datastorePath); err != nil {
HandleCredentialError(err, env, ctx)
return errors.Annotatef(err, "deleting VMDK cache from datastore %q", ds.Name)
}
}
return nil
}

Expand Down
11 changes: 0 additions & 11 deletions provider/vsphere/environ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func (s *environSuite) TestDestroyController(c *gc.C) {
s.dialStub.CheckCallNames(c, "Dial")
s.client.CheckCallNames(c,
"DestroyVMFolder", "RemoveVirtualMachines", "DestroyVMFolder",
"Datastores", "DeleteDatastoreFile", "DeleteDatastoreFile",
"Close",
)

Expand All @@ -121,16 +120,6 @@ func (s *environSuite) TestDestroyController(c *gc.C) {
c.Assert(destroyControllerVMFolderCall.Args, gc.HasLen, 2)
c.Assert(destroyControllerVMFolderCall.Args[0], gc.Implements, new(context.Context))
c.Assert(destroyControllerVMFolderCall.Args[1], gc.Equals, `Juju Controller (foo)`)

deleteDatastoreFileCall1 := s.client.Calls()[4]
c.Assert(deleteDatastoreFileCall1.Args, gc.HasLen, 2)
c.Assert(deleteDatastoreFileCall1.Args[0], gc.Implements, new(context.Context))
c.Assert(deleteDatastoreFileCall1.Args[1], gc.Equals, "[bar] foo/templates")

deleteDatastoreFileCall2 := s.client.Calls()[5]
c.Assert(deleteDatastoreFileCall2.Args, gc.HasLen, 2)
c.Assert(deleteDatastoreFileCall2.Args[0], gc.Implements, new(context.Context))
c.Assert(deleteDatastoreFileCall2.Args[1], gc.Equals, "[baz] foo/templates")
}

func (s *environSuite) TestAdoptResources(c *gc.C) {
Expand Down

0 comments on commit 331b69d

Please sign in to comment.