Skip to content
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
16 changes: 16 additions & 0 deletions internal/runtime/kubernetes/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,22 @@ func TestWaitForJobImmediatelyReportsUnschedulablePod(t *testing.T) {
}
}

func TestJobStartupFailureWaitsForImmediatePVCBinding(t *testing.T) {
job := &batchv1.Job{ObjectMeta: metav1.ObjectMeta{Name: "pvc-binding", Namespace: "druid"}}
pod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{Name: "pvc-binding-pod", Namespace: "druid", Labels: map[string]string{"job-name": job.Name}},
Status: corev1.PodStatus{Conditions: []corev1.PodCondition{{
Type: corev1.PodScheduled, Status: corev1.ConditionFalse, Reason: corev1.PodReasonUnschedulable,
Message: "0/3 nodes are available: pod has unbound immediate PersistentVolumeClaims",
}}},
}
backend := NewWithClient(Config{Namespace: "druid"}, fake.NewSimpleClientset(job, pod))

if _, _, failed := backend.jobStartupFailure(context.Background(), "druid", job.Name, false); failed {
t.Fatal("jobStartupFailure reported transient PVC binding as terminal")
}
}

func TestWaitForJobUsesRecentSuccessfulDeletion(t *testing.T) {
backend := NewWithClient(Config{Namespace: "druid"}, fake.NewSimpleClientset())
backend.recordJobExit("druid", "finished", 0)
Expand Down
3 changes: 3 additions & 0 deletions internal/runtime/kubernetes/wait_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ func (b *Backend) jobStartupFailure(ctx context.Context, namespace string, jobNa
for _, pod := range pods.Items {
for _, condition := range pod.Status.Conditions {
if condition.Type == corev1.PodScheduled && condition.Status == corev1.ConditionFalse && condition.Reason == corev1.PodReasonUnschedulable {
if strings.Contains(condition.Message, "unbound immediate PersistentVolumeClaims") {
continue
}
return 1, fmt.Sprintf("pod %s is unschedulable: %s", pod.Name, condition.Message), true
}
}
Expand Down
Loading