From 70159368e0744670300da59c4848f0873741faef Mon Sep 17 00:00:00 2001 From: Gero Posmyk-Leinemann Date: Tue, 14 Sep 2021 13:25:35 +0000 Subject: [PATCH] [server] Set Probot log level according to config --- chart/templates/_helpers.tpl | 8 +++++++- chart/templates/server-configmap.yaml | 1 + chart/values.yaml | 1 - components/server/ee/src/prebuilds/github-app.ts | 15 +++++++++++++-- components/server/src/config.ts | 4 ++-- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index b2090dbbde6cbc..d2921ad191406e 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -183,7 +183,13 @@ env: - name: GITPOD_INSTALLATION_SHORTNAME value: {{ template "gitpod.installation.shortname" . }} - name: LOG_LEVEL - value: {{ $gp.log.level | default "debug" | lower | quote }} + value: {{ template "gitpod.loglevel" }} +{{- end -}} + +{{- define "gitpod.loglevel" -}} +{{- $ := .root -}} +{{- $gp := .gp -}} +{{ $gp.log.level | default "debug" | lower | quote }} {{- end -}} {{- define "gitpod.container.analyticsEnv" -}} diff --git a/chart/templates/server-configmap.yaml b/chart/templates/server-configmap.yaml index b0c0e5500ca96b..1150959fe36186 100644 --- a/chart/templates/server-configmap.yaml +++ b/chart/templates/server-configmap.yaml @@ -23,6 +23,7 @@ data: {{- if .Values.devBranch }} "devBranch": "{{ .Values.devBranch }}", {{- end }} + "logLevel": {{ template "gitpod.loglevel" }}, "license": "{{ .Values.license }}", "workspaceHeartbeat": {{ $comp.workspaceHeartbeat | toJson }}, "workspaceDefaults": { diff --git a/chart/values.yaml b/chart/values.yaml index c4a2453d6e02eb..f5b48a8ae8e309 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -299,7 +299,6 @@ components: githubApp: enabled: false authProviderId: "Public-GitHub" - logLevel: "trace" blockNewUsers: enabled: false passlist: [] diff --git a/components/server/ee/src/prebuilds/github-app.ts b/components/server/ee/src/prebuilds/github-app.ts index 45cac4bdaee5cc..93aea8e4c2231c 100644 --- a/components/server/ee/src/prebuilds/github-app.ts +++ b/components/server/ee/src/prebuilds/github-app.ts @@ -12,7 +12,7 @@ import { injectable, inject } from 'inversify'; import { Config } from '../../../src/config'; import { AppInstallationDB, TracedWorkspaceDB, DBWithTracing, UserDB, WorkspaceDB, ProjectDB, TeamDB } from '@gitpod/gitpod-db/lib'; import * as express from 'express'; -import { log, LogContext } from '@gitpod/gitpod-protocol/lib/util/logging'; +import { log, LogContext, LogrusLogLevel } from '@gitpod/gitpod-protocol/lib/util/logging'; import { WorkspaceConfig, User, Project, StartPrebuildResult } from '@gitpod/gitpod-protocol'; import { MessageBusIntegration } from '../../../src/workspace/messagebus-integration'; import { GithubAppRules } from './github-app-rules'; @@ -55,7 +55,7 @@ export class GithubApp { appId: config.githubApp.appId, privateKey: GithubApp.loadPrivateKey(config.githubApp.certPath), secret: config.githubApp.webhookSecret, - logLevel: config.githubApp.logLevel as Options["logLevel"], + logLevel: GithubApp.mapToGitHubLogLevel(config.logLevel), baseUrl: config.githubApp.baseUrl, }) }); @@ -393,4 +393,15 @@ export namespace GithubApp { } } } + + export function mapToGitHubLogLevel(logLevel: LogrusLogLevel): Options["logLevel"] { + switch (logLevel) { + case "warning": + return "warn"; + case "panic": + return "fatal"; + default: + return logLevel; + } + } } diff --git a/components/server/src/config.ts b/components/server/src/config.ts index 0462defbbf2ee6..692b0aa84b1407 100644 --- a/components/server/src/config.ts +++ b/components/server/src/config.ts @@ -13,7 +13,7 @@ import { RateLimiterConfig } from './auth/rate-limiter'; import { CodeSyncConfig } from './code-sync/code-sync-service'; import { ChargebeeProviderOptions, readOptionsFromFile } from "@gitpod/gitpod-payment-endpoint/lib/chargebee"; import * as fs from 'fs'; -import { log } from '@gitpod/gitpod-protocol/lib/util/logging'; +import { log, LogrusLogLevel } from '@gitpod/gitpod-protocol/lib/util/logging'; import { filePathTelepresenceAware, KubeStage, translateLegacyStagename } from '@gitpod/gitpod-protocol/lib/env'; import { BrandingParser } from './branding-parser'; @@ -51,6 +51,7 @@ export interface ConfigSerialized { stage: string; devBranch?: string; insecureNoDomain: boolean; + logLevel: LogrusLogLevel; license?: string; @@ -74,7 +75,6 @@ export interface ConfigSerialized { authProviderId: string; certPath: string; marketplaceName: string; - logLevel?: string; }; definitelyGpDisabled: boolean;