Skip to content

Commit 409ce6b

Browse files
easyCZroboquat
authored andcommitted
[server] Remove Workspace health monitoring endpoint
1 parent 3ed1465 commit 409ce6b

File tree

3 files changed

+2
-212
lines changed

3 files changed

+2
-212
lines changed

components/server/ee/src/container-module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import { WorkspaceFactory } from "../../src/workspace/workspace-factory";
2828
import { WorkspaceFactoryEE } from "./workspace/workspace-factory";
2929
import { MonitoringEndpointsAppEE } from "./monitoring-endpoint-ee";
3030
import { MonitoringEndpointsApp } from "../../src/monitoring-endpoints";
31-
import { WorkspaceHealthMonitoring } from "./workspace/workspace-health-monitoring";
3231
import { AccountService } from "@gitpod/gitpod-payment-endpoint/lib/accounting/account-service";
3332
import {
3433
AccountServiceImpl,
@@ -73,7 +72,6 @@ export const productionEEContainerModule = new ContainerModule((bind, unbind, is
7372
rebind(WorkspaceFactory).to(WorkspaceFactoryEE).inSingletonScope();
7473
rebind(MonitoringEndpointsApp).to(MonitoringEndpointsAppEE).inSingletonScope();
7574

76-
bind(WorkspaceHealthMonitoring).toSelf().inSingletonScope();
7775
bind(PrebuildManager).toSelf().inSingletonScope();
7876
bind(IPrefixContextParser).to(StartPrebuildContextParser).inSingletonScope();
7977
bind(GithubApp).toSelf().inSingletonScope();

components/server/ee/src/monitoring-endpoint-ee.ts

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@
55
*/
66

77
import * as express from "express";
8-
import { WorkspaceHealthMonitoring } from "./workspace/workspace-health-monitoring";
9-
import { TraceContext } from "@gitpod/gitpod-protocol/lib/util/tracing";
10-
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
11-
import { injectable, inject } from "inversify";
8+
import { injectable } from "inversify";
129
import { registerServerMetrics } from "../../src/prometheus-metrics";
1310
import * as prometheusClient from "prom-client";
1411
import { registerDBMetrics } from "@gitpod/gitpod-db/lib";
1512

1613
@injectable()
17-
export class MonitoringEndpointsAppEE extends WorkspaceHealthMonitoring {
18-
@inject(WorkspaceHealthMonitoring) protected readonly workspaceHealthMonitoring: WorkspaceHealthMonitoring;
19-
14+
export class MonitoringEndpointsAppEE {
2015
public create(): express.Application {
2116
const registry = prometheusClient.register;
2217

@@ -34,53 +29,6 @@ export class MonitoringEndpointsAppEE extends WorkspaceHealthMonitoring {
3429
}
3530
});
3631

37-
monApp.get("/workspace-health", async (req, res) => {
38-
try {
39-
const result = await checkWorkspaceHealth({}, this.workspaceHealthMonitoring, !!req.query.extra);
40-
if (result.unhealthy > 0) {
41-
console.warn("not all workspaces are healthy", result);
42-
res.status(406).send(result);
43-
} else {
44-
res.status(200).send(result);
45-
}
46-
} catch (err) {
47-
log.debug("failed to check workspace health", err);
48-
res.status(500).send(err);
49-
}
50-
});
51-
5232
return monApp;
5333
}
5434
}
55-
56-
async function checkWorkspaceHealth(
57-
ctx: TraceContext,
58-
workspaceHealthMonitoring: WorkspaceHealthMonitoring,
59-
extra: boolean = false,
60-
) {
61-
const span = TraceContext.startSpan("checkWorkspaceHealth", ctx);
62-
const result = await workspaceHealthMonitoring.probeAllRunningWorkspaces({ span });
63-
const numUnhealthy = result
64-
.map((r) => (r.ok ? 0 : 1))
65-
.reduce((acc: number, cur: number) => (acc + cur) as number, 0);
66-
let returnValue = {
67-
status:
68-
numUnhealthy > 0 ? (numUnhealthy == result.length ? "unhealthy" : "partially healthy") : "fully healthy",
69-
healthy: result.length - numUnhealthy,
70-
unhealthy: numUnhealthy,
71-
total: result.length,
72-
timestamp: Date.now(),
73-
};
74-
if (extra && numUnhealthy > 0) {
75-
span.finish();
76-
return {
77-
...returnValue,
78-
extra: {
79-
unhealthyWorkspaces: result.filter((r) => !r.ok),
80-
notRunningWorkspaces: result.filter((r) => r.status !== "running"),
81-
},
82-
};
83-
}
84-
span.finish();
85-
return returnValue;
86-
}

components/server/ee/src/workspace/workspace-health-monitoring.ts

Lines changed: 0 additions & 156 deletions
This file was deleted.

0 commit comments

Comments
 (0)