From ed859bdf9b3ae59ba5975bf797d8580b30a22a60 Mon Sep 17 00:00:00 2001 From: Ryan Belgrave Date: Thu, 18 Feb 2021 18:04:25 -0600 Subject: [PATCH] remove host port metric since it doesn't go away on leader change --- controllers/hostport_controller.go | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/controllers/hostport_controller.go b/controllers/hostport_controller.go index 1d9535c..7f99bf7 100644 --- a/controllers/hostport_controller.go +++ b/controllers/hostport_controller.go @@ -22,7 +22,6 @@ import ( "sync" "github.com/go-logr/logr" - "github.com/prometheus/client_golang/prometheus" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" @@ -30,28 +29,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/handler" - "sigs.k8s.io/controller-runtime/pkg/metrics" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" hostportv1alpha1 "github.com/rmb938/hostport-allocator/api/v1alpha1" ) -var ( - metricsHostPortInfo = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Namespace: "hostport", - Name: "hostport_port", - Help: "The port allocated to the hostport", - }, - []string{"name"}, - ) -) - -func init() { - metrics.Registry.MustRegister(metricsHostPortInfo) -} - // HostPortReconciler reconciles a HostPort object type HostPortReconciler struct { client.Client @@ -72,16 +55,11 @@ func (r *HostPortReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { err := r.Get(ctx, req.NamespacedName, hp) if err != nil { if apierrors.IsNotFound(err) { - metricsHostPortInfo.DeleteLabelValues(req.Name) return ctrl.Result{}, nil } return ctrl.Result{}, err } - metricsHostPortInfo.With(prometheus.Labels{ - "name": hp.Name, - }).Set(float64(hp.Status.Port)) - // if port is deleting if hp.DeletionTimestamp.IsZero() == false {