@@ -10,73 +10,53 @@ import { TypeORM } from "@gitpod/gitpod-db/lib";
1010import { SpiceDBClientProvider } from "../authorization/spicedb" ;
1111import { log } from "@gitpod/gitpod-protocol/lib/util/logging" ;
1212import { v1 } from "@authzed/authzed-node" ;
13- import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server" ;
1413import { Redis } from "ioredis" ;
15- import { repeat } from "@gitpod/gitpod-protocol/lib/util/repeat" ;
16- import { Disposable , DisposableCollection } from "@gitpod/gitpod-protocol" ;
1714
1815@injectable ( )
19- export class ReadinessController {
16+ export class StartupController {
2017 @inject ( TypeORM ) protected readonly typeOrm : TypeORM ;
2118 @inject ( SpiceDBClientProvider ) protected readonly spiceDBClientProvider : SpiceDBClientProvider ;
2219 @inject ( Redis ) protected readonly redis : Redis ;
2320
24- private readinessProbeEnabled : boolean = true ;
25- private disposables : DisposableCollection = new DisposableCollection ( ) ;
26-
2721 get apiRouter ( ) : express . Router {
2822 const router = express . Router ( ) ;
29- this . addReadinessHandler ( router ) ;
23+ this . addStartupHandler ( router ) ;
3024 return router ;
3125 }
3226
33- public async start ( ) {
34- this . disposables . push ( this . startPollingFeatureFlag ( ) ) ;
35- }
36-
37- public async stop ( ) {
38- this . disposables . dispose ( ) ;
39- }
40-
41- protected addReadinessHandler ( router : express . Router ) {
27+ protected addStartupHandler ( router : express . Router ) {
4228 router . get ( "/" , async ( _ , res ) => {
4329 try {
44- if ( ! this . readinessProbeEnabled ) {
45- log . debug ( "Readiness check skipped due to feature flag" ) ;
46- res . status ( 200 ) ;
47- return ;
48- }
49-
5030 // Check database connection
5131 const dbConnection = await this . checkDatabaseConnection ( ) ;
5232 if ( ! dbConnection ) {
53- log . warn ( "Readiness check failed: Database connection failed" ) ;
33+ log . warn ( "Startup check failed: Database connection failed" ) ;
5434 res . status ( 503 ) . send ( "Database connection failed" ) ;
5535 return ;
5636 }
5737
5838 // Check SpiceDB connection
5939 const spiceDBConnection = await this . checkSpiceDBConnection ( ) ;
6040 if ( ! spiceDBConnection ) {
61- log . warn ( "Readiness check failed: SpiceDB connection failed" ) ;
41+ log . warn ( "Startup check failed: SpiceDB connection failed" ) ;
6242 res . status ( 503 ) . send ( "SpiceDB connection failed" ) ;
6343 return ;
6444 }
6545
6646 // Check Redis connection
6747 const redisConnection = await this . checkRedisConnection ( ) ;
6848 if ( ! redisConnection ) {
69- log . warn ( "Readiness check failed: Redis connection failed" ) ;
49+ log . warn ( "Startup check failed: Redis connection failed" ) ;
7050 res . status ( 503 ) . send ( "Redis connection failed" ) ;
7151 return ;
7252 }
7353
7454 // All connections are good
7555 res . status ( 200 ) . send ( "Ready" ) ;
76- log . debug ( "Readiness check successful" ) ;
56+ log . debug ( "Startup check successful" ) ;
7757 } catch ( error ) {
78- log . error ( "Readiness check failed" , error ) ;
79- res . status ( 503 ) . send ( "Readiness check failed" ) ;
58+ log . error ( "Startup check failed" , error ) ;
59+ res . status ( 503 ) . send ( "Startup check failed" ) ;
8060 }
8161 } ) ;
8262 }
@@ -121,21 +101,4 @@ export class ReadinessController {
121101 return false ;
122102 }
123103 }
124-
125- private startPollingFeatureFlag ( ) : Disposable {
126- return repeat ( async ( ) => {
127- // Check feature flag first
128- const readinessProbeEnabled = await getExperimentsClientForBackend ( ) . getValueAsync (
129- "server_readiness_probe" ,
130- true , // Default to readiness probe, skip if false
131- { } ,
132- ) ;
133-
134- log . debug ( "Feature flag server_readiness_probe updated" , {
135- readinessProbeEnabled,
136- oldValue : this . readinessProbeEnabled ,
137- } ) ;
138- this . readinessProbeEnabled = readinessProbeEnabled ;
139- } , 10_000 ) ;
140- }
141104}
0 commit comments