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

To record the start and end time of job scheduling #2318

Merged
merged 2 commits into from
Jul 5, 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
4 changes: 4 additions & 0 deletions pkg/scheduler/actions/allocate/allocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package allocate

import (
"time"

"k8s.io/klog"

"volcano.sh/volcano/pkg/scheduler/api"
Expand Down Expand Up @@ -225,6 +227,7 @@ func (alloc *Action) Execute(ssn *framework.Session) {
task.UID, node.Name, ssn.UID, err)
} else {
metrics.UpdateE2eSchedulingDurationByJob(job.Name, string(job.Queue), job.Namespace, metrics.Duration(job.CreationTimestamp.Time))
metrics.UpdateE2eSchedulingLastTimeByJob(job.Name, string(job.Queue), job.Namespace, time.Now())
}
} else {
klog.V(3).Infof("Predicates failed for task <%s/%s> on node <%s> with limited resources",
Expand All @@ -239,6 +242,7 @@ func (alloc *Action) Execute(ssn *framework.Session) {
task.UID, node.Name, ssn.UID, err)
} else {
metrics.UpdateE2eSchedulingDurationByJob(job.Name, string(job.Queue), job.Namespace, metrics.Duration(job.CreationTimestamp.Time))
metrics.UpdateE2eSchedulingLastTimeByJob(job.Name, string(job.Queue), job.Namespace, time.Now())
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/scheduler/actions/backfill/backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package backfill

import (
"time"

"k8s.io/klog"

"volcano.sh/volcano/pkg/scheduler/api"
Expand Down Expand Up @@ -76,6 +78,7 @@ func (backfill *Action) Execute(ssn *framework.Session) {
}

metrics.UpdateE2eSchedulingDurationByJob(job.Name, string(job.Queue), job.Namespace, metrics.Duration(job.CreationTimestamp.Time))
metrics.UpdateE2eSchedulingLastTimeByJob(job.Name, string(job.Queue), job.Namespace, time.Now())
allocated = true
break
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/scheduler/cache/event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ func (sc *SchedulerCache) setPodGroup(ss *schedulingapi.PodGroup) error {
sc.Jobs[job].Queue = schedulingapi.QueueID(sc.defaultQueue)
}

metrics.UpdateE2eSchedulingStartTimeByJob(sc.Jobs[job].Name, string(sc.Jobs[job].Queue), sc.Jobs[job].Namespace,
sc.Jobs[job].CreationTimestamp.Time)
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/scheduler/metrics/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func RegisterJobRetries(jobID string) {
// DeleteJobMetrics delete all metrics related to the job
func DeleteJobMetrics(jobName, queue, namespace string) {
e2eJobSchedulingDuration.DeleteLabelValues(jobName, queue, namespace)
e2eJobSchedulingStartTime.DeleteLabelValues(jobName, queue, namespace)
e2eJobSchedulingLastTime.DeleteLabelValues(jobName, queue, namespace)
unscheduleTaskCount.DeleteLabelValues(jobName)
jobShare.DeleteLabelValues(namespace, jobName)
jobRetryCount.DeleteLabelValues(jobName)
Expand Down
33 changes: 33 additions & 0 deletions pkg/scheduler/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ var (
[]string{"job_name", "queue", "job_namespace"},
)

e2eJobSchedulingStartTime = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Subsystem: VolcanoNamespace,
Name: "e2e_job_scheduling_start_time",
Help: "E2E job scheduling start time",
},
[]string{"job_name", "queue", "job_namespace"},
)

e2eJobSchedulingLastTime = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Subsystem: VolcanoNamespace,
Name: "e2e_job_scheduling_last_time",
Help: "E2E job scheduling last time",
},
[]string{"job_name", "queue", "job_namespace"},
)

dontan001 marked this conversation as resolved.
Show resolved Hide resolved
pluginSchedulingLatency = promauto.NewHistogramVec(
prometheus.HistogramOpts{
Subsystem: VolcanoNamespace,
Expand Down Expand Up @@ -151,6 +169,16 @@ func UpdateE2eSchedulingDurationByJob(jobName string, queue string, namespace st
e2eJobSchedulingLatency.Observe(DurationInMilliseconds(duration))
}

// UpdateE2eSchedulingStartTimeByJob updates the start time of scheduling
func UpdateE2eSchedulingStartTimeByJob(jobName string, queue string, namespace string, t time.Time) {
e2eJobSchedulingStartTime.WithLabelValues(jobName, queue, namespace).Set(ConvertToUnix(t))
}

// UpdateE2eSchedulingLastTimeByJob updates the last time of scheduling
func UpdateE2eSchedulingLastTimeByJob(jobName string, queue string, namespace string, t time.Time) {
e2eJobSchedulingLastTime.WithLabelValues(jobName, queue, namespace).Set(ConvertToUnix(t))
}

// UpdateTaskScheduleDuration updates single task scheduling latency
func UpdateTaskScheduleDuration(duration time.Duration) {
taskSchedulingLatency.Observe(DurationInMilliseconds(duration))
Expand Down Expand Up @@ -200,3 +228,8 @@ func DurationInSeconds(duration time.Duration) float64 {
func Duration(start time.Time) time.Duration {
return time.Since(start)
}

// ConvertToUnix convert the time to Unix time
func ConvertToUnix(t time.Time) float64 {
return float64(t.Unix())
}