Skip to content
This repository was archived by the owner on Jan 28, 2022. It is now read-only.

Commit a9f0a6f

Browse files
creddy123stuartleeks
authored andcommitted
Changes for requeuing the terminal state jobs
1 parent c9810b3 commit a9f0a6f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

api/v1alpha1/run_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ func (run *Run) IsSubmitted() bool {
6464
return run.Status.Metadata.JobID > 0
6565
}
6666

67+
// IsTerminated return true if item is in terminal state
68+
func (run *Run) IsTerminated() bool {
69+
if run.Status == nil || run.Status.Metadata.State == nil || run.Status.Metadata.State.LifeCycleState == nil {
70+
return false
71+
}
72+
switch *run.Status.Metadata.State.LifeCycleState {
73+
case dbmodels.RunLifeCycleStateTerminated, dbmodels.RunLifeCycleStateSkipped, dbmodels.RunLifeCycleStateInternalError:
74+
return true
75+
}
76+
return false
77+
}
78+
6779
// RunFinalizerName is the name of the run finalizer
6880
const RunFinalizerName = "run.finalizers.databricks.microsoft.com"
6981

controllers/run_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ func (r *RunReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
100100
}
101101
r.Recorder.Event(instance, corev1.EventTypeNormal, "Refreshed", "Object is refreshed")
102102
}
103-
103+
if instance.IsTerminated() {
104+
return ctrl.Result{}, nil
105+
}
104106
return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
105107
}
106108

0 commit comments

Comments
 (0)