Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metric to count SA cache misses #246

Merged
merged 1 commit into from
Nov 19, 2024
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
1 change: 1 addition & 0 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ func (m *Modifier) MutatePod(ar *v1beta1.AdmissionReview) *v1beta1.AdmissionResp

patchConfig := m.buildPodPatchConfig(&pod)
if patchConfig == nil {
missingSACounter.WithLabelValues().Inc()
klog.V(4).Infof("Pod was not mutated. Reason: "+
"Service account did not have the right annotations or was not found in the cache. %s", logContext(pod.Name, pod.GenerateName, pod.Spec.ServiceAccountName, pod.Namespace))
return &v1beta1.AdmissionResponse{
Expand Down
8 changes: 8 additions & 0 deletions pkg/handler/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,21 @@ var (
Help: "Indicator to how many pods are using sts web identity or container credentials",
}, []string{"method"},
)
missingSACounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "pod_identity_webhook_missing_sa_count",
Help: "Service account did not have the right annotations or was not found in the cache.",
},
[]string{},
)
)

func register() {
prometheus.MustRegister(requestCounter)
prometheus.MustRegister(requestLatencies)
prometheus.MustRegister(requestLatenciesSummary)
prometheus.MustRegister(webhookPodCount)
prometheus.MustRegister(missingSACounter)
}

func monitor(verb, path string, httpCode int, reqStart time.Time) {
Expand Down
Loading