-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[server] Delete prebuild records when purging workspaces #13152
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /** | ||
| * Copyright (c) 2021 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 * as prometheusClient from "prom-client"; | ||
|
|
||
| export function registerDBMetrics(registry: prometheusClient.Registry) { | ||
| registry.registerMetric(workspacesPurgedTotal); | ||
| registry.registerMetric(prebuildWorkspacesPurgedTotal); | ||
| registry.registerMetric(prebuildInfoPurgedTotal); | ||
| registry.registerMetric(workspaceInstancePurgedTotal); | ||
| } | ||
|
|
||
| const workspacesPurgedTotal = new prometheusClient.Counter({ | ||
| name: "gitpod_server_workspaces_purged_total", | ||
| help: "Counter of workspaces hard deleted by periodic gc.", | ||
| }); | ||
|
|
||
| export function reportWorkspacePurged(count: number) { | ||
| workspacesPurgedTotal.inc(count); | ||
| } | ||
|
|
||
| const prebuildWorkspacesPurgedTotal = new prometheusClient.Counter({ | ||
| name: "gitpod_server_prebuild_workspaces_purged_total", | ||
| help: "Counter of prebuild workspaces hard deleted by periodic gc.", | ||
| }); | ||
|
|
||
| export function reportPrebuiltWorkspacePurged(count: number) { | ||
| prebuildWorkspacesPurgedTotal.inc(count); | ||
| } | ||
|
|
||
| const prebuildInfoPurgedTotal = new prometheusClient.Counter({ | ||
| name: "gitpod_server_prebuild_info_purged_total", | ||
| help: "Counter of prebuild info records hard deleted by periodic gc.", | ||
| }); | ||
|
|
||
| export function reportPrebuildInfoPurged(count: number) { | ||
| prebuildInfoPurgedTotal.inc(count); | ||
| } | ||
|
|
||
| const workspaceInstancePurgedTotal = new prometheusClient.Counter({ | ||
| name: "gitpod_server_workspace_instances_purged_total", | ||
| help: "Counter of workspace instances records hard deleted by periodic gc.", | ||
| }); | ||
|
|
||
| export function reportWorkspaceInstancePurged(count: number) { | ||
| workspaceInstancePurgedTotal.inc(count); | ||
| } | ||
|
|
||
| const prebuiltWorkspaceUpdatablePurgedTotal = new prometheusClient.Counter({ | ||
| name: "gitpod_server_prebuilt_workspace_updatable_purged_total", | ||
| help: "Counter of prebuilt workspace updatable records hard deleted by periodic gc.", | ||
| }); | ||
|
|
||
| export function reportPrebuiltWorkspaceUpdatablePurged(count: number) { | ||
| prebuiltWorkspaceUpdatablePurgedTotal.inc(count); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,18 +9,26 @@ import { WorkspaceHealthMonitoring } from "./workspace/workspace-health-monitori | |
| import { TraceContext } from "@gitpod/gitpod-protocol/lib/util/tracing"; | ||
| import { log } from "@gitpod/gitpod-protocol/lib/util/logging"; | ||
| import { injectable, inject } from "inversify"; | ||
| import { register } from "../../src/prometheus-metrics"; | ||
| 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; | ||
|
|
||
| public create(): express.Application { | ||
| const registry = prometheusClient.register; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧡 |
||
|
|
||
| prometheusClient.collectDefaultMetrics({ register: registry }); | ||
| registerDBMetrics(registry); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change was needed to keep the metrics defined in the |
||
| registerServerMetrics(registry); | ||
|
|
||
| const monApp = express(); | ||
| monApp.get("/metrics", async (req, res) => { | ||
| try { | ||
| res.set("Content-Type", register.contentType); | ||
| res.end(await register.metrics()); | ||
| res.set("Content-Type", registry.contentType); | ||
| res.end(await registry.metrics()); | ||
| } catch (ex) { | ||
| res.status(500).end(ex); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The migration for this field is still missing, right?
Are you still working on this PR/should if be in "draft" mode? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one actually has the field, just wasn't in the db model. Yes, for the other ones we need the migrations. I'm moving the PR to draft.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh really... 🙈