Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use DatastoreFileManager to delete files #4043

Merged
merged 2 commits into from
Feb 27, 2017
Merged

Conversation

dougm
Copy link
Member

@dougm dougm commented Feb 26, 2017

Use DatastoreFileManager to delete files

DatastoreFileManager is a new govmomi helper that combines
FileManager, VirtualDiskManager and Datastore types for managing
files on a datastore.

For now the focus is on deleting files, and in particular, not leaking
DOM objects on vSAN.

Fixes #3931

@dougm
Copy link
Member Author

dougm commented Feb 26, 2017

@mdubya66 we need your review to merge #4024

I'll also be updating vendor/govmomi again with this PR once vmware/govmomi#672 is merged.

@@ -86,7 +86,7 @@ func (vm *VirtualMachine) FolderName(ctx context.Context) (string, error) {
func (vm *VirtualMachine) DSPath(ctx context.Context) (url.URL, error) {
var mvm mo.VirtualMachine

if err := vm.Properties(ctx, vm.Reference(), []string{"runtime.host", "config"}, &mvm); err != nil {
if err := vm.Properties(ctx, vm.Reference(), []string{"config.files.vmPathName"}, &mvm); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is not a required change for this PR, but in the process notice we can reduce the data collected quite a bit here.

if _, err := tasks.WaitForResult(d.ctx, func(ctx context.Context) (tasks.Task, error) {
return m.DeleteDatastoreFile(ctx, dsPath, d.session.Datacenter)
}); err != nil {
if err := m.Delete(d.ctx, dsPath); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the retry on certain failures on needed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We retry TaskInProgress faults elsewhere, but that isn't thrown by DeleteVirtualDisk_Task or DeleteDatastoreFile_Task: http://pubs.vmware.com/vsphere-65/index.jsp#com.vmware.wssdk.apiref.doc/vim.fault.TaskInProgress.html

I don't see any faults we should be retrying for those methods and the caller(s) of this code already handle the FileNotFound case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we handling NotAuthenticated issues from session timeout or similar? If there's any aspect style remediation performed in the tasks package beyond handling InProgress retrys then we should be using it across the board. Otherwise not.

@cgtexmex something else for vmomi gateway

return tasks.Wait(context.TODO(), func(ctx context.Context) (tasks.Task, error) {
return d.fm.DeleteDatastoreFile(ctx, f, d.s.Datacenter)
})
return d.ds.NewFileManager(d.s.Datacenter, true).Delete(ctx, f) // TODO: NewHelper should create the DatastoreFileManager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this TODO supposed to be done in other PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another PR, since this would be a cleanup/refactor that would simplify unrelated existing code, but not required to solve this issue.

if _, err := tasks.WaitForResult(d.ctx, func(ctx context.Context) (tasks.Task, error) {
return m.DeleteDatastoreFile(ctx, dsPath, d.session.Datacenter)
}); err != nil {
if err := m.Delete(d.ctx, dsPath); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we handling NotAuthenticated issues from session timeout or similar? If there's any aspect style remediation performed in the tasks package beyond handling InProgress retrys then we should be using it across the board. Otherwise not.

@cgtexmex something else for vmomi gateway

DatastoreFileManager is a new govmomi helper that combines
FileManager, VirtualDiskManager and Datastore types for managing
files on a datastore.

For now the focus is on deleting files, and in particular, not leaking
DOM objects on vSAN.

Fixes vmware#3931
@dougm dougm merged commit 5217a6a into vmware:master Feb 27, 2017
@dougm dougm deleted the issue-3931 branch February 27, 2017 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants