diff --git a/components/server/src/config.ts b/components/server/src/config.ts index 2090895dd55483..c7bbc9eb25f8bb 100644 --- a/components/server/src/config.ts +++ b/components/server/src/config.ts @@ -173,6 +173,12 @@ export interface ConfigSerialized { vsxRegistryUrl: string; + /* + * The maximum event loop lag allowed before the liveness endpoint should return + * an error code. + */ + maximumEventLoopLag: number; + /** * Payment related options */ diff --git a/components/server/src/container-module.ts b/components/server/src/container-module.ts index 581a527b9b97cf..436190cda9813d 100644 --- a/components/server/src/container-module.ts +++ b/components/server/src/container-module.ts @@ -110,6 +110,7 @@ import { } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server"; import { VerificationService } from "./auth/verification-service"; import { WebhookEventGarbageCollector } from "./projects/webhook-event-garbage-collector"; +import { LivenessController } from "./liveness/liveness-controller"; export const productionContainerModule = new ContainerModule((bind, unbind, isBound, rebind) => { bind(Config).toConstantValue(ConfigFile.fromFile()); @@ -218,6 +219,7 @@ export const productionContainerModule = new ContainerModule((bind, unbind, isBo bind(WorkspaceGarbageCollector).toSelf().inSingletonScope(); bind(WorkspaceDownloadService).toSelf().inSingletonScope(); + bind(LivenessController).toSelf().inSingletonScope(); bind(OneTimeSecretServer).toSelf().inSingletonScope(); diff --git a/components/server/src/liveness/liveness-controller.ts b/components/server/src/liveness/liveness-controller.ts new file mode 100644 index 00000000000000..16bbd8e3566318 --- /dev/null +++ b/components/server/src/liveness/liveness-controller.ts @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2022 Gitpod GmbH. All rights reserved. + * Licensed under the GNU Affero General Public License (AGPL). + * See License-AGPL.txt in the project root for license information. + */ + +import { injectable, inject } from "inversify"; +import * as express from "express"; +import * as prom from "prom-client"; +import { Config } from "../config"; +import { log } from "@gitpod/gitpod-protocol/lib/util/logging"; + +@injectable() +export class LivenessController { + @inject(Config) protected readonly config: Config; + + get apiRouter(): express.Router { + const router = express.Router(); + this.addLivenessHandler(router); + return router; + } + + protected addLivenessHandler(router: express.Router) { + router.get("/", async (_, res) => { + if (!this.config.maximumEventLoopLag) { + res.end(); + return; + } + const metrics = await prom.register.getMetricsAsJSON(); + const metric = metrics.find((m) => m.name === "nodejs_eventloop_lag_seconds"); + if (!metric) { + log.error("unable to find nodejs event loop metric, liveness probe will not function"); + res.end(); + return; + } + const value = (metric as any).values[0].value; + res.status(value > this.config.maximumEventLoopLag ? 500 : 200); + res.end(`${value}`); + }); + } +} diff --git a/components/server/src/server.ts b/components/server/src/server.ts index 11ea0a43f638cf..57d11991a238c4 100644 --- a/components/server/src/server.ts +++ b/components/server/src/server.ts @@ -49,6 +49,7 @@ import { LocalMessageBroker } from "./messaging/local-message-broker"; import { WsConnectionHandler } from "./express/ws-connection-handler"; import { InstallationAdminController } from "./installation-admin/installation-admin-controller"; import { WebhookEventGarbageCollector } from "./projects/webhook-event-garbage-collector"; +import { LivenessController } from "./liveness/liveness-controller"; @injectable() export class Server { @@ -65,6 +66,7 @@ export class Server { @inject(MessageBusIntegration) protected readonly messagebus: MessageBusIntegration; @inject(LocalMessageBroker) protected readonly localMessageBroker: LocalMessageBroker; @inject(WorkspaceDownloadService) protected readonly workspaceDownloadService: WorkspaceDownloadService; + @inject(LivenessController) protected readonly livenessController: LivenessController; @inject(MonitoringEndpointsApp) protected readonly monitoringEndpointsApp: MonitoringEndpointsApp; @inject(CodeSyncService) private readonly codeSyncService: CodeSyncService; @inject(HeadlessLogController) protected readonly headlessLogController: HeadlessLogController; @@ -298,6 +300,7 @@ export class Server { app.use("/code-sync", this.codeSyncService.apiRouter); app.use(HEADLESS_LOGS_PATH_PREFIX, this.headlessLogController.headlessLogs); app.use(HEADLESS_LOG_DOWNLOAD_PATH_PREFIX, this.headlessLogController.headlessLogDownload); + app.use("/live", this.livenessController.apiRouter); app.use(this.newsletterSubscriptionController.apiRouter); app.use("/version", (req: express.Request, res: express.Response, next: express.NextFunction) => { res.send(this.config.version); diff --git a/install/installer/cmd/testdata/render/aws-setup/output.golden b/install/installer/cmd/testdata/render/aws-setup/output.golden index 846f490dc02b47..c1f8273e7323d2 100644 --- a/install/installer/cmd/testdata/render/aws-setup/output.golden +++ b/install/installer/cmd/testdata/render/aws-setup/output.golden @@ -4335,6 +4335,7 @@ data: "contentServiceAddr": "content-service.default.svc.cluster.local:8080", "imageBuilderAddr": "image-builder-mk3.default.svc.cluster.local:8080", "usageServiceAddr": "usage.default.svc.cluster.local:9001", + "maximumEventLoopLag": 0.35, "vsxRegistryUrl": "https://open-vsx.gitpod.example.com", "chargebeeProviderOptionsFile": "/chargebee/providerOptions", "stripeSecretsFile": "/stripe-secret/apikeys", @@ -8510,7 +8511,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: 5e83195e3b26814469c129377371253ea302cf69070d509383e968ec5d7a7ce9 + gitpod.io/checksum_config: 32e2cd87294b477e4686b3523a87690f8c0116f6bf824310de31a839a523eea7 creationTimestamp: null labels: app: gitpod @@ -8609,6 +8610,13 @@ spec: value: WwogIHsKICAgICJuYW1lIjogImRlZmF1bHQiLAogICAgInVybCI6ICJkbnM6Ly8vd3MtbWFuYWdlcjo4MDgwIiwKICAgICJ0bHMiOiB7CiAgICAgICJjYSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL2NhLmNydCIsCiAgICAgICJjcnQiOiAiL3dzLW1hbmFnZXItY2xpZW50LXRscy1jZXJ0cy90bHMuY3J0IiwKICAgICAgImtleSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL3Rscy5rZXkiCiAgICB9LAogICAgInN0YXRlIjogImF2YWlsYWJsZSIsCiAgICAibWF4U2NvcmUiOiAxMDAsCiAgICAic2NvcmUiOiA1MCwKICAgICJnb3Zlcm4iOiB0cnVlLAogICAgImFkbWlzc2lvbkNvbnN0cmFpbnRzIjogbnVsbAogIH0KXQ== image: eu.gcr.io/gitpod-core-dev/build/server:test imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 6 + httpGet: + path: /live + port: 3000 + initialDelaySeconds: 120 + periodSeconds: 10 name: server ports: - containerPort: 3000 diff --git a/install/installer/cmd/testdata/render/azure-setup/output.golden b/install/installer/cmd/testdata/render/azure-setup/output.golden index 0e267bfe3e2ada..d58a1aaef5fce5 100644 --- a/install/installer/cmd/testdata/render/azure-setup/output.golden +++ b/install/installer/cmd/testdata/render/azure-setup/output.golden @@ -4199,6 +4199,7 @@ data: "contentServiceAddr": "content-service.default.svc.cluster.local:8080", "imageBuilderAddr": "image-builder-mk3.default.svc.cluster.local:8080", "usageServiceAddr": "usage.default.svc.cluster.local:9001", + "maximumEventLoopLag": 0.35, "vsxRegistryUrl": "https://open-vsx.gitpod.example.com", "chargebeeProviderOptionsFile": "/chargebee/providerOptions", "stripeSecretsFile": "/stripe-secret/apikeys", @@ -8362,7 +8363,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: 5e83195e3b26814469c129377371253ea302cf69070d509383e968ec5d7a7ce9 + gitpod.io/checksum_config: 32e2cd87294b477e4686b3523a87690f8c0116f6bf824310de31a839a523eea7 creationTimestamp: null labels: app: gitpod @@ -8461,6 +8462,13 @@ spec: value: WwogIHsKICAgICJuYW1lIjogImRlZmF1bHQiLAogICAgInVybCI6ICJkbnM6Ly8vd3MtbWFuYWdlcjo4MDgwIiwKICAgICJ0bHMiOiB7CiAgICAgICJjYSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL2NhLmNydCIsCiAgICAgICJjcnQiOiAiL3dzLW1hbmFnZXItY2xpZW50LXRscy1jZXJ0cy90bHMuY3J0IiwKICAgICAgImtleSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL3Rscy5rZXkiCiAgICB9LAogICAgInN0YXRlIjogImF2YWlsYWJsZSIsCiAgICAibWF4U2NvcmUiOiAxMDAsCiAgICAic2NvcmUiOiA1MCwKICAgICJnb3Zlcm4iOiB0cnVlLAogICAgImFkbWlzc2lvbkNvbnN0cmFpbnRzIjogbnVsbAogIH0KXQ== image: eu.gcr.io/gitpod-core-dev/build/server:test imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 6 + httpGet: + path: /live + port: 3000 + initialDelaySeconds: 120 + periodSeconds: 10 name: server ports: - containerPort: 3000 diff --git a/install/installer/cmd/testdata/render/customization/output.golden b/install/installer/cmd/testdata/render/customization/output.golden index 36caba94f269d9..70b1f78b2ff94e 100644 --- a/install/installer/cmd/testdata/render/customization/output.golden +++ b/install/installer/cmd/testdata/render/customization/output.golden @@ -5146,6 +5146,7 @@ data: "contentServiceAddr": "content-service.default.svc.cluster.local:8080", "imageBuilderAddr": "image-builder-mk3.default.svc.cluster.local:8080", "usageServiceAddr": "usage.default.svc.cluster.local:9001", + "maximumEventLoopLag": 0.35, "vsxRegistryUrl": "https://open-vsx.gitpod.example.com", "chargebeeProviderOptionsFile": "/chargebee/providerOptions", "stripeSecretsFile": "/stripe-secret/apikeys", @@ -9930,7 +9931,7 @@ spec: metadata: annotations: gitpod.io: hello - gitpod.io/checksum_config: 1c78430996bb02767dd4d5056d285a4921476ee7d787fc03289271172e680e4f + gitpod.io/checksum_config: c90cd959e46212ec8bc505415b69d1340af10b1938cad4a1e717a9d2a76479ed hello: world creationTimestamp: null labels: @@ -10032,6 +10033,13 @@ spec: value: WwogIHsKICAgICJuYW1lIjogImRlZmF1bHQiLAogICAgInVybCI6ICJkbnM6Ly8vd3MtbWFuYWdlcjo4MDgwIiwKICAgICJ0bHMiOiB7CiAgICAgICJjYSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL2NhLmNydCIsCiAgICAgICJjcnQiOiAiL3dzLW1hbmFnZXItY2xpZW50LXRscy1jZXJ0cy90bHMuY3J0IiwKICAgICAgImtleSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL3Rscy5rZXkiCiAgICB9LAogICAgInN0YXRlIjogImF2YWlsYWJsZSIsCiAgICAibWF4U2NvcmUiOiAxMDAsCiAgICAic2NvcmUiOiA1MCwKICAgICJnb3Zlcm4iOiB0cnVlLAogICAgImFkbWlzc2lvbkNvbnN0cmFpbnRzIjogbnVsbAogIH0KXQ== image: eu.gcr.io/gitpod-core-dev/build/server:test imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 6 + httpGet: + path: /live + port: 3000 + initialDelaySeconds: 120 + periodSeconds: 10 name: server ports: - containerPort: 3000 diff --git a/install/installer/cmd/testdata/render/external-registry/output.golden b/install/installer/cmd/testdata/render/external-registry/output.golden index 05f0a9475d13e2..db26d6183a448d 100644 --- a/install/installer/cmd/testdata/render/external-registry/output.golden +++ b/install/installer/cmd/testdata/render/external-registry/output.golden @@ -4386,6 +4386,7 @@ data: "contentServiceAddr": "content-service.default.svc.cluster.local:8080", "imageBuilderAddr": "image-builder-mk3.default.svc.cluster.local:8080", "usageServiceAddr": "usage.default.svc.cluster.local:9001", + "maximumEventLoopLag": 0.35, "vsxRegistryUrl": "https://open-vsx.gitpod.example.com", "chargebeeProviderOptionsFile": "/chargebee/providerOptions", "stripeSecretsFile": "/stripe-secret/apikeys", @@ -8788,7 +8789,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: 2aeb669de68663a5b2c623f39956d06e8fe065ce6ab3497364969412346267a2 + gitpod.io/checksum_config: 3212e0147834123027630e72c4dc6d60d6de7bb4f9143aebc173248f1d3e46a6 creationTimestamp: null labels: app: gitpod @@ -8887,6 +8888,13 @@ spec: value: WwogIHsKICAgICJuYW1lIjogImRlZmF1bHQiLAogICAgInVybCI6ICJkbnM6Ly8vd3MtbWFuYWdlcjo4MDgwIiwKICAgICJ0bHMiOiB7CiAgICAgICJjYSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL2NhLmNydCIsCiAgICAgICJjcnQiOiAiL3dzLW1hbmFnZXItY2xpZW50LXRscy1jZXJ0cy90bHMuY3J0IiwKICAgICAgImtleSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL3Rscy5rZXkiCiAgICB9LAogICAgInN0YXRlIjogImF2YWlsYWJsZSIsCiAgICAibWF4U2NvcmUiOiAxMDAsCiAgICAic2NvcmUiOiA1MCwKICAgICJnb3Zlcm4iOiB0cnVlLAogICAgImFkbWlzc2lvbkNvbnN0cmFpbnRzIjogbnVsbAogIH0KXQ== image: eu.gcr.io/gitpod-core-dev/build/server:test imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 6 + httpGet: + path: /live + port: 3000 + initialDelaySeconds: 120 + periodSeconds: 10 name: server ports: - containerPort: 3000 diff --git a/install/installer/cmd/testdata/render/gcp-setup/output.golden b/install/installer/cmd/testdata/render/gcp-setup/output.golden index f31de65f6e73a4..74df0ad86ce74b 100644 --- a/install/installer/cmd/testdata/render/gcp-setup/output.golden +++ b/install/installer/cmd/testdata/render/gcp-setup/output.golden @@ -4160,6 +4160,7 @@ data: "contentServiceAddr": "content-service.default.svc.cluster.local:8080", "imageBuilderAddr": "image-builder-mk3.default.svc.cluster.local:8080", "usageServiceAddr": "usage.default.svc.cluster.local:9001", + "maximumEventLoopLag": 0.35, "vsxRegistryUrl": "https://open-vsx.gitpod.example.com", "chargebeeProviderOptionsFile": "/chargebee/providerOptions", "stripeSecretsFile": "/stripe-secret/apikeys", @@ -8291,7 +8292,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: e815e4561d4c745651c63b726706a527b86b8a7eec74049d42415aef264b61a1 + gitpod.io/checksum_config: 95f202b0069bd8027c0de410a88e31fdfbd82ac5c9ed999407d479cd2bc421cf creationTimestamp: null labels: app: gitpod @@ -8384,6 +8385,13 @@ spec: value: WwogIHsKICAgICJuYW1lIjogImRlZmF1bHQiLAogICAgInVybCI6ICJkbnM6Ly8vd3MtbWFuYWdlcjo4MDgwIiwKICAgICJ0bHMiOiB7CiAgICAgICJjYSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL2NhLmNydCIsCiAgICAgICJjcnQiOiAiL3dzLW1hbmFnZXItY2xpZW50LXRscy1jZXJ0cy90bHMuY3J0IiwKICAgICAgImtleSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL3Rscy5rZXkiCiAgICB9LAogICAgInN0YXRlIjogImF2YWlsYWJsZSIsCiAgICAibWF4U2NvcmUiOiAxMDAsCiAgICAic2NvcmUiOiA1MCwKICAgICJnb3Zlcm4iOiB0cnVlLAogICAgImFkbWlzc2lvbkNvbnN0cmFpbnRzIjogbnVsbAogIH0KXQ== image: eu.gcr.io/gitpod-core-dev/build/server:test imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 6 + httpGet: + path: /live + port: 3000 + initialDelaySeconds: 120 + periodSeconds: 10 name: server ports: - containerPort: 3000 diff --git a/install/installer/cmd/testdata/render/http-proxy/output.golden b/install/installer/cmd/testdata/render/http-proxy/output.golden index d359773607e2e0..26c9d86c365b11 100644 --- a/install/installer/cmd/testdata/render/http-proxy/output.golden +++ b/install/installer/cmd/testdata/render/http-proxy/output.golden @@ -4609,6 +4609,7 @@ data: "contentServiceAddr": "content-service.default.svc.cluster.local:8080", "imageBuilderAddr": "image-builder-mk3.default.svc.cluster.local:8080", "usageServiceAddr": "usage.default.svc.cluster.local:9001", + "maximumEventLoopLag": 0.35, "vsxRegistryUrl": "https://open-vsx.gitpod.example.com", "chargebeeProviderOptionsFile": "/chargebee/providerOptions", "stripeSecretsFile": "/stripe-secret/apikeys", @@ -10209,7 +10210,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: 2aeb669de68663a5b2c623f39956d06e8fe065ce6ab3497364969412346267a2 + gitpod.io/checksum_config: 3212e0147834123027630e72c4dc6d60d6de7bb4f9143aebc173248f1d3e46a6 creationTimestamp: null labels: app: gitpod @@ -10350,6 +10351,13 @@ spec: value: content-service.default.svc.cluster.local,image-builder-mk3.default.svc.cluster.local,usage.default.svc.cluster.local,$(NO_PROXY) image: eu.gcr.io/gitpod-core-dev/build/server:test imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 6 + httpGet: + path: /live + port: 3000 + initialDelaySeconds: 120 + periodSeconds: 10 name: server ports: - containerPort: 3000 diff --git a/install/installer/cmd/testdata/render/minimal/output.golden b/install/installer/cmd/testdata/render/minimal/output.golden index 8681d5cd0d4878..c3bfecc189caf2 100644 --- a/install/installer/cmd/testdata/render/minimal/output.golden +++ b/install/installer/cmd/testdata/render/minimal/output.golden @@ -4606,6 +4606,7 @@ data: "contentServiceAddr": "content-service.default.svc.cluster.local:8080", "imageBuilderAddr": "image-builder-mk3.default.svc.cluster.local:8080", "usageServiceAddr": "usage.default.svc.cluster.local:9001", + "maximumEventLoopLag": 0.35, "vsxRegistryUrl": "https://open-vsx.gitpod.example.com", "chargebeeProviderOptionsFile": "/chargebee/providerOptions", "stripeSecretsFile": "/stripe-secret/apikeys", @@ -9163,7 +9164,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: 2aeb669de68663a5b2c623f39956d06e8fe065ce6ab3497364969412346267a2 + gitpod.io/checksum_config: 3212e0147834123027630e72c4dc6d60d6de7bb4f9143aebc173248f1d3e46a6 creationTimestamp: null labels: app: gitpod @@ -9262,6 +9263,13 @@ spec: value: WwogIHsKICAgICJuYW1lIjogImRlZmF1bHQiLAogICAgInVybCI6ICJkbnM6Ly8vd3MtbWFuYWdlcjo4MDgwIiwKICAgICJ0bHMiOiB7CiAgICAgICJjYSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL2NhLmNydCIsCiAgICAgICJjcnQiOiAiL3dzLW1hbmFnZXItY2xpZW50LXRscy1jZXJ0cy90bHMuY3J0IiwKICAgICAgImtleSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL3Rscy5rZXkiCiAgICB9LAogICAgInN0YXRlIjogImF2YWlsYWJsZSIsCiAgICAibWF4U2NvcmUiOiAxMDAsCiAgICAic2NvcmUiOiA1MCwKICAgICJnb3Zlcm4iOiB0cnVlLAogICAgImFkbWlzc2lvbkNvbnN0cmFpbnRzIjogbnVsbAogIH0KXQ== image: eu.gcr.io/gitpod-core-dev/build/server:test imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 6 + httpGet: + path: /live + port: 3000 + initialDelaySeconds: 120 + periodSeconds: 10 name: server ports: - containerPort: 3000 diff --git a/install/installer/cmd/testdata/render/statefulset-customization/output.golden b/install/installer/cmd/testdata/render/statefulset-customization/output.golden index 4b0469aa5cc4cd..0d6b31fadc1587 100644 --- a/install/installer/cmd/testdata/render/statefulset-customization/output.golden +++ b/install/installer/cmd/testdata/render/statefulset-customization/output.golden @@ -4618,6 +4618,7 @@ data: "contentServiceAddr": "content-service.default.svc.cluster.local:8080", "imageBuilderAddr": "image-builder-mk3.default.svc.cluster.local:8080", "usageServiceAddr": "usage.default.svc.cluster.local:9001", + "maximumEventLoopLag": 0.35, "vsxRegistryUrl": "https://open-vsx.gitpod.example.com", "chargebeeProviderOptionsFile": "/chargebee/providerOptions", "stripeSecretsFile": "/stripe-secret/apikeys", @@ -9175,7 +9176,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: 2aeb669de68663a5b2c623f39956d06e8fe065ce6ab3497364969412346267a2 + gitpod.io/checksum_config: 3212e0147834123027630e72c4dc6d60d6de7bb4f9143aebc173248f1d3e46a6 creationTimestamp: null labels: app: gitpod @@ -9274,6 +9275,13 @@ spec: value: WwogIHsKICAgICJuYW1lIjogImRlZmF1bHQiLAogICAgInVybCI6ICJkbnM6Ly8vd3MtbWFuYWdlcjo4MDgwIiwKICAgICJ0bHMiOiB7CiAgICAgICJjYSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL2NhLmNydCIsCiAgICAgICJjcnQiOiAiL3dzLW1hbmFnZXItY2xpZW50LXRscy1jZXJ0cy90bHMuY3J0IiwKICAgICAgImtleSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL3Rscy5rZXkiCiAgICB9LAogICAgInN0YXRlIjogImF2YWlsYWJsZSIsCiAgICAibWF4U2NvcmUiOiAxMDAsCiAgICAic2NvcmUiOiA1MCwKICAgICJnb3Zlcm4iOiB0cnVlLAogICAgImFkbWlzc2lvbkNvbnN0cmFpbnRzIjogbnVsbAogIH0KXQ== image: eu.gcr.io/gitpod-core-dev/build/server:test imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 6 + httpGet: + path: /live + port: 3000 + initialDelaySeconds: 120 + periodSeconds: 10 name: server ports: - containerPort: 3000 diff --git a/install/installer/cmd/testdata/render/use-pod-security-policies/output.golden b/install/installer/cmd/testdata/render/use-pod-security-policies/output.golden index f9a094b2ff4488..bd5095e949fb51 100644 --- a/install/installer/cmd/testdata/render/use-pod-security-policies/output.golden +++ b/install/installer/cmd/testdata/render/use-pod-security-policies/output.golden @@ -4939,6 +4939,7 @@ data: "contentServiceAddr": "content-service.default.svc.cluster.local:8080", "imageBuilderAddr": "image-builder-mk3.default.svc.cluster.local:8080", "usageServiceAddr": "usage.default.svc.cluster.local:9001", + "maximumEventLoopLag": 0.35, "vsxRegistryUrl": "https://open-vsx.gitpod.example.com", "chargebeeProviderOptionsFile": "/chargebee/providerOptions", "stripeSecretsFile": "/stripe-secret/apikeys", @@ -9607,7 +9608,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: 2aeb669de68663a5b2c623f39956d06e8fe065ce6ab3497364969412346267a2 + gitpod.io/checksum_config: 3212e0147834123027630e72c4dc6d60d6de7bb4f9143aebc173248f1d3e46a6 creationTimestamp: null labels: app: gitpod @@ -9706,6 +9707,13 @@ spec: value: WwogIHsKICAgICJuYW1lIjogImRlZmF1bHQiLAogICAgInVybCI6ICJkbnM6Ly8vd3MtbWFuYWdlcjo4MDgwIiwKICAgICJ0bHMiOiB7CiAgICAgICJjYSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL2NhLmNydCIsCiAgICAgICJjcnQiOiAiL3dzLW1hbmFnZXItY2xpZW50LXRscy1jZXJ0cy90bHMuY3J0IiwKICAgICAgImtleSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL3Rscy5rZXkiCiAgICB9LAogICAgInN0YXRlIjogImF2YWlsYWJsZSIsCiAgICAibWF4U2NvcmUiOiAxMDAsCiAgICAic2NvcmUiOiA1MCwKICAgICJnb3Zlcm4iOiB0cnVlLAogICAgImFkbWlzc2lvbkNvbnN0cmFpbnRzIjogbnVsbAogIH0KXQ== image: eu.gcr.io/gitpod-core-dev/build/server:test imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 6 + httpGet: + path: /live + port: 3000 + initialDelaySeconds: 120 + periodSeconds: 10 name: server ports: - containerPort: 3000 diff --git a/install/installer/cmd/testdata/render/workspace-requests-limits/output.golden b/install/installer/cmd/testdata/render/workspace-requests-limits/output.golden index adb4650cdbd081..fdf9d856d6296a 100644 --- a/install/installer/cmd/testdata/render/workspace-requests-limits/output.golden +++ b/install/installer/cmd/testdata/render/workspace-requests-limits/output.golden @@ -4609,6 +4609,7 @@ data: "contentServiceAddr": "content-service.default.svc.cluster.local:8080", "imageBuilderAddr": "image-builder-mk3.default.svc.cluster.local:8080", "usageServiceAddr": "usage.default.svc.cluster.local:9001", + "maximumEventLoopLag": 0.35, "vsxRegistryUrl": "https://open-vsx.gitpod.example.com", "chargebeeProviderOptionsFile": "/chargebee/providerOptions", "stripeSecretsFile": "/stripe-secret/apikeys", @@ -9166,7 +9167,7 @@ spec: template: metadata: annotations: - gitpod.io/checksum_config: 2aeb669de68663a5b2c623f39956d06e8fe065ce6ab3497364969412346267a2 + gitpod.io/checksum_config: 3212e0147834123027630e72c4dc6d60d6de7bb4f9143aebc173248f1d3e46a6 creationTimestamp: null labels: app: gitpod @@ -9265,6 +9266,13 @@ spec: value: WwogIHsKICAgICJuYW1lIjogImRlZmF1bHQiLAogICAgInVybCI6ICJkbnM6Ly8vd3MtbWFuYWdlcjo4MDgwIiwKICAgICJ0bHMiOiB7CiAgICAgICJjYSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL2NhLmNydCIsCiAgICAgICJjcnQiOiAiL3dzLW1hbmFnZXItY2xpZW50LXRscy1jZXJ0cy90bHMuY3J0IiwKICAgICAgImtleSI6ICIvd3MtbWFuYWdlci1jbGllbnQtdGxzLWNlcnRzL3Rscy5rZXkiCiAgICB9LAogICAgInN0YXRlIjogImF2YWlsYWJsZSIsCiAgICAibWF4U2NvcmUiOiAxMDAsCiAgICAic2NvcmUiOiA1MCwKICAgICJnb3Zlcm4iOiB0cnVlLAogICAgImFkbWlzc2lvbkNvbnN0cmFpbnRzIjogbnVsbAogIH0KXQ== image: eu.gcr.io/gitpod-core-dev/build/server:test imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 6 + httpGet: + path: /live + port: 3000 + initialDelaySeconds: 120 + periodSeconds: 10 name: server ports: - containerPort: 3000 diff --git a/install/installer/pkg/components/server/configmap.go b/install/installer/pkg/components/server/configmap.go index 31e37ab2af32ea..180a45ffca9b58 100644 --- a/install/installer/pkg/components/server/configmap.go +++ b/install/installer/pkg/components/server/configmap.go @@ -236,6 +236,7 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) { ContentServiceAddr: net.JoinHostPort(fmt.Sprintf("%s.%s.svc.cluster.local", contentservice.Component, ctx.Namespace), strconv.Itoa(contentservice.RPCPort)), ImageBuilderAddr: net.JoinHostPort(fmt.Sprintf("%s.%s.svc.cluster.local", common.ImageBuilderComponent, ctx.Namespace), strconv.Itoa(common.ImageBuilderRPCPort)), UsageServiceAddr: net.JoinHostPort(fmt.Sprintf("%s.%s.svc.cluster.local", usage.Component, ctx.Namespace), strconv.Itoa(usage.GRPCServicePort)), + MaximumEventLoopLag: 0.35, CodeSync: CodeSync{}, VSXRegistryUrl: fmt.Sprintf("https://open-vsx.%s", ctx.Config.Domain), // todo(sje): or "https://{{ .Values.vsxRegistry.host | default "open-vsx.org" }}" if not using OpenVSX proxy EnablePayment: chargebeeSecret != "" || stripeSecret != "" || stripeConfig != "", diff --git a/install/installer/pkg/components/server/deployment.go b/install/installer/pkg/components/server/deployment.go index 22e126a389f136..d818cb65d70166 100644 --- a/install/installer/pkg/components/server/deployment.go +++ b/install/installer/pkg/components/server/deployment.go @@ -26,6 +26,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/utils/pointer" ) @@ -387,6 +388,20 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { "memory": resource.MustParse("200Mi"), }, }), + LivenessProbe: &corev1.Probe{ + ProbeHandler: corev1.ProbeHandler{ + HTTPGet: &corev1.HTTPGetAction{ + Path: "/live", + Port: intstr.IntOrString{ + Type: intstr.Int, + IntVal: ContainerPort, + }, + }, + }, + InitialDelaySeconds: 120, + PeriodSeconds: 10, + FailureThreshold: 6, + }, SecurityContext: &corev1.SecurityContext{ Privileged: pointer.Bool(false), RunAsUser: pointer.Int64(31001), diff --git a/install/installer/pkg/components/server/types.go b/install/installer/pkg/components/server/types.go index 71908c324ab7fe..97f63aa0cd0f5a 100644 --- a/install/installer/pkg/components/server/types.go +++ b/install/installer/pkg/components/server/types.go @@ -31,6 +31,7 @@ type ConfigSerialized struct { ContentServiceAddr string `json:"contentServiceAddr"` ImageBuilderAddr string `json:"imageBuilderAddr"` UsageServiceAddr string `json:"usageServiceAddr"` + MaximumEventLoopLag float64 `json:"maximumEventLoopLag"` VSXRegistryUrl string `json:"vsxRegistryUrl"` ChargebeeProviderOptionsFile string `json:"chargebeeProviderOptionsFile"` StripeSecretsFile string `json:"stripeSecretsFile"`