Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
Set CreationTimestamp for newly created resource reservations (#262)
Browse files Browse the repository at this point in the history
Set CreationTimestamp for newly created resource reservations
  • Loading branch information
Alexis-D authored Apr 12, 2023
1 parent 7340b7e commit 6d3a279
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions internal/extender/resourcereservations.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,15 @@ func (rrm *defaultResourceReservationManager) bindExecutorToResourceReservation(

// only report the metric the first time the reservation is bound
if _, ok := resourceReservation.Status.Pods[reservationName]; !ok {
// this is the k8s server time, so the duration we're computing only makes sense if clocks are reasonably kept in sync
// this should the k8s server time, but due to the way we cache request/object this might actually be set by k8s-spark-scheduler itself
creationTime := resourceReservation.CreationTimestamp.Time
duration := time.Now().Sub(creationTime)
metrics.ReportTimeToFirstBindMetrics(ctx, duration)

// we haven't observed this in practice, but the docs for CreationTimestamp make it clear that this is optional
// so just to be safe we ignore the zero-value
if !creationTime.IsZero() {
duration := time.Since(creationTime)
metrics.ReportTimeToFirstBindMetrics(ctx, duration)
}
}
return nil
}
Expand Down Expand Up @@ -489,9 +494,10 @@ func newResourceReservation(driverNode string, executorNodes []string, driver *v
}
return &v1beta2.ResourceReservation{
ObjectMeta: metav1.ObjectMeta{
Name: driver.Labels[common.SparkAppIDLabel],
Namespace: driver.Namespace,
OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(driver, podGroupVersionKind)},
Name: driver.Labels[common.SparkAppIDLabel],
Namespace: driver.Namespace,
OwnerReferences: []metav1.OwnerReference{*metav1.NewControllerRef(driver, podGroupVersionKind)},
CreationTimestamp: metav1.Now(),
Labels: map[string]string{
v1beta1.AppIDLabel: driver.Labels[common.SparkAppIDLabel],
},
Expand Down

0 comments on commit 6d3a279

Please sign in to comment.