Delete vmdk first before delete directory for vc 6.5 or newer#2652
Delete vmdk first before delete directory for vc 6.5 or newer#2652emlin merged 6 commits intovmware:masterfrom
Conversation
|
|
||
| m := object.NewFileManager(ds.Client()) | ||
| if d.isVSAN(ds) { | ||
| if d.geVC65() || d.isVSAN(ds) { |
There was a problem hiding this comment.
Can we do this (call deleteFiles...) all the time? Do we need to only do it for 65 or vsan?
There was a problem hiding this comment.
Actually, this will make the delete slower, especially while there are many images downloaded.
|
|
||
| m := object.NewFileManager(ds.Client()) | ||
| if d.isVSAN(ds) { | ||
| if d.geVC65() || d.isVSAN(ds) { |
There was a problem hiding this comment.
- Why is the caller responsible for knowing the exact model by which you have to delete files?
- Why even bother with separate paths (this is purely an optimization)
Can we have d.deleteFiles(m, ds, dsPath) - if we really have to have the optimization, the check should be inside that function.
There was a problem hiding this comment.
Here, the top level method to delete should be method
func (d *Dispatcher) deleteDatastoreFiles(ds *object.Datastore, path string, force bool) (bool, error)
So caller doesn't need to care about the internal impl, I think.
The last comment is same to @fdawg4l mentioned above. But I think delete interactively is not an optimization. It will slow down the delete.
But if vsphere is going this way, and we don't care too much about 6.0, it's also fine to remove this branch.
There was a problem hiding this comment.
I don't care too much about moving to a consolidated branch, but having this logic here instead of in the pkg/vsphere/datastore code means that every single caller who wants to delete a tree has to do this same version detection or know the specifics of how to do a recursive deletion.
There was a problem hiding this comment.
the pkg/vsphere/datastore is meant to be a common pkg could be used by both vic-machine and storage portlayer, but there is some assumption not exists in vic-machine.
I could refactor code to merge them two, but probably not at this time.
| func (d *Dispatcher) geVC65() bool { | ||
| vcVersion := d.session.Client.ServiceContent.About.Version | ||
| // vsphere only has versions 5.5.x, 6.0.x, 6.5.x, not likely to have 6.10.x, so compare string directly here | ||
| return strings.Compare(vcVersion, "6.5.0") >= 0 |
There was a problem hiding this comment.
I think https://golang.org/pkg/strings/#HasPrefix could be more suitable here
There was a problem hiding this comment.
so you mean anything without "6.0." prefix? In case, vsphere does not provide any patch like 6.1.x.
anyway, not likely...
There was a problem hiding this comment.
The only reason for this method is to select a difference in a specific behaviour. If this is being broken out into a separate method then it should be something like deleteRequiresEmptyDirectory() that actually describes the use. Otherwise we'll end up with geVC70 as well once 6.5 is released and we start testing against vmkernel main.
There was a problem hiding this comment.
Not quite sure about this point.
Current method name just shows the function itself, and the caller decides how to use it. That is same to the definition of isVSAN() method.
For the method in the future of geVC70, that must be other function difference between VC 6.5 and VC 7.0.
We could limit such kind of difference, and I don't prefer to have this detection, just if without this branch, there will have side effect, and that's not necessary for VC 6.0 as I said above.
So if we agree for this impact, I can remove the detection, and keep them consistent in VMFS file system and vSAN, for both VC versions.
|
|
||
| m := object.NewFileManager(ds.Client()) | ||
| if d.isVSAN(ds) { | ||
| if d.geVC65() || d.isVSAN(ds) { |
There was a problem hiding this comment.
I don't care too much about moving to a consolidated branch, but having this logic here instead of in the pkg/vsphere/datastore code means that every single caller who wants to delete a tree has to do this same version detection or know the specifics of how to do a recursive deletion.
| func (d *Dispatcher) geVC65() bool { | ||
| vcVersion := d.session.Client.ServiceContent.About.Version | ||
| // vsphere only has versions 5.5.x, 6.0.x, 6.5.x, not likely to have 6.10.x, so compare string directly here | ||
| return strings.Compare(vcVersion, "6.5.0") >= 0 |
There was a problem hiding this comment.
The only reason for this method is to select a difference in a specific behaviour. If this is being broken out into a separate method then it should be something like deleteRequiresEmptyDirectory() that actually describes the use. Otherwise we'll end up with geVC70 as well once 6.5 is released and we start testing against vmkernel main.
|
What is the error with 6.5? And vSAN? "Folder deletes are always recursive" http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.wssdk.apiref.doc/vim.FileManager.html#deleteFile |
|
@dougm Well the problem in vSAN and 6.5 is slightly different. vSAN: to delete a folder, the folder must be empty. 6.5: delete folder works well, if there is no linked disk chain. For the recursive delete, thanks for the reference. I didn't know that. |
Do not differentiate vc6.0 and 6.5, vmfs and vsan datastore to reduce difference based on env.
|
LGTM |
|
lgtm |
1 similar comment
|
lgtm |
|
♻️ |
Fixes #2014
In VC 6.5, if we delete datastore file directories, with linked vmdk files inside, delete will fail, even we don't have any delta vmdks rely on them.
Delete from UI does not work as well.
The only workaround for this issue, is to delete in vSAN model, delete vmdk files first, and then file directory.