Delete datastore files iteratively for all datastore types#7441
Delete datastore files iteratively for all datastore types#7441AngieCris merged 12 commits intovmware:masterfrom
Conversation
…mware#6951)" This reverts commit 1fd1e7f.
|
#2652 is the PR to delete all kind of datastore files recursively, for vc6.5 requires that. |
| } | ||
| d.op.Debugf("Folder %q is not found", dsPath) | ||
| return nil | ||
| // Get sorted result to make sure children files listed ahead of folder. Then we can empty folder before delete it |
| } | ||
| d.op.Debugf("Folder %q is not found", dsPath) | ||
| return nil | ||
| // Get sorted result to make sure children files listed ahead of folder. Then we can empty folder before delete it |
| d.op.Debugf("Folder %q is not found", dsPath) | ||
| return nil | ||
| // Get sorted result to make sure children files listed ahead of folder. Then we can empty folder before delete it | ||
| // This function specifically designed for vSan, as vSan sometimes will throw error to delete folder is the folder is not empty |
There was a problem hiding this comment.
Can we remove this comment if it's not relevant anymore?
anchal-agrawal
left a comment
There was a problem hiding this comment.
LGTM. Do we need to update any tests in 6-03-Delete to account for the changes here?
hickeng
left a comment
There was a problem hiding this comment.
Seems I'm reluctant to continue with the epically long delete times for large numbers of images...
| @@ -158,26 +158,23 @@ func (d *Dispatcher) isVSAN(ds *object.Datastore) bool { | |||
| func (d *Dispatcher) deleteFilesIteratively(m *object.DatastoreFileManager, ds *object.Datastore, dsPath string) error { | |||
| defer trace.End(trace.Begin(dsPath, d.op)) | |||
|
|
|||
There was a problem hiding this comment.
sorry for the whiplash Angie - given this isn't a direct revert if addressing anchal's comments, could we add a recursive delete attempt as the first thing, then fail over into the current path.
So adding the following at the top:
// don't check errors given detail process of any remaining files will occur after
d.deleteVMFSFiles(m, ds, dsPath)There was a problem hiding this comment.
that's alright. unnecessary recursive delete doesn't sound very neat tbh....
it seems like ESX and older versions of VC don't have the issue but vSAN and new VC version do have that, in most cases it has to go thru iterative delete
if we add d.deleteVMFSFiles(m, ds, dsPath) at the top, then it would probably print failure log messages complaining not being able to delete non-empty datastore folders. Since we ignore the error coming out of this, and recursively clean stuff up later, if the folder did get cleaned up in the end, looking at the log it would still feel like that there's a failure deleting the folder.
sorry about the messy description, but just wondering will it confuse users?
There was a problem hiding this comment.
The log looks like this from a test run I did:
INFO[0003] Removing image stores
DEBU[0004] Failed to delete "[datastore1] vch-test-4/VIC": Cannot delete file [datastore1] vch-test-4/VIC
DEBU[0013] Folder "[datastore1] vch-test-4/kvStores" is not found
DEBU[0013] Image store parent directory not empty, leaving in place.
......
DEBU[0016] Folder "[datastore1] vch-test-4" is not found
INFO[0016] Removing Resource Pool "vch-test-4"
The later Folder "[datastore1] vch-test-4" is not found is from vm.Unregsiter, it shows that the folder is already been deleted
but still we see Failed to delete "[datastore1] vch-test-4/VIC": Cannot delete file [datastore1] vch-test-4/VIC on the top, even tho it's actually deleted successfully right after
(also we're sort of not supposed to see Folder "[datastore1] vch-test-4" is not found from unregister at all, but it shows up because the line we added returns NotFound error)
There was a problem hiding this comment.
I'm okay with them showing up as debug messages - we could add an additional debug message saying "Attempting recursive delete" then if that's not clean a message saying "Cleaning up recusive deletion failures via iterative delete" or similar.
We may want to return a different error type rather than re-use NotFound if it's causing misleading output.
There was a problem hiding this comment.
Got it. Here's the log output with the most recent change:
DEBU[0007] No disks found attached to VM
INFO[0007] Removing image stores
DEBU[0009] Failed to delete "[datastore1] vch-2/VIC": Cannot delete file [datastore1] vch-2/VIC
DEBU[0009] Attempt to delete top level folder "[datastore1] vch-2/VIC" failed. Remove the children files instead.
DEBU[0027] Image store parent directory not empty, leaving in place.
INFO[0027] Removing volume stores
Does this look okay? I added a log saying Attempt to delete top level folder failed. Remove the children files instead
|
@anchal-agrawal The reason why all group 6 tests didn't fail on CI before was that old CI ran on ESX, and deleting a non-empty datastore folder with child image files works on ESX. But the operation won't go thru on newer version of VC. |
Codecov Report
@@ Coverage Diff @@
## master #7441 +/- ##
=========================================
- Coverage 31.58% 31.5% -0.08%
=========================================
Files 278 278
Lines 42169 42172 +3
=========================================
- Hits 13318 13286 -32
- Misses 27685 27719 +34
- Partials 1166 1167 +1
Continue to review full report at Codecov.
|
[specific ci=Group6-VIC-Machine]Fixes #7359
Revert of commit 1fd1e7f PR #6951
For non-vSAN type datastores, sometimes it complains when we try to delete non-empty datastore folders with child image files, causing trailing VCH datastore folders after vic-machine delete finishes.
So the new approach is, we attempt to delete a datastore folder first. If it fails, we delete children files one by one, and then finally empty the folder.