Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package main

import (
"context"
"crypto/tls"
"flag"
"os"
Expand All @@ -24,6 +25,8 @@ import (

"github.com/sigstore/model-validation-operator/internal/constants"
"github.com/sigstore/model-validation-operator/internal/controller"
"github.com/sigstore/model-validation-operator/internal/metrics"
"github.com/sigstore/model-validation-operator/internal/servicemonitor"
"github.com/sigstore/model-validation-operator/internal/tracker"
"github.com/sigstore/model-validation-operator/internal/utils"
"github.com/sigstore/model-validation-operator/internal/webhooks"
Expand All @@ -33,6 +36,7 @@ import (
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"

monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
Expand Down Expand Up @@ -67,6 +71,7 @@ func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))

utilruntime.Must(mlv1alpha1.AddToScheme(scheme))
utilruntime.Must(monitoringv1.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
}

Expand All @@ -81,6 +86,7 @@ func main() {
var enableHTTP2 bool
var disableWebhook bool
var forceLegacySidecar bool
var enableServiceMonitor bool
var tlsOpts []func(*tls.Config)

// Status tracker configuration
Expand Down Expand Up @@ -117,6 +123,9 @@ func main() {
"VALIDATION_AGENT_IMAGE",
constants.ModelValidationAgentImage,
"Validation agent image to be used.")
utils.BoolFlagOrEnv(&enableServiceMonitor, "enable-service-monitor",
"ENABLE_SERVICE_MONITOR", false,
"Automatically create a Prometheus ServiceMonitor for the operator metrics endpoint.")

// Status tracker configuration flags
flag.DurationVar(&debounceDuration, "debounce-duration", defaultDebounceDuration,
Expand All @@ -139,6 +148,17 @@ func main() {

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

otelShutdown, err := metrics.SetupOTelMetrics()
if err != nil {
setupLog.Error(err, "unable to set up OTel metrics")
os.Exit(1)
}
defer func() {
if err := otelShutdown(context.Background()); err != nil {
setupLog.Error(err, "error shutting down OTel metrics")
}
}()

// if the enable-http2 flag is false (the default), http/2 should be disabled
// due to its vulnerabilities. More specifically, disabling http/2 will
// prevent from being vulnerable to the HTTP/2 Stream Cancellation and
Expand Down Expand Up @@ -275,6 +295,19 @@ func main() {
}
}

if enableServiceMonitor {
smCreator := servicemonitor.NewCreator(mgr.GetClient(), mgr.GetConfig(), servicemonitor.Options{
Namespace: os.Getenv("POD_NAMESPACE"),
PortName: "https",
Path: "/metrics",
Secure: secureMetrics,
})
if err := mgr.Add(smCreator); err != nil {
setupLog.Error(err, "unable to add ServiceMonitor creator")
os.Exit(1)
}
}

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
setupLog.Error(err, "unable to set up health check")
os.Exit(1)
Expand Down
24 changes: 24 additions & 0 deletions config/components/service-monitor/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component

# This component enables automatic ServiceMonitor creation for Prometheus/OpenShift.
# It adds the --enable-service-monitor flag and POD_NAMESPACE env var to the controller manager,
# and grants RBAC for managing ServiceMonitor resources.
patches:
- target:
kind: Deployment
name: controller-manager
patch: |-
- op: add
path: /spec/template/spec/containers/0/args/-
value: --enable-service-monitor
- op: add
path: /spec/template/spec/containers/0/env
value:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace

resources:
- servicemonitor_rbac.yaml
29 changes: 29 additions & 0 deletions config/components/service-monitor/servicemonitor_rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: servicemonitor-manager-role
rules:
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
verbs:
- get
- list
- watch
- create
- update
- delete
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: servicemonitor-manager-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: servicemonitor-manager-role
subjects:
- kind: ServiceAccount
name: controller-manager
namespace: system
11 changes: 11 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,14 @@ rules:
- telemetryconfigs/status
verbs:
- update
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
verbs:
- create
- delete
- get
- list
- update
- watch
15 changes: 10 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ require (
github.com/go-logr/logr v1.4.3
github.com/onsi/ginkgo/v2 v2.29.0
github.com/onsi/gomega v1.40.0
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.79.2
github.com/prometheus/client_golang v1.23.2
github.com/prometheus/client_model v0.6.2
github.com/prometheus/common v0.67.5
github.com/sigstore/model-signing v0.0.0-00010101000000-000000000000
github.com/sigstore/model-validation-operator/pkg/tracing v0.0.0
github.com/stretchr/testify v1.11.1
go.opentelemetry.io/otel v1.43.0
go.opentelemetry.io/otel/trace v1.43.0
go.opentelemetry.io/otel v1.44.0
go.opentelemetry.io/otel/exporters/prometheus v0.60.0
go.opentelemetry.io/otel/metric v1.44.0
go.opentelemetry.io/otel/sdk/metric v1.44.0
go.opentelemetry.io/otel/trace v1.44.0
golang.org/x/time v0.15.0
k8s.io/api v0.35.3
k8s.io/apimachinery v0.35.3
Expand Down Expand Up @@ -82,6 +86,7 @@ require (
github.com/google/go-containerregistry v0.21.1 // indirect
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7 // indirect
github.com/in-toto/attestation v1.1.2 // indirect
github.com/in-toto/in-toto-golang v0.11.0 // indirect
Expand All @@ -94,7 +99,8 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/procfs v0.17.0 // indirect
github.com/prometheus/otlptranslator v0.0.2 // indirect
github.com/prometheus/procfs v0.20.1 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.10.0 // indirect
github.com/shibumi/go-pathspec v1.3.0 // indirect
github.com/sigstore/protobuf-specs v0.5.0 // indirect
Expand All @@ -114,8 +120,7 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.43.0 // indirect
go.opentelemetry.io/otel/metric v1.43.0 // indirect
go.opentelemetry.io/otel/sdk v1.43.0 // indirect
go.opentelemetry.io/otel/sdk v1.44.0 // indirect
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.28.0 // indirect
Expand Down
34 changes: 22 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ github.com/googleapis/enterprise-certificate-proxy v0.3.15 h1:xolVQTEXusUcAA5Ugt
github.com/googleapis/enterprise-certificate-proxy v0.3.15/go.mod h1:vqVt9yG9480NtzREnTlmGSBmFrA+bzb0yl0TxoBQXOg=
github.com/googleapis/gax-go/v2 v2.22.0 h1:PjIWBpgGIVKGoCXuiCoP64altEJCj3/Ei+kSU5vlZD4=
github.com/googleapis/gax-go/v2 v2.22.0/go.mod h1:irWBbALSr0Sk3qlqb9SyJ1h68WjgeFuiOzI4Rqw5+aY=
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc h1:GN2Lv3MGO7AS6PrRoT6yV5+wkrOpcszoIsO4+4ds248=
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc/go.mod h1:+JKpmjMGhpgPL+rXZ5nsZieVzvarn86asRlBg4uNGnk=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7 h1:X+2YciYSxvMQK0UZ7sg45ZVabVZBeBuvMkmuI2V3Fak=
Expand Down Expand Up @@ -317,14 +319,18 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.79.2 h1:DGv150w4UyxnjNHlkCw85R3+lspOxegtdnbpP2vKRrk=
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.79.2/go.mod h1:AVMP4QEW8xuGWnxaWSpI3kKjP9fDA31nO68zsyREJZA=
github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4=
github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw=
github.com/prometheus/procfs v0.17.0 h1:FuLQ+05u4ZI+SS/w9+BWEM2TXiHKsUQ9TADiRH7DuK0=
github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw=
github.com/prometheus/otlptranslator v0.0.2 h1:+1CdeLVrRQ6Psmhnobldo0kTp96Rj80DRXRd5OSnMEQ=
github.com/prometheus/otlptranslator v0.0.2/go.mod h1:P8AwMgdD7XEr6QRUJ2QWLpiAZTgTE2UYgjlu3svompI=
github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc=
github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down Expand Up @@ -411,22 +417,26 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.6
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.67.0/go.mod h1:NoUCKYWK+3ecatC4HjkRktREheMeEtrXoQxrqYFeHSc=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.67.0 h1:OyrsyzuttWTSur2qN/Lm0m2a8yqyIjUVBZcxFPuXq2o=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.67.0/go.mod h1:C2NGBr+kAB4bk3xtMXfZ94gqFDtg/GkI7e9zqGh5Beg=
go.opentelemetry.io/otel v1.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I=
go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0=
go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU=
go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0 h1:QKdN8ly8zEMrByybbQgv8cWBcdAarwmIPZ6FThrWXJs=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0/go.mod h1:bTdK1nhqF76qiPoCCdyFIV+N/sRHYXYCTQc+3VCi3MI=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0 h1:tgJ0uaNS4c98WRNUEx5U3aDlrDOI5Rs+1Vifcw4DJ8U=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.34.0/go.mod h1:U7HYyW0zt/a9x5J1Kjs+r1f/d4ZHnYFclhYY2+YbeoE=
go.opentelemetry.io/otel/exporters/prometheus v0.60.0 h1:cGtQxGvZbnrWdC2GyjZi0PDKVSLWP/Jocix3QWfXtbo=
go.opentelemetry.io/otel/exporters/prometheus v0.60.0/go.mod h1:hkd1EekxNo69PTV4OWFGZcKQiIqg0RfuWExcPKFvepk=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.43.0 h1:mS47AX77OtFfKG4vtp+84kuGSFZHTyxtXIN269vChY0=
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.43.0/go.mod h1:PJnsC41lAGncJlPUniSwM81gc80GkgWJWr3cu2nKEtU=
go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM=
go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY=
go.opentelemetry.io/otel/sdk v1.43.0 h1:pi5mE86i5rTeLXqoF/hhiBtUNcrAGHLKQdhg4h4V9Dg=
go.opentelemetry.io/otel/sdk v1.43.0/go.mod h1:P+IkVU3iWukmiit/Yf9AWvpyRDlUeBaRg6Y+C58QHzg=
go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfCGLEo89fDkw=
go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A=
go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A=
go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc=
go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo=
go.opentelemetry.io/otel/metric/x v0.66.0 h1:YkCrx1zLOChi9ZcZ6euupOcsgzbVlec7D/xoEU1+cTA=
go.opentelemetry.io/otel/metric/x v0.66.0/go.mod h1:d1+BDj9t96do0/1LoU1ayfCv79ZgNE41qbhBvnMOBZk=
go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58=
go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0=
go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI=
go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA=
go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk=
go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE=
go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A=
go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4=
go.step.sm/crypto v0.81.0 h1:e+ouzpNt3Xm4dp7HGXhgYB5y4iFik3vh3phHKWmvugU=
Expand Down
22 changes: 22 additions & 0 deletions internal/controller/helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2025 The Sigstore Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package controller

func reconcileResult(err error) string {
if err != nil {
return "error"
}
return "success"
}
9 changes: 8 additions & 1 deletion internal/controller/modelvalidation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package controller

import (
"context"
"time"

"github.com/sigstore/model-validation-operator/api/v1alpha1"
"github.com/sigstore/model-validation-operator/internal/metrics"
"github.com/sigstore/model-validation-operator/internal/tracker"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -25,7 +27,12 @@ type ModelValidationReconciler struct {
// +kubebuilder:rbac:groups=ml.sigstore.dev,resources=modelvalidations/status,verbs=update

// Reconcile handles ModelValidation events to track creation/updates/deletion
func (r *ModelValidationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
func (r *ModelValidationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err error) {
start := time.Now()
defer func() {
metrics.RecordReconcile(ctx, "modelvalidation", reconcileResult(err), time.Since(start))
}()

logger := log.FromContext(ctx)

mv := &v1alpha1.ModelValidation{}
Expand Down
9 changes: 8 additions & 1 deletion internal/controller/pod_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package controller

import (
"context"
"time"

"github.com/sigstore/model-validation-operator/internal/constants"
"github.com/sigstore/model-validation-operator/internal/metrics"
"github.com/sigstore/model-validation-operator/internal/tracker"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -29,7 +31,12 @@ type PodReconciler struct {
// +kubebuilder:rbac:groups=ml.sigstore.dev,resources=modelvalidations/status,verbs=update

// Reconcile handles pod events to update ModelValidation status
func (r *PodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
func (r *PodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err error) {
start := time.Now()
defer func() {
metrics.RecordReconcile(ctx, "pod", reconcileResult(err), time.Since(start))
}()

logger := log.FromContext(ctx)

pod := &corev1.Pod{}
Expand Down
8 changes: 7 additions & 1 deletion internal/controller/telemetryconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"time"

"github.com/sigstore/model-validation-operator/api/v1alpha1"
"github.com/sigstore/model-validation-operator/internal/metrics"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -43,7 +44,12 @@
// +kubebuilder:rbac:groups=ml.sigstore.dev,resources=modelvalidations,verbs=get;list;watch

// Reconcile evaluates selectors and updates matched counts in status.
func (r *TelemetryConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
func (r *TelemetryConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err error) {
start := time.Now()
defer func() {
metrics.RecordReconcile(ctx, "telemetryconfig", reconcileResult(err), time.Since(start))
}()

logger := log.FromContext(ctx)

tc := &v1alpha1.TelemetryConfig{}
Expand Down Expand Up @@ -96,7 +102,7 @@
return reconcile.Result{}, nil
}

func (r *TelemetryConfigReconciler) countMatchedNamespaces(ctx context.Context, tc *v1alpha1.TelemetryConfig) (int32, error) {

Check failure on line 105 in internal/controller/telemetryconfig_controller.go

View workflow job for this annotation

GitHub Actions / Run Linting

The line is 126 characters long, which exceeds the maximum of 120 characters. (lll)
var nsList corev1.NamespaceList
if err := r.List(ctx, &nsList); err != nil {
return 0, err
Expand All @@ -120,7 +126,7 @@
return count, nil
}

func (r *TelemetryConfigReconciler) countMatchedModelValidations(ctx context.Context, tc *v1alpha1.TelemetryConfig) (int32, error) {

Check failure on line 129 in internal/controller/telemetryconfig_controller.go

View workflow job for this annotation

GitHub Actions / Run Linting

The line is 132 characters long, which exceeds the maximum of 120 characters. (lll)
var mvList v1alpha1.ModelValidationList
if err := r.List(ctx, &mvList); err != nil {
return 0, err
Expand Down Expand Up @@ -166,7 +172,7 @@

// mapNamespaceToTelemetryConfigs re-enqueues all TelemetryConfigs when a namespace changes,
// since namespace label changes could affect selector matching.
func (r *TelemetryConfigReconciler) mapNamespaceToTelemetryConfigs(ctx context.Context, _ client.Object) []reconcile.Request {

Check failure on line 175 in internal/controller/telemetryconfig_controller.go

View workflow job for this annotation

GitHub Actions / Run Linting

The line is 126 characters long, which exceeds the maximum of 120 characters. (lll)
var tcList v1alpha1.TelemetryConfigList
if err := r.List(ctx, &tcList); err != nil {
return nil
Expand All @@ -183,7 +189,7 @@

// mapModelValidationToTelemetryConfigs re-enqueues all TelemetryConfigs when a ModelValidation changes,
// since MV label changes could affect selector matching.
func (r *TelemetryConfigReconciler) mapModelValidationToTelemetryConfigs(ctx context.Context, _ client.Object) []reconcile.Request {

Check failure on line 192 in internal/controller/telemetryconfig_controller.go

View workflow job for this annotation

GitHub Actions / Run Linting

The line is 132 characters long, which exceeds the maximum of 120 characters. (lll)
var tcList v1alpha1.TelemetryConfigList
if err := r.List(ctx, &tcList); err != nil {
return nil
Expand Down
Loading
Loading