fix hanging manual snapshot task
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-01-15 17:49:42 +11:00
parent 1b91c73a18
commit 75a5f31a2f
6 changed files with 130 additions and 39 deletions

View File

@@ -663,7 +663,8 @@ func (v *Vcenter) GetVMFolderPath(vm mo.VirtualMachine) (string, error) {
folderPath := ""
//v.Logger.Debug("parent is", "parent", parentRef)
for parentRef != nil && parentRef.Type != "Datacenter" {
maxHops := 128
for parentRef != nil && parentRef.Type != "Datacenter" && maxHops > 0 {
// Retrieve the parent object
//parentObj, err := finder.ObjectReference(v.ctx, *parentRef)
//if err != nil {
@@ -691,9 +692,10 @@ func (v *Vcenter) GetVMFolderPath(vm mo.VirtualMachine) (string, error) {
return "", fmt.Errorf("unexpected parent type: %s", parentObj.Reference().Type)
}
//break
maxHops--
}
if parentRef == nil {
if parentRef == nil || maxHops == 0 {
return "", fmt.Errorf("folder traversal terminated early for VM %s", vm.Name)
}