Remove metrics field from controllers
Signed-off-by: Michael Tsang <michael.tsang@jetstack.io>
This commit is contained in:
parent
455f6ebab4
commit
7d67ae466e
@ -37,7 +37,6 @@ import (
|
||||
"github.com/jetstack/cert-manager/pkg/issuer/acme/dns"
|
||||
"github.com/jetstack/cert-manager/pkg/issuer/acme/http"
|
||||
logf "github.com/jetstack/cert-manager/pkg/logs"
|
||||
"github.com/jetstack/cert-manager/pkg/metrics"
|
||||
)
|
||||
|
||||
type Controller struct {
|
||||
@ -64,7 +63,6 @@ type Controller struct {
|
||||
|
||||
watchedInformers []cache.InformerSynced
|
||||
queue workqueue.RateLimitingInterface
|
||||
metrics *metrics.Metrics
|
||||
|
||||
scheduler *scheduler.Scheduler
|
||||
}
|
||||
@ -106,7 +104,6 @@ func New(ctx *controllerpkg.Context) (*Controller, error) {
|
||||
|
||||
ctrl.helper = issuer.NewHelper(ctrl.issuerLister, ctrl.clusterIssuerLister)
|
||||
ctrl.acmeHelper = acme.NewHelper(ctrl.secretLister, ctrl.Context.ClusterResourceNamespace)
|
||||
ctrl.metrics = metrics.Default
|
||||
|
||||
ctrl.httpSolver = http.NewSolver(ctx)
|
||||
var err error
|
||||
|
||||
@ -33,6 +33,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/pkg/feature"
|
||||
dnsutil "github.com/jetstack/cert-manager/pkg/issuer/acme/dns/util"
|
||||
logf "github.com/jetstack/cert-manager/pkg/logs"
|
||||
"github.com/jetstack/cert-manager/pkg/metrics"
|
||||
acmeapi "github.com/jetstack/cert-manager/third_party/crypto/acme"
|
||||
)
|
||||
|
||||
@ -56,7 +57,7 @@ type solver interface {
|
||||
// Sync will process this ACME Challenge.
|
||||
// It is the core control function for ACME challenges.
|
||||
func (c *Controller) Sync(ctx context.Context, ch *cmapi.Challenge) (err error) {
|
||||
c.metrics.ControllerSyncCallCount.WithLabelValues(ControllerName).Inc()
|
||||
metrics.Default.IncrementSyncCallCount(ControllerName)
|
||||
|
||||
log := logf.FromContext(ctx).WithValues("dnsName", ch.Spec.DNSName, "type", ch.Spec.Type)
|
||||
ctx = logf.NewContext(ctx, log)
|
||||
|
||||
@ -36,7 +36,6 @@ import (
|
||||
controllerpkg "github.com/jetstack/cert-manager/pkg/controller"
|
||||
"github.com/jetstack/cert-manager/pkg/issuer"
|
||||
logf "github.com/jetstack/cert-manager/pkg/logs"
|
||||
"github.com/jetstack/cert-manager/pkg/metrics"
|
||||
)
|
||||
|
||||
type Controller struct {
|
||||
@ -58,7 +57,6 @@ type Controller struct {
|
||||
|
||||
watchedInformers []cache.InformerSynced
|
||||
queue workqueue.RateLimitingInterface
|
||||
metrics *metrics.Metrics
|
||||
|
||||
// used for testing
|
||||
clock clock.Clock
|
||||
@ -96,7 +94,6 @@ func New(ctx *controllerpkg.Context) *Controller {
|
||||
secretInformer := ctrl.KubeSharedInformerFactory.Core().V1().Secrets()
|
||||
ctrl.watchedInformers = append(ctrl.watchedInformers, secretInformer.Informer().HasSynced)
|
||||
ctrl.secretLister = secretInformer.Lister()
|
||||
ctrl.metrics = metrics.Default
|
||||
|
||||
ctrl.helper = issuer.NewHelper(ctrl.issuerLister, ctrl.clusterIssuerLister)
|
||||
ctrl.acmeHelper = acme.NewHelper(ctrl.secretLister, ctrl.Context.ClusterResourceNamespace)
|
||||
|
||||
@ -33,6 +33,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/pkg/acme"
|
||||
acmecl "github.com/jetstack/cert-manager/pkg/acme/client"
|
||||
cmapi "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha1"
|
||||
"github.com/jetstack/cert-manager/pkg/metrics"
|
||||
acmeapi "github.com/jetstack/cert-manager/third_party/crypto/acme"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
@ -48,7 +49,7 @@ var (
|
||||
// - create a Challenge resource in order to fulfill required validations
|
||||
// - waiting for Challenge resources to enter the 'ready' state
|
||||
func (c *Controller) Sync(ctx context.Context, o *cmapi.Order) (err error) {
|
||||
c.metrics.ControllerSyncCallCount.WithLabelValues(ControllerName).Inc()
|
||||
metrics.Default.IncrementSyncCallCount(ControllerName)
|
||||
|
||||
oldOrder := o
|
||||
o = o.DeepCopy()
|
||||
|
||||
@ -69,7 +69,7 @@ var (
|
||||
)
|
||||
|
||||
func (c *Controller) Sync(ctx context.Context, crt *v1alpha1.Certificate) (err error) {
|
||||
c.metrics.ControllerSyncCallCount.WithLabelValues(ControllerName).Inc()
|
||||
c.metrics.IncrementSyncCallCount(ControllerName)
|
||||
|
||||
log := logf.FromContext(ctx)
|
||||
dbg := log.V(logf.DebugLevel)
|
||||
|
||||
@ -33,7 +33,6 @@ import (
|
||||
controllerpkg "github.com/jetstack/cert-manager/pkg/controller"
|
||||
"github.com/jetstack/cert-manager/pkg/issuer"
|
||||
logf "github.com/jetstack/cert-manager/pkg/logs"
|
||||
"github.com/jetstack/cert-manager/pkg/metrics"
|
||||
)
|
||||
|
||||
type Controller struct {
|
||||
@ -49,7 +48,6 @@ type Controller struct {
|
||||
|
||||
watchedInformers []cache.InformerSynced
|
||||
queue workqueue.RateLimitingInterface
|
||||
metrics *metrics.Metrics
|
||||
}
|
||||
|
||||
func New(ctx *controllerpkg.Context) *Controller {
|
||||
@ -68,7 +66,6 @@ func New(ctx *controllerpkg.Context) *Controller {
|
||||
ctrl.secretLister = secretsInformer.Lister()
|
||||
ctrl.issuerFactory = issuer.NewIssuerFactory(ctx)
|
||||
ctrl.ctx = logf.NewContext(ctx.RootContext, nil, ControllerName)
|
||||
ctrl.metrics = metrics.Default
|
||||
|
||||
return ctrl
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha1"
|
||||
"github.com/jetstack/cert-manager/pkg/apis/certmanager/validation"
|
||||
logf "github.com/jetstack/cert-manager/pkg/logs"
|
||||
"github.com/jetstack/cert-manager/pkg/metrics"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -38,7 +39,7 @@ const (
|
||||
)
|
||||
|
||||
func (c *Controller) Sync(ctx context.Context, iss *v1alpha1.ClusterIssuer) (err error) {
|
||||
c.metrics.ControllerSyncCallCount.WithLabelValues(ControllerName).Inc()
|
||||
metrics.Default.IncrementSyncCallCount(ControllerName)
|
||||
|
||||
log := logf.FromContext(ctx)
|
||||
|
||||
|
||||
@ -43,7 +43,6 @@ go_test(
|
||||
deps = [
|
||||
"//pkg/apis/certmanager/v1alpha1:go_default_library",
|
||||
"//pkg/controller/test:go_default_library",
|
||||
"//pkg/metrics:go_default_library",
|
||||
"//test/unit/gen:go_default_library",
|
||||
"//vendor/k8s.io/api/extensions/v1beta1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
|
||||
@ -38,7 +38,6 @@ import (
|
||||
cmlisters "github.com/jetstack/cert-manager/pkg/client/listers/certmanager/v1alpha1"
|
||||
controllerpkg "github.com/jetstack/cert-manager/pkg/controller"
|
||||
"github.com/jetstack/cert-manager/pkg/issuer"
|
||||
"github.com/jetstack/cert-manager/pkg/metrics"
|
||||
"github.com/jetstack/cert-manager/pkg/util"
|
||||
extinformers "k8s.io/client-go/informers/extensions/v1beta1"
|
||||
)
|
||||
@ -73,7 +72,6 @@ type Controller struct {
|
||||
workerWg sync.WaitGroup
|
||||
syncedFuncs []cache.InformerSynced
|
||||
defaults defaults
|
||||
metrics *metrics.Metrics
|
||||
}
|
||||
|
||||
// New returns a new Certificates controller. It sets up the informer handler
|
||||
@ -109,7 +107,6 @@ func New(
|
||||
}
|
||||
|
||||
ctrl.helper = issuer.NewHelper(ctrl.issuerLister, ctrl.clusterIssuerLister)
|
||||
ctrl.metrics = metrics.Default
|
||||
|
||||
return ctrl
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ import (
|
||||
"k8s.io/klog"
|
||||
|
||||
"github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha1"
|
||||
"github.com/jetstack/cert-manager/pkg/metrics"
|
||||
"github.com/jetstack/cert-manager/pkg/util"
|
||||
)
|
||||
|
||||
@ -60,7 +61,7 @@ const (
|
||||
var ingressGVK = extv1beta1.SchemeGroupVersion.WithKind("Ingress")
|
||||
|
||||
func (c *Controller) Sync(ctx context.Context, ing *extv1beta1.Ingress) error {
|
||||
c.metrics.ControllerSyncCallCount.WithLabelValues(ControllerName).Inc()
|
||||
metrics.Default.IncrementSyncCallCount(ControllerName)
|
||||
|
||||
if !shouldSync(ing, c.defaults.autoCertificateAnnotations) {
|
||||
klog.Infof("Not syncing ingress %s/%s as it does not contain necessary annotations", ing.Namespace, ing.Name)
|
||||
|
||||
@ -28,7 +28,6 @@ import (
|
||||
|
||||
"github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha1"
|
||||
testpkg "github.com/jetstack/cert-manager/pkg/controller/test"
|
||||
"github.com/jetstack/cert-manager/pkg/metrics"
|
||||
"github.com/jetstack/cert-manager/test/unit/gen"
|
||||
)
|
||||
|
||||
@ -911,8 +910,7 @@ func TestSync(t *testing.T) {
|
||||
issuerKind: test.DefaultIssuerKind,
|
||||
autoCertificateAnnotations: []string{testAcmeTLSAnnotation},
|
||||
},
|
||||
helper: &fakeHelper{issuer: test.Issuer},
|
||||
metrics: metrics.Default,
|
||||
helper: &fakeHelper{issuer: test.Issuer},
|
||||
}
|
||||
b.Sync()
|
||||
|
||||
|
||||
@ -33,7 +33,6 @@ import (
|
||||
controllerpkg "github.com/jetstack/cert-manager/pkg/controller"
|
||||
"github.com/jetstack/cert-manager/pkg/issuer"
|
||||
logf "github.com/jetstack/cert-manager/pkg/logs"
|
||||
"github.com/jetstack/cert-manager/pkg/metrics"
|
||||
)
|
||||
|
||||
type Controller struct {
|
||||
@ -50,7 +49,6 @@ type Controller struct {
|
||||
|
||||
watchedInformers []cache.InformerSynced
|
||||
queue workqueue.RateLimitingInterface
|
||||
metrics *metrics.Metrics
|
||||
}
|
||||
|
||||
func New(ctx *controllerpkg.Context) *Controller {
|
||||
@ -72,7 +70,6 @@ func New(ctx *controllerpkg.Context) *Controller {
|
||||
ctrl.secretLister = secretsInformer.Lister()
|
||||
ctrl.issuerFactory = issuer.NewIssuerFactory(ctx)
|
||||
ctrl.ctx = logf.NewContext(ctx.RootContext, nil, ControllerName)
|
||||
ctrl.metrics = metrics.Default
|
||||
|
||||
return ctrl
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha1"
|
||||
"github.com/jetstack/cert-manager/pkg/apis/certmanager/validation"
|
||||
logf "github.com/jetstack/cert-manager/pkg/logs"
|
||||
"github.com/jetstack/cert-manager/pkg/metrics"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -38,7 +39,7 @@ const (
|
||||
)
|
||||
|
||||
func (c *Controller) Sync(ctx context.Context, iss *v1alpha1.Issuer) (err error) {
|
||||
c.metrics.ControllerSyncCallCount.WithLabelValues(ControllerName).Inc()
|
||||
metrics.Default.IncrementSyncCallCount(ControllerName)
|
||||
|
||||
log := logf.FromContext(ctx)
|
||||
|
||||
|
||||
@ -195,3 +195,9 @@ func updateX509Expiry(name, namespace string, cert *x509.Certificate) {
|
||||
"name": name,
|
||||
"namespace": namespace}).Set(float64(expiryTime.Unix()))
|
||||
}
|
||||
|
||||
func (m *Metrics) IncrementSyncCallCount(controllerName string) {
|
||||
log := logf.FromContext(m.ctx)
|
||||
log.V(logf.DebugLevel).Info("incrementing controller sync call count", "controllerName", controllerName)
|
||||
ControllerSyncCallCount.WithLabelValues(controllerName).Inc()
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user