Skip to content

Commit

Permalink
Fix Dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Jogeleit committed Feb 22, 2021
1 parent 11c32ad commit 9eb5337
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
4 changes: 2 additions & 2 deletions charts/policy-reporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name: policy-reporter
description: K8s PolicyReporter watches for wgpolicyk8s.io/v1alpha1.PolicyReport resources. It creates Prometheus Metrics and can send rule validation events to Loki

type: application
version: 0.5.0
appVersion: 0.4.0
version: 0.5.1
appVersion: 0.4.1
4 changes: 2 additions & 2 deletions charts/policy-reporter/templates/dashboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,13 @@ data:
{
"expr": "sum(cluster_policy_report_result{status=~\"fail|error\"} > 0) by (policy)",
"interval": "",
"legendFormat": "{{` {{ rule }}` }}",
"legendFormat": "{{` {{ policy }}` }}",
"refId": "A"
},
{
"expr": "sum(policy_report_result{status=~\"fail|error\"} > 0) by (policy)",
"interval": "",
"legendFormat": "{{` {{ rule }}` }}",
"legendFormat": "{{` {{ policy }}` }}",
"refId": "B"
}
],
Expand Down
2 changes: 1 addition & 1 deletion charts/policy-reporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ metrics:
image:
repository: fjogeleit/policy-reporter
pullPolicy: IfNotPresent
tag: 0.4.0
tag: 0.4.1

imagePullSecrets: []

Expand Down
40 changes: 24 additions & 16 deletions pkg/kubernetes/report_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,38 @@ func (c *policyReportClient) FetchPolicyReports() []report.PolicyReport {
}

func (c *policyReportClient) WatchClusterPolicyReports(cb report.WatchClusterPolicyReportCallback) {
result, err := c.client.Resource(clusterPolicyReports).Watch(context.Background(), metav1.ListOptions{})
if err != nil {
log.Printf("K8s Watch Error: %s\n", err.Error())
return
}
for {
result, err := c.client.Resource(clusterPolicyReports).Watch(context.Background(), metav1.ListOptions{})
if err != nil {
log.Printf("K8s Watch Error: %s\n", err.Error())
return
}

for result := range result.ResultChan() {
if item, ok := result.Object.(*unstructured.Unstructured); ok {
cb(result.Type, c.mapClusterPolicyReport(item.Object))
for result := range result.ResultChan() {
if item, ok := result.Object.(*unstructured.Unstructured); ok {
cb(result.Type, c.mapClusterPolicyReport(item.Object))
}
}

log.Println("[WARNING] WatchClusterPolicyReports Stops")
}
}

func (c *policyReportClient) WatchPolicyReports(cb report.WatchPolicyReportCallback) {
result, err := c.client.Resource(policyReports).Watch(context.Background(), metav1.ListOptions{})
if err != nil {
log.Printf("K8s Watch Error: %s\n", err.Error())
return
}
for {
result, err := c.client.Resource(policyReports).Watch(context.Background(), metav1.ListOptions{})
if err != nil {
log.Printf("K8s Watch Error: %s\n", err.Error())
return
}

for result := range result.ResultChan() {
if item, ok := result.Object.(*unstructured.Unstructured); ok {
cb(result.Type, c.mapPolicyReport(item.Object))
for result := range result.ResultChan() {
if item, ok := result.Object.(*unstructured.Unstructured); ok {
cb(result.Type, c.mapPolicyReport(item.Object))
}
}

log.Println("[WARNING] WatchPolicyReports Stops")
}
}

Expand Down

0 comments on commit 9eb5337

Please sign in to comment.