Repository navigation
feat: add Trainer control-plane metrics - #4190
abhijeet-dhumal wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
robert-bell
left a comment
There was a problem hiding this comment.
Thanks @abhijeet-dhumal! I've left some inline feedback.
71adb35 to
9b58b90
Compare
|
Thanks @robert-bell .. I’ve tried to address the metric scope and test coverage updates. |
683d2ac to
c2a4081
Compare
c5c77ce to
39dfacb
Compare
robert-bell
left a comment
There was a problem hiding this comment.
Thanks @abhijeet-dhumal this is looking good! I've left a few minor suggestions but this is looking pretty close.
robert-bell
left a comment
There was a problem hiding this comment.
@abhijeet-dhumal I ran the new PR review skill over this - can you check if these any of these comments are valid?
1ad4f92 to
0f47c2d
Compare
andreyvelich
left a comment
There was a problem hiding this comment.
Thanks @abhijeet-dhumal for the work on this! Review done using AI tools; inline comments below.
Signed-off-by: abhijeet-dhumal <abhijeetdhumal652@gmail.com>
db98949 to
0bebcf4
Compare
|
/milestone v2.4 |
robert-bell
left a comment
There was a problem hiding this comment.
Thanks @abhijeet-dhumal this is looking pretty close!
| return fmt.Errorf("wait for TrainJob metrics observer: %w", err) | ||
| } | ||
| m.ready.Store(true) | ||
| <-ctx.Done() |
There was a problem hiding this comment.
Can we log that the instrumentation has been configured correctly?
| <-ctx.Done() | |
| m.log.Info("trainer-metrics instrumentation ready") | |
| <-ctx.Done() |
| return fmt.Errorf("wait for runtime metrics observers: %w", err) | ||
| } | ||
| c.ready.Store(true) | ||
| <-ctx.Done() |
There was a problem hiding this comment.
Same here - can we log that the instrumentation has been configured correctly?
| <-ctx.Done() | |
| c.log.Info("runtime-metrics instrumentation ready") | |
| <-ctx.Done() |
| } | ||
| defer func() { | ||
| if removeErr := clusterInformer.RemoveEventHandler(clusterRegistration); removeErr != nil { | ||
| ctrl.Log.WithName("trainer-metrics").Error(removeErr, "failed to remove ClusterTrainingRuntime metrics observer") |
There was a problem hiding this comment.
nit: can we move this logger into the runtimeInfoCollector and use a different name?
return &runtimeInfoCollector{
cache: c,
log: ctrl.Log.WithName("runtime-metrics-collector")
snapshot: make(map[string]runtimeInfo),
}| } | ||
| defer func() { | ||
| if removeErr := trainingInformer.RemoveEventHandler(trainingRegistration); removeErr != nil { | ||
| ctrl.Log.WithName("trainer-metrics").Error(removeErr, "failed to remove TrainingRuntime metrics observer") |
There was a problem hiding this comment.
nit: same as https://github.com/kubeflow/trainer/pull/4190/changes#r4338364858 - use a logger on the runtimeInfoCollector
What this PR does / why we need it
Adds six upstream Trainer Prometheus metrics for runtime inventory, TrainJob creation, completion, failure, lifetime, and requested training-node counts proposed in #3429:
Metrics are registered only by the elected controller leader and collected from informer-backed snapshots without Kubernetes API calls during scraping. The implementation also handles duplicate terminal events, runtime updates/deletions, and leader transitions.
TLS, authentication, and ServiceMonitor configuration are handled separately by PR #4102.
kubeflow_trainer_runtime_info: current TrainingRuntime and ClusterTrainingRuntime inventory.kubeflow_trainer_trainjob_created_total: TrainJobs observed after the initial informer cache listing.kubeflow_trainer_trainjob_finished_total: terminal outcomes by result, reason, and runtime.kubeflow_trainer_trainjob_lifetime_seconds: time from TrainJob creation to terminal state.kubeflow_trainer_trainjob_requested_training_nodes_per_job: requested training-node size.The controller uses its existing informer caches instead of calling the Kubernetes API during metric collection. Runtime information is kept in an in-memory snapshot and reused when processing TrainJobs.
Only the elected controller leader processes metric events and registers the Trainer metrics. When leadership changes, the old leader removes its metrics and the new leader registers them. This prevents duplicate metrics from multiple controller replicas.
The implementation also:
Validation
go vet ./pkg/metrics/...git diff --check.Follow-up
Final CI, documentation build, approver review, and cluster E2E validation remain required before merge.
Checklist