Add REDSKY_JOB_START_DELAY environment variable
@@ -18,6 +18,8 @@ package controllers
import (
"context"
+ "os"
+ "strconv"
"time"
"github.com/go-logr/logr"
@@ -67,10 +69,12 @@ func (r *TrialJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
// Create a new job if necessary
if len(jobList.Items) == 0 {
- // TODO Remove this once we know why it is actually needed (if it is needed)
+ // TODO Remove this once we have more flexible configuration of the wait controller
+ if jobStartDelay, err := strconv.ParseInt(os.Getenv("REDSKY_JOB_START_DELAY"), 10, 64); err == nil {
for _, c := range t.Status.Conditions {
- if c.Type == redskyv1alpha1.TrialStable && c.LastTransitionTime.Add(1*time.Second).After(now.Time) {
- return ctrl.Result{RequeueAfter: 1 * time.Second}, nil
+ if c.Type == redskyv1alpha1.TrialStable && c.LastTransitionTime.Add(time.Duration(jobStartDelay)*time.Second).After(now.Time) {
+ return ctrl.Result{RequeueAfter: now.Time.Sub(c.LastTransitionTime.Time)}, nil
+ }
}
}
