-
Problem report
-
Resolution: Fixed
-
Trivial
-
6.0.16, 6.4.1, 7.0.0alpha1
-
Sprint 100 (May 2023), Sprint 101 (Jun 2023), Sprint 102 (Jul 2023), Sprint 103 (Aug 2023)
-
2
Please consider changing the behavior of building templates when they are exported from the frontend.
Right now, exported templates will have a different order of entities that are stored as items of an array in the resulting YAML or XML. If you delete these and recreate them they will have a different order in the resulting file. We assume that the reason behind this behaviour is that during the export these are sorted using their IDs in the DB and if you delete and recreate them, they will have different IDs.
Examples of such entities:
- overrides
- LLD macro paths in discovery rules
- graphs in dashboards
- fields in graphs
- formulas in filters
- script items' parameters
- etc.
Our current template creation tooling implementation uses the logic of deleting everything in the template and recreating it from scratch. As a result, it generates unnecessary diff, which makes it harder to review PRs (actually, a lot harder for some templates with a lot of such entities, or if for some reason you need to rebuild all templates with some minor change).
Steps to reproduce:
- Export a template with lots of overrides, LLD macro paths, etc (for example "Chassis by IPMI", "SMART by Zabbix agent 2", "Cisco Meraki", "Azure by HTTP", ...)
- Export it from the frontend and replace it in the main Zabbix repo.
- Most likely, you'll already get such diff. But if not, then stage these changes, then make further changes.
- As an example for the template "Chassis by IPMI", delete some LLD macros from the "Threshold sensors discovery" rule and create them from scratch.
- Export it from the frontend and replace it in the main Zabbix repo again.
- Check the unstaged area diff.
Result:
Entities are being mixed and change their order. See the attached screenshots with the examples of such diff.
Expected:
The exported templates should remain consistent at all times. This may be potentially dangerous, especially in case of filters in the LLD rules as it just randomly changes the macro order (formula IDs, A/B etc.), but I think that we've seen such behaviour only in case of AND type of calculation. Still, it would be much better to have at least alphabetical sort order during the export as it will give at least some kind of consistency.