VM folder not deleted after destroying VM

Hello,

In last months, I have noticed that in my OpenNebula system, when user deletes a VM, its folder remains in the operative system.
My scenario is this: one server that acts as server (here named “server”) and as KVM node and a second server that only acts as KVM node (here named “node”). Datastores 1 and 2 are shared through NFS, but datastore 0 is local to each system. TM_MAD is qcow2 (and, then, SHARED=yes).
.
When user creates a VM in the second KVM node, when he/she decides to delete that VM, OpenNebula updates its database and VM dissappear from Sunstone and from CLI, but folder /var/lib/one/datastores/o/$VM_ID remains in the system.

As a example, these files belongs to a VM with this problem. These files are located at /var/lib/one/vms/$VM_ID:

[oneadmin@server 13012]$ ls -lhart
total 244K
-rw-r--r--    1 oneadmin oneadmin  143 Apr 27 16:43 transfer.0.prolog
-rw-r--r--    1 oneadmin oneadmin 2.0K Apr 27 16:43 deployment.0
-rw-r--r--    1 oneadmin oneadmin  683 Apr 27 16:43 context.sh
-rw-r--r--    1 oneadmin oneadmin  226 Apr 27 16:43 transfer.0.stop
-rw-r--r--    1 oneadmin oneadmin  137 Apr 27 16:43 transfer.0.epilog
drwx------    2 oneadmin oneadmin  141 Apr 27 16:43 .
drwxr-x--- 5987 oneadmin oneadmin 120K Apr 27 16:44 ..

Content of each file is this:
transfer.0.prolog:

CLONE qcow2 server:/var/lib/one//datastores/1/9c6a4f3f27b1d4cd89e81f3d65edb69b node:/var/lib/one//datastores/0/13012/disk.0 13012 1

deployment.0:

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
        <name>one-13012</name>
        <title>Client</title>
        <uuid>545f4f7d-5e9b-43ea-bca6-7b0f18955934</uuid>
        <vcpu><![CDATA[2]]></vcpu>
        <cputune>
                <shares>768</shares>
        </cputune>
        <memory>3393536</memory>
        <currentMemory>3393536</currentMemory>
        <os>
                <type arch='x86_64'>hvm</type>
        </os>
        <cpu mode='host-passthrough'>
        </cpu>
        <devices>
                <emulator><![CDATA[/usr/bin/qemu-kvm-one]]></emulator>
                <disk type='file' device='disk'>
                        <source file='/var/lib/one//datastores/0/13012/disk.0'/>
                        <target dev='vda' bus='virtio'/>
                        <boot order='1'/>
                        <driver name='qemu' type='qcow2' cache='none' discard='unmap'/>
                </disk>
                <disk type='file' device='cdrom'>
                        <source file='/var/lib/one//datastores/0/13012/disk.1'/>
                        <target dev='hda' bus='ide'/>
                        <readonly/>
                        <driver name='qemu' type='raw'/>
                </disk>
                <interface type='bridge'>
                        <source bridge='br1'/>
                        <mac address='02:00:0a:0a:0a:50'/>
                        <target dev='one-13012-0'/>
                        <model type='virtio'/>
                </interface>
                <graphics type='vnc' listen='0.0.0.0' port='18912' keymap='es'/>
        </devices>
        <features>
                <acpi/>
        </features>
        <devices>
                <channel type='unix'>
                        <source mode='bind'/><target type='virtio' name='org.qemu.guest_agent.0'/>
                </channel>
        </devices>
        <devices>
                <controller type='scsi' index='0' model='virtio-scsi'>
                        <driver queues='1'/>
                </controller>
        </devices>
        <metadata>
                <one:vm xmlns:one="http://opennebula.org/xmlns/libvirt/1.0">
                        <one:system_datastore><![CDATA[/var/lib/one//datastores/0/13012]]></one:system_datastore>
                        <one:name><![CDATA[Client]]></one:name>
                        <one:uname><![CDATA[prjci-1]]></one:uname>
                        <one:uid>1577</one:uid>
                        <one:gname><![CDATA[Prj-GCI]]></one:gname>
                        <one:gid>140</one:gid>
                        <one:opennebula_version>6.4.0</one:opennebula_version>
                        <one:stime>1682606580</one:stime>
                        <one:deployment_time>1682606590</one:deployment_time>
                </one:vm>
        </metadata>
</domain>

context.sh:

# Context variables generated by OpenNebula
DISK_ID='1'
ETH0_DNS='8.8.8.8'
ETH0_EXTERNAL=''
ETH0_GATEWAY='10.10.10.1'
ETH0_GATEWAY6=''
ETH0_IP='10.10.10.80'
ETH0_IP6=''
ETH0_IP6_GATEWAY=''
ETH0_IP6_METHOD='disable'
ETH0_IP6_METRIC=''
ETH0_IP6_PREFIX_LENGTH=''
ETH0_IP6_ULA=''
ETH0_MAC='02:00:0a:0a:0a:50'
ETH0_MASK='255.255.252.0'
ETH0_METHOD=''
ETH0_METRIC=''
ETH0_MTU=''
ETH0_NETWORK='10.10.10.0'
ETH0_SEARCH_DOMAIN=''
ETH0_VLAN_ID=''
ETH0_VROUTER_IP=''
ETH0_VROUTER_IP6=''
ETH0_VROUTER_MANAGEMENT=''
NETWORK='YES'
PASSWORD='MyPassword'
SSH_PUBLIC_KEY=''
START_SCRIPT_BASE64='L2Jpbi9lY2hvICJhZG1pbnA6TmVidWxhQ2FvcyIgfCBjaHBhc3N3ZA=='
TARGET='hda'

transfer.0.stop:

MV qcow2 node:/var/lib/one//datastores/0/13012/disk.0 server:/var/lib/one//datastores/0/13012/disk.0 13012 1
MV qcow2 node:/var/lib/one//datastores/0/13012 server:/var/lib/one//datastores/0/13012 13012 0

transfer.0.epilog:

DELETE qcow2 server:/var/lib/one//datastores/0/13012/disk.0 13012 1
DELETE qcow2 server:/var/lib/one//datastores/0/13012 13012 0

All seems in the right way but when user deletes VM, its folder remains at “node”. However, if you run “onevm list”, that VM doesn’t appear.

Where is the problem?

Thanks.