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
11 changes: 5 additions & 6 deletions apps/druid/core/services/runtime_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,14 @@ func uiPublishCommand() *domain.CommandInstructionSet {
WorkingDir: "/app/resources/deployment",
Mounts: []domain.Mount{{Path: "/app/resources/deployment", SubPath: ".", ReadOnly: true}},
Command: []string{"sh", "-ec", `
source="${DRUID_UI_SOURCE:?DRUID_UI_SOURCE is required}"
upload_url="${DRUID_UI_UPLOAD_URL:?DRUID_UI_UPLOAD_URL is required}"
case "$source" in private/*.wasm|public/*.wasm) ;; *) echo "invalid UI package path" >&2; exit 1;; esac
test -f "$source" && test -s "$source"
test -n "$(printenv DRUID_UI_SOURCE)" && test -n "$(printenv DRUID_UI_UPLOAD_URL)"
case "$(printenv DRUID_UI_SOURCE)" in private/*.wasm|public/*.wasm) ;; *) echo "invalid UI package path" >&2; exit 1;; esac
test -f "$(printenv DRUID_UI_SOURCE)" && test -s "$(printenv DRUID_UI_SOURCE)"
echo "Uploading Druid UI package"
curl --fail-with-body --silent --show-error --request PUT --upload-file "$source" \
curl --fail-with-body --silent --show-error --request PUT --upload-file "$(printenv DRUID_UI_SOURCE)" \
--header "Content-Type: application/wasm" \
--header "Cache-Control: public, max-age=31536000, immutable" \
"$upload_url"
"$(printenv DRUID_UI_UPLOAD_URL)"
`},
}},
}
Expand Down
3 changes: 3 additions & 0 deletions apps/druid/core/services/runtime_ui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ func TestPublishUIPackageRunsOneShotCommandWithEphemeralURL(t *testing.T) {
t.Fatalf("procedure env = %#v", values)
}
script := command.Command.Procedures[0].Command[len(command.Command.Procedures[0].Command)-1]
if !strings.Contains(script, "$(printenv DRUID_UI_SOURCE)") || !strings.Contains(script, "$(printenv DRUID_UI_UPLOAD_URL)") {
t.Fatalf("publish command lost request-scoped environment references: %q", script)
}
if strings.Contains(script, "sha256") || strings.Contains(script, "content_md5") || strings.Contains(script, "prepare_url") {
t.Fatal("publish command must upload directly without digest negotiation")
}
Expand Down
24 changes: 2 additions & 22 deletions internal/runtime/kubernetes/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ func TestWaitForJobReportsPodFailureReason(t *testing.T) {
}
}

func TestWaitForJobImmediatelyReportsUnschedulablePod(t *testing.T) {
func TestJobStartupFailureDoesNotReportUnschedulablePod(t *testing.T) {
job := &batchv1.Job{ObjectMeta: metav1.ObjectMeta{Name: "unschedulable", Namespace: "druid"}}
pod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{Name: "unschedulable-pod", Namespace: "druid", Labels: map[string]string{"job-name": job.Name}},
Expand All @@ -770,28 +770,8 @@ func TestWaitForJobImmediatelyReportsUnschedulablePod(t *testing.T) {
}
backend := NewWithClient(Config{Namespace: "druid"}, fake.NewSimpleClientset(job, pod))

exitCode, err := backend.waitForJob(context.Background(), "druid", job.Name)
if err == nil || !strings.Contains(err.Error(), "insufficient memory") {
t.Fatalf("waitForJob error = %v, want unschedulable detail", err)
}
if exitCode == nil || *exitCode != 1 {
t.Fatalf("exitCode = %#v, want 1", exitCode)
}
}

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")
t.Fatal("jobStartupFailure reported unschedulable pod as terminal")
}
}

Expand Down
8 changes: 0 additions & 8 deletions internal/runtime/kubernetes/wait_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,6 @@ func (b *Backend) jobStartupFailure(ctx context.Context, namespace string, jobNa
return 1, "", false
}
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
}
}
for _, status := range pod.Status.InitContainerStatuses {
if status.State.Terminated != nil && !includeTerminated {
continue
Expand Down
Loading