Closed mightyspiky closed 2 years ago
I cannot recreate the issue following these steps. The only difference is that I made the VM manually.
I cannot recreate the issue following these steps. The only difference is that I made the VM manually.
Hmm.. I initially thought the problem occurs also with automatically inventoried KVM virtual machines but I've just verified and it occurs only with my LXC containers. When I click on a container name in the virtualization section, the loaded page doesn't include the memory amount I see on the overview so when I edit any field and save, empty value is overwriting the old value. It might be good to note that with my LXC containers, the amount of memory is suffixed with "M" for megabytes (ex: 2048M) and it's not the case with my KVM virtual machines (ex: 2048). Could it be related to the problem you think?
The UI for VMs should only accept numeric values but I do see that the database stores the data as a string. This may explain how the value gets removed after saving the form, but the suffixed value "2048M" should not have shown like that at all in the form. It may have shown in other places like search results and the list on the VMs tab though.
The native inventory feature seems to remove some suffixes like B, KB, and MB and ensures the value is converted into the number of MB (without the suffix). I don't see it handling suffixed like "M" though.
The UI for VMs should only accept numeric values but I do see that the database stores the data as a string. This may explain how the value gets removed after saving the form, but the suffixed value "2048M" should not have shown like that at all in the form. It may have shown in other places like search results and the list on the VMs tab though.
The native inventory feature seems to remove some suffixes like B, KB, and MB and ensures the value is converted into the number of MB (without the suffix). I don't see it handling suffixed like "M" though.
My LXC containers first got inventoried with Fusion-Inventory agent but I moved to glpi-agent when I upgraded to GLPI 10. Shouldn't the new native agent modify the value to remove the "M" ? If not, can I safely manually remove the "M" and presume the memory amount will still get updated automatically in GLPI (without adding the "M") if I change the memory amount of my LXC containers in LXC configuration?
By the way, I re-read your last post and the value for the memory field gets removed after loading the form, not after saving it. The value with "M" is only shown in the overview of the virtualization section.
I don't know if there are locks for VM fields that would prevent the inventory from updating it once it is manually changed. However, if it does get updated by the inventory agent, it would still get the bad value unless the agent is changed to send just memory size in MB without the suffix or with an expected suffix, or the server side is updated to handle more possible suffixes.
The official format for the inventory file states the VM memory value should be "Memory size in MB" and an integer type so no suffixes should be used.
So, if the bug is in GLPI agent and not GLPI server, am I at the right place? Is there a Github page specific to GLPI agent?
I'll let someone who knows the agent/inventory part better but from what I saw, the LXC inventory in GLPI Agent should get the memory size in bytes but I don't see it being transformed to MB or having a suffix added.
Can you provide the version of the FusionInventory agent and plugin that it was initially inventoried with, and the current GLPI agent version?
On the server side, I guess supporting shortened suffixes would be OK as long as it is safe to assume they stand for Megabyte (1000 1000 bytes) for example and not Mebibyte (1024 1024 bytes).
I really can't remember the initial FusionInventory agent version I've used, sorry, but it's from many years ago. As for GLPI agent, I have the rpm version installed and it's 1.2-1 . As for my problem, I think I might have a clue: In my LXC configuration for a specific container, I have this:
lxc.cgroup.memory.limit_in_bytes = 2048M
The parameter specifies in its name that I should write the value in bytes but I have always used the "M" suffix with success (it works without problem in LXC). Maybe if I write the value in bytes in my LXC conf, I would have no more problem in GLPI interface after the next automatic inventory..? I still think though that GLPI should handle this correctly since the "M" suffix is a valid way to specify memory amount in LXC.
I saw the config name and it didn't occur to me that it was a user-defined value (I don't know LXC either). In that case, it seems like something that needs handled on the agent side.
Please provide a JSON file (if you use glpi-agent) we can use to reproduce the issue. Inventory schema is quite strict, and does not transform any incorrect values (only values coming from old XML format may be fixed right now). Maybe it is possible to retrieve only VMs information, @g-bougard ?
Yes, the output of the following command should help to reproduce the case:
glpi-inventory --partial=virtualmachine
[root@oldy ~]# glpi-inventory --partial=virtualmachine
[info] New inventory from oldy.local-2022-06-01-10-24-55 for local0
{
"action": "inventory",
"content": {
"bios": {
"bdate": "2018-05-24",
"bmanufacturer": "Dell Inc.",
"bversion": "2.10.0",
"mmanufacturer": "Dell Inc.",
"mmodel": "Z",
"msn": "Y",
"smanufacturer": "Dell Inc.",
"smodel": "PowerEdge T110 II",
"ssn": "X"
},
"hardware": {
"chassis_type": "Main Server Chassis",
"dns": "192.168.6.1",
"name": "oldy",
"uuid": "4c4c4544-0050-5610-8057-b5c04f385a31",
"vmsystem": "Physical",
"workgroup": "local"
},
"versionclient": "GLPI-Inventory_v1.2-1",
"virtualmachines": [
{
"memory": 1572,
"name": "groggy",
"status": "running",
"subsystem": "kvm",
"uuid": "ebeddca4-b4fb-4c7a-bc92-f222d1bc38db",
"vcpu": 2,
"vmtype": "libvirt"
},
{
"memory": 4194,
"name": "shitty",
"status": "off",
"subsystem": "kvm",
"uuid": "3290b753-0310-4fb1-9edb-edfe71a300dd",
"vcpu": 4,
"vmtype": "libvirt"
},
{
"mac": "00:16:3e:33:bd:e2",
"name": "busy",
"status": "off",
"vcpu": 4,
"vmtype": "lxc"
},
{
"mac": "00:16:3e:f9:20:88",
"name": "edgy",
"status": "running",
"uuid": "c369dbe1bbdca879fbe6edb5759a6a4ccc00cae0",
"vcpu": 8,
"vmtype": "lxc"
},
{
"mac": "00:16:3e:51:b4:06",
"name": "funky",
"status": "running",
"uuid": "086ef8b21f28f79d04d46179c86479535aa21dab",
"vcpu": 2,
"vmtype": "lxc"
},
{
"mac": "00:16:3e:a7:37:10",
"name": "steady",
"status": "running",
"vcpu": 2,
"vmtype": "lxc"
},
{
"mac": "00:16:3e:68:5e:14",
"name": "zesty",
"status": "running",
"uuid": "6be79415745ca9341bec2e1358cb01b980e93e96",
"vcpu": 2,
"vmtype": "lxc"
}
]
},
"deviceid": "oldy.local-2022-06-01-10-24-55",
"itemtype": "Computer"
}
[root@oldy ~]#
There's no memory amount retrieved for the LXC containers :(
So, I guess the values I see on the virtualization overview section are probably from an old version of FusionInventory..?
I've tried to put the values in bytes without the "M" suffix in my LXC conf and, when I do, "glpi-inventory --partial=virtualmachine" shows it in its output. Ex:
{
"mac": "00:16:3e:51:b4:06",
"memory": 2147483648,
"name": "funky",
"status": "running",
"uuid": "086ef8b21f28f79d04d46179c86479535aa21dab",
"vcpu": 2,
"vmtype": "lxc"
}
Hi, I tried to transfer this issue to GLPI-Agent GH. This created this issue: glpi-project/glpi-agent#132 but it seems something goes wrong during the transfer. So I'm closing it here as I included a fix to correctly compute LXC container memory. @mightyspiky as I said in the GLPI-Agent issue, you can now use the nightly build.
I've just tried the nightly build and it works perfect now! I had to delete manually the containers that had the "M" suffix in the GLPI interface but, after that, I re-ran the agent, containers reappear and memory amount for them appears correctly without the "M". Thanks Guillaume!!
I'm now running glpi-agent 1.4 and it seems LXC containers memory limit get inventoried correctly the first time, but if I change the memory limit in an lxc container's config and then run glpi-agent again, the memory limit in GLPI doesn't get updated. I must delete the container in GLPI and then re-inventory again to get the memory limit update so I would like to re-open the issue. Also, I don't know if I must post here or on https://github.com/glpi-project/glpi-agent/issues/132 so I'm waiting for your answer g-bougard or anyone else.
Code of Conduct
Is there an existing issue for this?
Version
10.0
Bug description
In the GLPI web interface, manually editing the comment field of an LXC container brought up by automatic inventory (in the virtualization section of a computer object) erase the value for the memory field.
Relevant log output
No response
Page URL
No response
Steps To reproduce
Your GLPI setup information
Informations sur le système, l'installation et la configuration
Server
GLPI constants
Libraries
SQL replicas
Notifications
Plugins list
Anything else?
No response