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
5 changes: 5 additions & 0 deletions src/selfhost/qdrant-vectorize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ function qdrantHeaders(): Record<string, string> {
return h;
}

/** Build the unauthenticated Kubernetes-style readiness endpoint for a configured Qdrant base URL. */
export function qdrantReadyzUrl(url: string): string {
return `${url.replace(/\/+$/, "")}/readyz`;
}

/**
* Ensures the Qdrant collection exists. Safe to call on every startup — a 409 (already exists)
* is silently ignored. Call this before createQdrantVectorize() when QDRANT_URL is set.
Expand Down
4 changes: 2 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ async function main(): Promise<void> {
let vectorizeOverride: Vectorize | undefined;
if (process.env.QDRANT_URL) {
const qdrantUrl = process.env.QDRANT_URL;
const { createQdrantVectorize, initQdrantCollection } =
const { createQdrantVectorize, initQdrantCollection, qdrantReadyzUrl } =
await import("./selfhost/qdrant-vectorize");
// Retry until Qdrant accepts the collection PUT — the container may still be booting when we start.
await retryUntilReady("qdrant", () => initQdrantCollection(qdrantUrl));
Expand All @@ -389,7 +389,7 @@ async function main(): Promise<void> {
name: "qdrant",
check: () =>
withTimeout(
fetch(qdrantUrl, { signal: AbortSignal.timeout(1500) })
fetch(qdrantReadyzUrl(qdrantUrl), { signal: AbortSignal.timeout(1500) })
.then((r) => r.ok)
.catch(() => false),
),
Expand Down
9 changes: 8 additions & 1 deletion test/unit/selfhost-qdrant-vectorize.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
import { createQdrantVectorize, initQdrantCollection } from "../../src/selfhost/qdrant-vectorize";
import { createQdrantVectorize, initQdrantCollection, qdrantReadyzUrl } from "../../src/selfhost/qdrant-vectorize";
import { resetMetrics, renderMetrics } from "../../src/selfhost/metrics";

const BASE = "http://qdrant:6333";
Expand All @@ -9,6 +9,13 @@ function mockFetch(status: number, body: unknown = {}) {
return vi.fn(async () => new Response(JSON.stringify(body), { status }));
}

describe("qdrantReadyzUrl (#1482 regression)", () => {
it("points readiness probes at Qdrant's unauthenticated /readyz endpoint", () => {
expect(qdrantReadyzUrl(BASE)).toBe(`${BASE}/readyz`);
expect(qdrantReadyzUrl(`${BASE}/`)).toBe(`${BASE}/readyz`);
});
});

describe("initQdrantCollection (#1217)", () => {
afterEach(() => { vi.restoreAllMocks(); resetMetrics(); });

Expand Down
Loading