Skip to content

Commit f417382

Browse files
committed
[server] Introduce server_readiness_probe feature flag so we can disable the ReadinessProbe if required
Tool: gitpod/catfood.gitpod.cloud
1 parent 5a57076 commit f417382

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

components/server/src/liveness/readiness-controller.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { TypeORM } from "@gitpod/gitpod-db/lib";
1010
import { SpiceDBClientProvider } from "../authorization/spicedb";
1111
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
1212
import { ReadSchemaRequest } from "@authzed/authzed-node/dist/src/v1";
13+
import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server";
1314

1415
@injectable()
1516
export class ReadinessController {
@@ -25,6 +26,19 @@ export class ReadinessController {
2526
protected addReadinessHandler(router: express.Router) {
2627
router.get("/", async (_, res) => {
2728
try {
29+
// Check feature flag first
30+
const readinessProbeEnabled = await getExperimentsClientForBackend().getValueAsync(
31+
"server_readiness_probe",
32+
true, // Default to readiness probe, skip if false
33+
{},
34+
);
35+
36+
if (!readinessProbeEnabled) {
37+
log.debug("Readiness check skipped due to feature flag");
38+
res.status(200);
39+
return;
40+
}
41+
2842
// Check database connection
2943
const dbConnection = await this.checkDatabaseConnection();
3044
if (!dbConnection) {

memory-bank/activeContext.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ Initial exploration of the Gitpod codebase has revealed:
147147
- **Server Health Checks**: The Gitpod server uses two distinct health check mechanisms:
148148
- **Liveness Probe**: Checks the event loop lag to determine if the server is functioning properly
149149
- **Readiness Probe**: Checks database and SpiceDB connectivity to ensure the server is ready to handle requests
150+
- Controlled by a ConfigCat feature flag `server_readiness_probe` (default: true) that can bypass the actual checks
150151
- **Critical Dependencies**: The server has critical external dependencies that must be operational:
151152
- **Database (TypeORM)**: Used for persistent storage
152153
- **SpiceDB**: Used for authorization and permission management

memory-bank/progress.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,12 @@ No specific blockers or dependencies have been identified yet. This section will
211211
- Updated server container module and route configuration
212212
- Created PRD document for the readiness probe implementation
213213
- Updated Kubernetes deployment configuration to add the readiness probe
214+
- Added ConfigCat feature flag `server_readiness_probe` to control readiness checks
214215
- Updated memory bank with new learnings:
215216
- Added information about server health checks and critical dependencies
216217
- Documented server architecture patterns and dependency injection
217218
- Added information about Kubernetes deployment configuration
219+
- Documented feature flag implementation for readiness probe
218220

219221
## Next Evaluation Point
220222

prd/001-readinessprobe-server.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,19 @@ The readiness probe should be tested to ensure:
157157
- The probe runs every 10 seconds
158158
- The probe allows up to 3 failures before marking the pod as not ready
159159

160+
## Feature Flag Control
161+
162+
The readiness probe implementation includes a ConfigCat feature flag called `server_readiness_probe` that controls whether the actual connectivity checks are performed:
163+
164+
- When the flag is set to `true` (default): The readiness probe will always return a 200 status code, bypassing the actual database and SpiceDB connectivity checks
165+
- When the flag is set to `false`: The readiness probe will perform the actual checks and return the appropriate status code based on the results
166+
167+
This feature flag provides several benefits:
168+
169+
1. **Gradual Rollout**: Allows for a gradual rollout of the readiness probe, which is useful for testing in production environments
170+
2. **Emergency Override**: If the readiness probe causes issues in production, the flag can be quickly toggled to bypass the checks without requiring a code deployment
171+
3. **Environment-Specific Configuration**: Different environments (dev, staging, production) can have different settings for the readiness probe
172+
160173
## Future Improvements
161174

162175
- Add more sophisticated checks for SpiceDB connectivity, such as a simple permission check

0 commit comments

Comments
 (0)