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

clean up metrics of deleted objects #2230

Merged
merged 1 commit into from
May 13, 2022
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
2 changes: 1 addition & 1 deletion pkg/scheduler/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ func (sc *SchedulerCache) processCleanupJob() {

if schedulingapi.JobTerminated(job) {
delete(sc.Jobs, job.UID)
metrics.DeleteJobShare(job.Namespace, job.Name)
metrics.DeleteJobMetrics(job.Name, string(job.Queue), job.Namespace)
klog.V(3).Infof("Job <%v:%v/%v> was deleted.", job.UID, job.Namespace, job.Name)
} else {
// Retry
Expand Down
6 changes: 5 additions & 1 deletion pkg/scheduler/cache/event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
schedulingv1beta1 "volcano.sh/apis/pkg/apis/scheduling/v1beta1"
"volcano.sh/apis/pkg/apis/utils"
schedulingapi "volcano.sh/volcano/pkg/scheduler/api"
"volcano.sh/volcano/pkg/scheduler/metrics"
)

func isTerminated(status schedulingapi.TaskStatus) bool {
Expand Down Expand Up @@ -613,7 +614,10 @@ func (sc *SchedulerCache) updateQueue(queue *scheduling.Queue) {
}

func (sc *SchedulerCache) deleteQueue(id schedulingapi.QueueID) {
delete(sc.Queues, id)
if queue, ok := sc.Queues[id]; ok {
delete(sc.Queues, id)
metrics.DeleteQueueMetrics(queue.Name)
}
}

//DeletePriorityClass delete priorityclass from the scheduler cache
Expand Down
13 changes: 8 additions & 5 deletions pkg/scheduler/metrics/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ func UpdateJobShare(jobNs, jobID string, share float64) {
jobShare.WithLabelValues(jobNs, jobID).Set(share)
}

// DeleteJobShare delete jobShare for one job
func DeleteJobShare(jobNs, jobID string) {
jobShare.DeleteLabelValues(jobNs, jobID)
}

// RegisterJobRetries total number of job retries.
func RegisterJobRetries(jobID string) {
jobRetryCount.WithLabelValues(jobID).Inc()
}

// DeleteJobMetrics delete all metrics related to the job
func DeleteJobMetrics(jobName, queue, namespace string) {
e2eJobSchedulingDuration.DeleteLabelValues(jobName, queue, namespace)
unscheduleTaskCount.DeleteLabelValues(jobName)
jobShare.DeleteLabelValues(namespace, jobName)
jobRetryCount.DeleteLabelValues(jobName)
}
17 changes: 17 additions & 0 deletions pkg/scheduler/metrics/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,20 @@ func UpdateQueuePodGroupRunningCount(queueName string, count int32) {
func UpdateQueuePodGroupUnknownCount(queueName string, count int32) {
queuePodGroupUnknown.WithLabelValues(queueName).Set(float64(count))
}

// DeleteQueueMetrics delete all metrics related to the queue
func DeleteQueueMetrics(queueName string) {
queueAllocatedMilliCPU.DeleteLabelValues(queueName)
queueAllocatedMemory.DeleteLabelValues(queueName)
queueRequestMilliCPU.DeleteLabelValues(queueName)
queueRequestMemory.DeleteLabelValues(queueName)
queueDeservedMilliCPU.DeleteLabelValues(queueName)
queueDeservedMemory.DeleteLabelValues(queueName)
queueShare.DeleteLabelValues(queueName)
queueWeight.DeleteLabelValues(queueName)
queueOverused.DeleteLabelValues(queueName)
queuePodGroupInqueue.DeleteLabelValues(queueName)
queuePodGroupPending.DeleteLabelValues(queueName)
queuePodGroupRunning.DeleteLabelValues(queueName)
queuePodGroupUnknown.DeleteLabelValues(queueName)
}