sni / lmd

Livestatus Multitool Daemon - Create livestatus federation from multiple sources
https://labs.consol.de/omd/packages/lmd/
GNU General Public License v3.0
42 stars 31 forks source link

Keep services sorted after indexing #120

Closed erikdsjostrom closed 2 years ago

erikdsjostrom commented 2 years ago

When pre-filtering services by host name the services are fetched as map and then converted to an array. Since maps are an unordered data structure the order of the resulting array will essentially be random. This causes an issue with service queries which follow the default sort order, the result of these queries are not sorted because they are expected to already be sorted. So for a simple service query in the default sort order with a host_name filter which triggers pre-filtering this combination produces a result where the order of the services is random.

With this commit the services are sorted by their description, which is the default order, before returning them in the pre-filtering stage.

Signed-off-by: Erik Sjöström esjostrom@itrsgroup.com

sni commented 2 years ago

good catch, that explains some issues i was experiencing. Running gofmt should fix the citests.

erikdsjostrom commented 2 years ago

Will do.

sni commented 2 years ago

golangci is still not happy, you can run the citests manually by make citest. I guess you need to either initialize the list and then set the values by index, or initialize it empty and then append to it.

erikdsjostrom commented 2 years ago

Woops, didn't mean to close the PR. Let's go with initializing an empty list.