OpenNebula / one

The open source Cloud & Edge Computing Platform bringing real freedom to your Enterprise Cloud 🚀
http://opennebula.io
Apache License 2.0
1.24k stars 480 forks source link

Case sensitive Augeas oned.conf lens #5165

Open vholer opened 3 years ago

vholer commented 3 years ago

Description

Augeas lens for reading oned.conf-like configuration files is case sensitive, so it's easy to create redundant entries with different casing, which are not effective (i.e., only first occurance in unique parameters matter).

To Reproduce Steps to reproduce the behavior.

# augtool 
augtool> print /files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK
/files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK
/files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK/DRIVER = "\"raw\""
/files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK/CACHE = "\"none\""
/files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK/DISCARD = "\"unmap\""

augtool> set /files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK/DRIVER '"test"'
augtool> print /files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK
/files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK
/files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK/DRIVER = "\"test\""
/files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK/CACHE = "\"none\""
/files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK/DISCARD = "\"unmap\""

augtool> set /files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK/driver '"test"'
augtool> print /files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK
/files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK
/files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK/DRIVER = "\"test\""
/files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK/CACHE = "\"none\""
/files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK/DISCARD = "\"unmap\""
/files/etc/one/vmm_exec/vmm_exec_kvm.conf/DISK/driver = "\"test\""             # <---------------
augtool> 

Expected behavior All path elements inside file, no matter the real casing, can be addressed simply (e.g., downcasing everything in memory structure on load, while preserving the original casing on save).

Details

Progress Status

xorel commented 3 years ago

To fix this it seems we would need to switch from non-specific lenses based on regex allowing arbitrary keys to more specific entries with enumerating allowed keys. So, instead

let name = key /[A-Z_0-9]+/`

we can have

let port = del /[pP][oO][rR][tT]/ "PORT" . label "PORT"
let name = ( port | ... )

This would work case-insensitive for line PORT=2633

atodorov-storpool commented 3 years ago

IMO double definitions (caps sensitive or not) should be handled by the server-side too. OpenNebula should issue a warning or even raise an error for such issues. This will be more generic because such errors could be done not only with augeas lens.

For example, at the beginning I've usually was uncommenting the DB section to enable MySQL configuration, forgetting to comment the sqlite3 one which was leading to oned still using sqlite3... (it looks like the first match has precedence). Not exactly the case because the augeas lens actually resolved this case, but I think that you understand me.