Avoid sorting rules in rule-patching library
Description
Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.
This change improves the rule-sanitizer library to avoid sorting all the rules. This was originally done to simplify indexing rules with the same names, but it turns out that integrating this lib can be complex to review when all the rules of the manifests are reordered. Thus, it is easier to just leave the file as it was initially sorted.
Type of change
What type of changes does your code introduce to the kube-prometheus? Put an x in the box that apply.
- [ ]
CHANGE(fix or feature that would cause existing functionality to not work as expected) - [ ]
FEATURE(non-breaking change which adds functionality) - [ ]
BUGFIX(non-breaking change which fixes an issue) - [x]
ENHANCEMENT(non-breaking change which improves existing functionality) - [ ]
NONE(if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)
Changelog entry
Please put a one-line changelog entry below. Later this will be copied to the changelog file.
Avoid sorting rules in rule-patching library
/cc @raptorsun
Test with a patch and the indexRules() function need some fix. In the returned array from indexRules() the index of every element is 0.
Tested with the following content in rule-patches.libsonnet:
{
excludedRuleGroups: [],
excludedRules: [],
patchedRules: [
{
name: 'kubernetes-storage',
rules: [
{
alert: 'KubePersistentVolumeFillingUp',
index: 1,
patches: 'index 1 patch',
},
],
},
],
}
In the output file kubernetes-prometheusRule.yaml the 2 rules for alert KubePersistentVolumeFillingUp has not changed.
It should be good now, I hadn't tested it enough and there was something wrong in the script.
The new version looks good to me :)