1
0
Fork 0
mirror of https://github.com/kyverno/policy-reporter.git synced 2024-12-14 11:57:32 +00:00

Fix cache fallback (#369)

* Fix Cache fallback

Signed-off-by: Frank Jogeleit <frank.jogeleit@web.de>

* update changelog

Signed-off-by: Frank Jogeleit <frank.jogeleit@web.de>

---------

Signed-off-by: Frank Jogeleit <frank.jogeleit@web.de>
This commit is contained in:
Frank Jogeleit 2023-11-21 11:39:06 +01:00 committed by GitHub
parent 7751d895f1
commit 4d1840342b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View file

@ -1,8 +1,13 @@
# Changelog # Changelog
# Next
* Policy Reporter v2.17.3
* Fix handling if metric cache fallback
# 2.21.2 # 2.21.2
* Policy Reporter * Policy Reporter v2.17.2
* Fix ID generation for Policy Reports which using `scope` as resource reference * Fix ID generation for Policy Reports which using `scope` as resource reference
* Add optional `message` metric label
* Helm Chart * Helm Chart
* fix: Add chart parameters for setting `revisionHistoryLimit` [[#363](https://github.com/kyverno/policy-reporter/pull/363) by [bodgit](https://github.com/bodgit)] * fix: Add chart parameters for setting `revisionHistoryLimit` [[#363](https://github.com/kyverno/policy-reporter/pull/363) by [bodgit](https://github.com/bodgit)]
* fix: allow not setting `.Values.podSecurityContext` for kyvernoPlugin [[#361](https://github.com/kyverno/policy-reporter/pull/361) by [haraldsk](https://github.com/haraldsk)] * fix: allow not setting `.Values.podSecurityContext` for kyvernoPlugin [[#361](https://github.com/kyverno/policy-reporter/pull/361) by [haraldsk](https://github.com/haraldsk)]

View file

@ -61,10 +61,7 @@ func (c *Cache) GetReportLabels(id string) []*CacheItem {
return item.([]*CacheItem) return item.([]*CacheItem)
} }
return []*CacheItem{{ return []*CacheItem{}
Labels: make(prometheus.Labels),
Value: 0,
}}
} }
func labelHash(labels prometheus.Labels) string { func labelHash(labels prometheus.Labels) string {

View file

@ -60,7 +60,9 @@ func CreateCustomResultMetricsListener(
case report.Deleted: case report.Deleted:
items := cache.GetReportLabels(newReport.GetID()) items := cache.GetReportLabels(newReport.GetID())
for _, item := range items { for _, item := range items {
decreaseOrDelete(gauge, item.Labels, item.Value) if len(item.Labels) > 0 {
decreaseOrDelete(gauge, item.Labels, item.Value)
}
} }
cache.Remove(newReport.GetID()) cache.Remove(newReport.GetID())