Skip to content

Commit

Permalink
Bug 1701495: Eventrouter pod in CrashLoopBackOff status: "runtime err…
Browse files Browse the repository at this point in the history
…or: invalid memory address or nil pointer dereference"

https://bugzilla.redhat.com/show_bug.cgi?id=1701495
  • Loading branch information
richm committed Oct 9, 2019
1 parent fec0a81 commit 9cde058
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
45 changes: 42 additions & 3 deletions eventrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/openshift/eventrouter/sinks"
"github.com/prometheus/client_golang/prometheus"

"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"

This comment has been minimized.

Copy link
@alanconway

alanconway Feb 10, 2021

This is a no-op, renaming package "v1" to "v1".
I'd prefer "corev1" as its more informative.

This comment has been minimized.

Copy link
@richm

richm Feb 10, 2021

Author

ok - I would prefer that someone on the logging team takes over this PR

This comment has been minimized.

Copy link
@alanconway

alanconway Feb 10, 2021

Me and my big mouth :) Its a nit really. /lgtm

utilruntime "k8s.io/apimachinery/pkg/util/runtime"
coreinformers "k8s.io/client-go/informers/core/v1"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -52,11 +52,33 @@ var (
"reason",
"source",
})
kubernetesInfoEventCounterVec = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "heptio_eventrouter_info_total",
Help: "Total number of info events in the kubernetes cluster",
}, []string{
"involved_object_kind",
"involved_object_name",
"involved_object_namespace",
"reason",
"source",
})
kubernetesUnknownEventCounterVec = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "heptio_eventrouter_unknown_total",
Help: "Total number of events of unknown type in the kubernetes cluster",
}, []string{
"involved_object_kind",
"involved_object_name",
"involved_object_namespace",
"reason",
"source",
})
)

func init() {
prometheus.MustRegister(kubernetesWarningEventCounterVec)
prometheus.MustRegister(kubernetesNormalEventCounterVec)
prometheus.MustRegister(kubernetesInfoEventCounterVec)
prometheus.MustRegister(kubernetesUnknownEventCounterVec)
}

// EventRouter is responsible for maintaining a stream of kubernetes
Expand Down Expand Up @@ -127,22 +149,39 @@ func prometheusEvent(event *v1.Event) {
var counter prometheus.Counter
var err error

if event.Type == "Normal" {
switch event.Type {
case "Normal":
counter, err = kubernetesNormalEventCounterVec.GetMetricWithLabelValues(
event.InvolvedObject.Kind,
event.InvolvedObject.Name,
event.InvolvedObject.Namespace,
event.Reason,
event.Source.Host,
)
} else if event.Type == "Warning" {
case "Warning":
counter, err = kubernetesWarningEventCounterVec.GetMetricWithLabelValues(
event.InvolvedObject.Kind,
event.InvolvedObject.Name,
event.InvolvedObject.Namespace,
event.Reason,
event.Source.Host,
)
case "Info":
counter, err = kubernetesInfoEventCounterVec.GetMetricWithLabelValues(
event.InvolvedObject.Kind,
event.InvolvedObject.Name,
event.InvolvedObject.Namespace,
event.Reason,
event.Source.Host,
)
default:
counter, err = kubernetesUnknownEventCounterVec.GetMetricWithLabelValues(
event.InvolvedObject.Kind,
event.InvolvedObject.Name,
event.InvolvedObject.Namespace,
event.Reason,
event.Source.Host,
)
}

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion yaml/eventrouter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ metadata:
name: eventrouter-cm
namespace: kube-system
---
apiVersion: apps/v1beta2
apiVersion: apps/v1
kind: Deployment
metadata:
name: eventrouter
Expand Down

1 comment on commit 9cde058

@alanconway
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Please sign in to comment.