Skip to content

Commit

Permalink
[server] Move ff google_cloud_profiler into env var/installer config (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
geropl authored Jun 20, 2024
1 parent 9380449 commit 940f234
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
10 changes: 5 additions & 5 deletions components/server/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ import { installLogCountMetric } from "@gitpod/gitpod-protocol/lib/util/logging-
import { TracingManager } from "@gitpod/gitpod-protocol/lib/util/tracing";
import { TypeORM } from "@gitpod/gitpod-db/lib";
import { dbConnectionsEnqueued, dbConnectionsFree, dbConnectionsTotal } from "./prometheus-metrics";
import { getExperimentsClientForBackend } from "@gitpod/gitpod-protocol/lib/experiments/configcat-server";
import { installCtxLogAugmenter } from "./util/log-context";
if (process.env.NODE_ENV === "development") {
require("longjohn");
Expand All @@ -71,11 +70,12 @@ installLogCountMetric();

// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
let isEnabled = await getExperimentsClientForBackend().getValueAsync("google_cloud_profiler", false, {});
while (!isEnabled) {
await new Promise((resolve) => setTimeout(resolve, 3000));
isEnabled = await getExperimentsClientForBackend().getValueAsync("google_cloud_profiler", false, {});
if (process.env.GOOGLE_CLOUD_PROFILER?.toLocaleLowerCase() !== "true") {
console.log("skipping cloud profiler, not enabled");
return;
}
console.log("starting cloud profiler");

try {
const profiler = await import("@google-cloud/profiler");
// there is no way to stop it: https://github.com/googleapis/cloud-profiler-nodejs/issues/876
Expand Down
5 changes: 5 additions & 0 deletions dev/preview/workflow/preview/deploy-gitpod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,11 @@ yq w -i "${INSTALLER_CONFIG_PATH}" experimental.workspace.networkLimits.enforce
yq w -i "${INSTALLER_CONFIG_PATH}" experimental.workspace.networkLimits.connectionsPerMinute "3000"
yq w -i "${INSTALLER_CONFIG_PATH}" experimental.workspace.networkLimits.bucketSize "3000"

#
# Enable GCP profiling in server
#
yq w -i "${INSTALLER_CONFIG_PATH}" experimental.webapp.server.gcpProfilerEnabled "true"

log_success "Generated config at $INSTALLER_CONFIG_PATH"

# ========
Expand Down
10 changes: 10 additions & 0 deletions install/installer/pkg/components/server/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
return nil
})

_ = ctx.WithExperimental(func(cfg *experimental.Config) error {
if cfg.WebApp != nil && cfg.WebApp.Server != nil && cfg.WebApp.Server.GoogleCloudProfilerEnabled {
env = append(env, corev1.EnvVar{
Name: "GOOGLE_CLOUD_PROFILER",
Value: "true",
})
}
return nil
})

volumes := make([]corev1.Volume, 0)
volumeMounts := make([]corev1.VolumeMount, 0)

Expand Down
2 changes: 2 additions & 0 deletions install/installer/pkg/config/v1/experimental/experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ type ServerConfig struct {

// @deprecated use containerRegistry.privateBaseImageAllowList instead
DefaultBaseImageRegistryWhiteList []string `json:"defaultBaseImageRegistryWhitelist"`

GoogleCloudProfilerEnabled bool `json:"gcpProfilerEnabled,omitempty"`
}

type ProxyConfig struct {
Expand Down

0 comments on commit 940f234

Please sign in to comment.