Skip to content

[server] Remove Workspace health monitoring endpoint #13312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions components/server/ee/src/container-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { WorkspaceFactory } from "../../src/workspace/workspace-factory";
import { WorkspaceFactoryEE } from "./workspace/workspace-factory";
import { MonitoringEndpointsAppEE } from "./monitoring-endpoint-ee";
import { MonitoringEndpointsApp } from "../../src/monitoring-endpoints";
import { WorkspaceHealthMonitoring } from "./workspace/workspace-health-monitoring";
import { AccountService } from "@gitpod/gitpod-payment-endpoint/lib/accounting/account-service";
import {
AccountServiceImpl,
Expand Down Expand Up @@ -73,7 +72,6 @@ export const productionEEContainerModule = new ContainerModule((bind, unbind, is
rebind(WorkspaceFactory).to(WorkspaceFactoryEE).inSingletonScope();
rebind(MonitoringEndpointsApp).to(MonitoringEndpointsAppEE).inSingletonScope();

bind(WorkspaceHealthMonitoring).toSelf().inSingletonScope();
bind(PrebuildManager).toSelf().inSingletonScope();
bind(IPrefixContextParser).to(StartPrebuildContextParser).inSingletonScope();
bind(GithubApp).toSelf().inSingletonScope();
Expand Down
56 changes: 2 additions & 54 deletions components/server/ee/src/monitoring-endpoint-ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@
*/

import * as express from "express";
import { WorkspaceHealthMonitoring } from "./workspace/workspace-health-monitoring";
import { TraceContext } from "@gitpod/gitpod-protocol/lib/util/tracing";
import { log } from "@gitpod/gitpod-protocol/lib/util/logging";
import { injectable, inject } from "inversify";
import { injectable } from "inversify";
import { registerServerMetrics } from "../../src/prometheus-metrics";
import * as prometheusClient from "prom-client";
import { registerDBMetrics } from "@gitpod/gitpod-db/lib";

@injectable()
export class MonitoringEndpointsAppEE extends WorkspaceHealthMonitoring {
@inject(WorkspaceHealthMonitoring) protected readonly workspaceHealthMonitoring: WorkspaceHealthMonitoring;

export class MonitoringEndpointsAppEE {
public create(): express.Application {
const registry = prometheusClient.register;

Expand All @@ -34,53 +29,6 @@ export class MonitoringEndpointsAppEE extends WorkspaceHealthMonitoring {
}
});

monApp.get("/workspace-health", async (req, res) => {
try {
const result = await checkWorkspaceHealth({}, this.workspaceHealthMonitoring, !!req.query.extra);
if (result.unhealthy > 0) {
console.warn("not all workspaces are healthy", result);
res.status(406).send(result);
} else {
res.status(200).send(result);
}
} catch (err) {
log.debug("failed to check workspace health", err);
res.status(500).send(err);
}
});

return monApp;
}
}

async function checkWorkspaceHealth(
ctx: TraceContext,
workspaceHealthMonitoring: WorkspaceHealthMonitoring,
extra: boolean = false,
) {
const span = TraceContext.startSpan("checkWorkspaceHealth", ctx);
const result = await workspaceHealthMonitoring.probeAllRunningWorkspaces({ span });
const numUnhealthy = result
.map((r) => (r.ok ? 0 : 1))
.reduce((acc: number, cur: number) => (acc + cur) as number, 0);
let returnValue = {
status:
numUnhealthy > 0 ? (numUnhealthy == result.length ? "unhealthy" : "partially healthy") : "fully healthy",
healthy: result.length - numUnhealthy,
unhealthy: numUnhealthy,
total: result.length,
timestamp: Date.now(),
};
if (extra && numUnhealthy > 0) {
span.finish();
return {
...returnValue,
extra: {
unhealthyWorkspaces: result.filter((r) => !r.ok),
notRunningWorkspaces: result.filter((r) => r.status !== "running"),
},
};
}
span.finish();
return returnValue;
}
156 changes: 0 additions & 156 deletions components/server/ee/src/workspace/workspace-health-monitoring.ts

This file was deleted.