From 77a8833d7000411dbd1c1b0262288f049b089154 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Wed, 18 Oct 2017 19:29:17 -0700 Subject: [PATCH] Handle failure to dial. --- zfs_replication_exporter.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/zfs_replication_exporter.go b/zfs_replication_exporter.go index 857b54c..fcc3b1d 100644 --- a/zfs_replication_exporter.go +++ b/zfs_replication_exporter.go @@ -195,10 +195,12 @@ func main() { glog.Errorf("Error dialing %q: %v", host, err) } } - if err := updateMetrics(host, c); err != nil { - glog.Errorf("Failed to update metrics: %v", err) - c.Close() - c = nil + if c != nil { + if err := updateMetrics(host, c); err != nil { + glog.Errorf("Failed to update metrics: %v", err) + c.Close() + c = nil + } } time.Sleep(*refreshInterval) }