diff --git a/apps/druid/core/services/runtime_ui.go b/apps/druid/core/services/runtime_ui.go index 92271bb..e54af4f 100644 --- a/apps/druid/core/services/runtime_ui.go +++ b/apps/druid/core/services/runtime_ui.go @@ -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)" `}, }}, } diff --git a/apps/druid/core/services/runtime_ui_test.go b/apps/druid/core/services/runtime_ui_test.go index 08b8768..9064bb8 100644 --- a/apps/druid/core/services/runtime_ui_test.go +++ b/apps/druid/core/services/runtime_ui_test.go @@ -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") } diff --git a/internal/runtime/kubernetes/resources_test.go b/internal/runtime/kubernetes/resources_test.go index 312e959..daf8587 100644 --- a/internal/runtime/kubernetes/resources_test.go +++ b/internal/runtime/kubernetes/resources_test.go @@ -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}}, @@ -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") } } diff --git a/internal/runtime/kubernetes/wait_jobs.go b/internal/runtime/kubernetes/wait_jobs.go index 29d0e29..d82a5bd 100644 --- a/internal/runtime/kubernetes/wait_jobs.go +++ b/internal/runtime/kubernetes/wait_jobs.go @@ -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