Skip to content

Commit b2c9fce

Browse files
authored
feat: implement vector store (qdrant) cluster ping action (#193)
## Description <!-- Please add PR description (don't leave blank) - example: This PR [adds/removes/fixes/replaces] the [feature/bug/etc] --> This pull request introduces an automated health check for the Qdrant vector store cluster to help keep it active and prevent deletion due to inactivity. The main changes include adding a scheduled GitHub Actions workflow to ping the cluster, implementing a new Node.js script for connectivity and collection checks, and updating the `package.json` scripts to support manual execution. ### Changes Made - Created `dev/ping-qdrant-cluster.js`, a Node.js utility that checks cluster connectivity and verifies the existence of the `dictionary` collection, providing clear logging and error hints. - Updated `package.json` to add a new `ping:qdrant` npm script for running the cluster ping locally or in CI. - Added `.github/workflows/ping-qdrant.yml` to schedule a weekly workflow and allow manual runs for pinging the Qdrant cluster, ensuring regular activity and easier testing. ## Related Issue <!-- Please prefix the issue number with Fixes/Resolves - example: Fixes #123 or Resolves #123 --> Fixes #192 ## Screenshots/Screencasts <!-- Please provide screenshots or video recording that demos your changes (especially if it's a visual change) --> NA ## Notes to Reviewer <!-- Please state here if you added a new npm packages, or any extra information that can help reviewer better review you changes --> - Added new GitHub Actions workflow
1 parent aa6fc5f commit b2c9fce

3 files changed

Lines changed: 112 additions & 1 deletion

File tree

.github/workflows/ping-qdrant.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Ping Vector Store (Qdrant) Cluster
2+
3+
on:
4+
# Run weekly on Sundays at 2 AM UTC to keep the cluster active
5+
schedule:
6+
- cron: "0 2 * * 0"
7+
8+
# Allow manual triggering for testing
9+
workflow_dispatch:
10+
11+
jobs:
12+
ping-cluster:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: "20"
23+
cache: "npm"
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Ping Qdrant cluster
29+
env:
30+
QDRANT_URL: ${{ secrets.QDRANT_URL }}
31+
QDRANT_API_KEY: ${{ secrets.QDRANT_API_KEY }}
32+
run: npm run ping:qdrant
33+
34+
- name: Ping successful
35+
run: echo "✅ Qdrant cluster ping completed successfully"

dev/ping-qdrant-cluster.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* Vector Store (Qdrant) Cluster Ping Utility
3+
*
4+
* This script performs a lightweight health check on the Vector Store (Qdrant) cluster
5+
* by checking the existence of the 'dictionary' collection.
6+
*
7+
* This keeps the cluster active and prevents automatic deletion due to inactivity.
8+
*/
9+
const QDRANT_URL = process.env.QDRANT_URL;
10+
const QDRANT_API_KEY = process.env.QDRANT_API_KEY;
11+
const COLLECTION_NAME = "dictionary";
12+
13+
console.log("🚀 Starting Vector Store (Qdrant) cluster ping...");
14+
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
15+
16+
try {
17+
console.log("🔍 Checking Vector Store (Qdrant) cluster connectivity...");
18+
19+
// Test basic cluster connection
20+
const healthResponse = await fetch(QDRANT_URL, {
21+
headers: {
22+
'api-key': QDRANT_API_KEY
23+
}
24+
});
25+
26+
if (!healthResponse.ok) {
27+
throw new Error(`Health check failed: ${healthResponse.status} ${healthResponse.statusText}`);
28+
}
29+
30+
console.log("✅ Cluster is accessible");
31+
32+
// Check collections
33+
const collectionsResponse = await fetch(`${QDRANT_URL}/collections`, {
34+
headers: {
35+
'api-key': QDRANT_API_KEY
36+
}
37+
});
38+
39+
if (!collectionsResponse.ok) {
40+
throw new Error(`Collections check failed: ${collectionsResponse.status} ${collectionsResponse.statusText}`);
41+
}
42+
43+
const collectionsData = await collectionsResponse.json();
44+
const collections = collectionsData.result?.collections || [];
45+
const collectionExists = collections.some(collection => collection.name === COLLECTION_NAME);
46+
47+
if (collectionExists) {
48+
console.log(`✅ SUCCESS: '${COLLECTION_NAME}' collection exists`);
49+
console.log(`📊 Total collections: ${collections.length}`);
50+
console.log(`🎯 Cluster ping completed successfully at ${new Date().toISOString()}`);
51+
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
52+
console.log("🎉 Cluster ping completed successfully!");
53+
process.exit(0);
54+
} else {
55+
console.error(`❌ ERROR: '${COLLECTION_NAME}' collection not found`);
56+
console.log(`📊 Available collections: ${collections.map(c => c.name).join(', ')}`);
57+
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
58+
console.error("💥 Cluster ping failed!");
59+
process.exit(1);
60+
}
61+
62+
} catch (error) {
63+
console.error("❌ FAILED to ping Vector Store (Qdrant) cluster:");
64+
console.error("Error details:", error.message);
65+
66+
if (error.message.includes("401") || error.message.includes("Unauthorized")) {
67+
console.error("💡 Hint: Check your QDRANT_API_KEY configuration");
68+
} else if (error.message.includes("network") || error.message.includes("fetch")) {
69+
console.error("💡 Hint: Check your QDRANT_URL and network connectivity");
70+
}
71+
72+
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
73+
console.error("💥 Cluster ping failed!");
74+
process.exit(1);
75+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"test:watch": "vitest",
1818
"test:coverage": "vitest run --coverage",
1919
"setup": "node dev/setup.js",
20-
"seed:jai": "node --env-file=.env dev/seed-vector-store.js"
20+
"seed:jai": "node --env-file=.env dev/seed-vector-store.js",
21+
"ping:qdrant": "node --env-file=.env dev/ping-qdrant-cluster.js"
2122
},
2223
"keywords": [],
2324
"author": "",

0 commit comments

Comments
 (0)