-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
contrib/mixin: Generate rules, fix tests #13671
Conversation
Codecov Report
@@ Coverage Diff @@
## main #13671 +/- ##
==========================================
- Coverage 72.91% 72.68% -0.23%
==========================================
Files 465 465
Lines 37947 37858 -89
==========================================
- Hits 27668 27518 -150
- Misses 8514 8562 +48
- Partials 1765 1778 +13
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@@ -0,0 +1,147 @@ | |||
groups: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't add generated files to repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was the main intent, have it here so we can use it in https://github.com/prometheus-community/helm-charts/blob/main/charts/kube-prometheus-stack/hack/sync_prometheus_rules.py#L63
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we should add a test that ensures that this file is up to date, so that PRs that change rules always need to regenerate this file.
I would like a second opinion of fact that we are adding this file. @tomwilkie @lilic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @serathius here, you should rarely want to use a generic generated yaml and often override configs like namespaces and other fields. and @mrueg it might be better to sync on the non-generated files rather than yaml?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I agree with not having rendered output in a repository (as it might run out of sync), this approach follows what https://github.com/prometheus-operator/kube-prometheus/tree/main/manifests and https://github.com/monitoring-mixins/website have been doing and had been practice in the etcd-3.4 and previous releases https://raw.githubusercontent.com/etcd-io/website/master/content/en/docs/v3.4/op-guide/etcd3_alert.rules.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brancz @paulfantom might be more up to date on this, but from what I remember there was talk about removing the generated manifests to discourage folks from applying those directly instead consuming the jsonnet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we still have that issue in kube-prometheus and we are looking for alternatives to remove generated files from the repository. However, this is not a top priority right now.
As for mixins, https://monitoring.mixins.dev/ is regenerating etcd mixin daily and allows for consumption in YAML format (YAML files available in here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for using it in https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack/hack, why not add jsonnet execution there and customize mixin to the needs of the helm chart? This way you can even add more mixins and consume them directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for providing additional context @paulfantom! I wasn't aware that you're looking into phasing out generated files. In general, I think from a documentation perspective a rendered file is more readable than the jsonnet. If the etcd maintainers would be okay, we could add it back to the website repo?
For https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack/hack this currently relies on someone's own setup when running the script and providing the PR, thus I wanted to avoid to require additional tooling there. Eventually, it might be good to look into adding more mixins there if we need more and then have common tooling for it.
Those tests were broken as they were not run automatically. Please integrate this tests in GitHub CI tests or there is no sense in fixing them. |
70f8524
to
6b78793
Compare
Tests are included now in github workflow. Still failing on the two tests. |
I would disable those two tests for now so we can at least have other tests running and preventing breakage. If you don't want to fix them in this PR, then please comment them out and file an issue for it so someone else can pick it up. |
082044b
to
a514863
Compare
I fixed one test and will take a look at the other one later. Thanks for the quick feedback! |
a514863
to
4bfafa0
Compare
Hey @mrueg, could you split the test fix into separate PR so we can merge it? |
Hi! Sorry for the late reply. It may be easier to use |
* Add Makefile * Make tests runnable * Add generated rule manifest file Signed-off-by: Manuel Rüger <manuel@rueg.eu>
4bfafa0
to
72c33d8
Compare
@@ -14,6 +14,7 @@ | |||
*.test | |||
hack/tls-setup/certs | |||
.idea | |||
/contrib/mixin/manifests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the folder to .gitignore here so it doesn't get added to the repo if someone generates it.
@@ -0,0 +1,147 @@ | |||
groups: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for providing additional context @paulfantom! I wasn't aware that you're looking into phasing out generated files. In general, I think from a documentation perspective a rendered file is more readable than the jsonnet. If the etcd maintainers would be okay, we could add it back to the website repo?
For https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack/hack this currently relies on someone's own setup when running the script and providing the PR, thus I wanted to avoid to require additional tooling there. Eventually, it might be good to look into adding more mixins there if we need more and then have common tooling for it.
@serathius I have removed the rendered file |
I think that'd be a great idea - we're using it in a few places already (eg https://github.com/grafana/jsonnet-libs/blob/master/Makefile#L24). Its also got a linter that applied various lint rules to both the dashboards and the alerts that you might find useful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing tests. Great Job!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Thanks @mrueg
Primary intent of this PR is to have a rendered rules file that we can include in kube-prometheus-stack.
Additionally I added the following pieces:
After changing the time series (series only seems to support plain time series) in the test.yaml so the tests run, those two still fail:
Let me know if anyone has time to provide a fix (I tried to fix them, but for some reason my ideas didn't work).
@ptabor