Commit 34168773 authored by Ben Wilson's avatar Ben Wilson

Fixes panic caused by version initialized to nil

parent 1644c7b2
...@@ -20,6 +20,8 @@ import ( ...@@ -20,6 +20,8 @@ import (
"k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes"
) )
var UnknownStatus = "UNKNOWN"
var ( var (
listenAddress = kingpin.Flag( listenAddress = kingpin.Flag(
"web.listen-address", "web.listen-address",
...@@ -86,7 +88,7 @@ func main() { ...@@ -86,7 +88,7 @@ func main() {
healthy: false, healthy: false,
updateTime: time.Now(), updateTime: time.Now(),
allowedMethods: nil, allowedMethods: nil,
version: nil, version: &UnknownStatus,
} }
http.Handle("/metrics", promhttp.Handler()) http.Handle("/metrics", promhttp.Handler())
http.Handle("/health", healthHandler(&health)) http.Handle("/health", healthHandler(&health))
...@@ -130,8 +132,7 @@ func getSequencerVersion(health *healthCheck, client *kubernetes.Clientset) { ...@@ -130,8 +132,7 @@ func getSequencerVersion(health *healthCheck, client *kubernetes.Clientset) {
} }
sequencerStatefulSet, err := client.AppsV1().StatefulSets(string(ns)).Get(context.TODO(), "sequencer", getOpts) sequencerStatefulSet, err := client.AppsV1().StatefulSets(string(ns)).Get(context.TODO(), "sequencer", getOpts)
if err != nil { if err != nil {
unknownStatus := "UNKNOWN" health.version = &UnknownStatus
health.version = &unknownStatus
log.Errorf("Unable to retrieve a sequencer StatefulSet: %s", err) log.Errorf("Unable to retrieve a sequencer StatefulSet: %s", err)
continue continue
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment