Skip to content
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

[server] Remove legacy configuration #5496

Merged
merged 1 commit into from
Sep 6, 2021
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
125 changes: 0 additions & 125 deletions chart/templates/server-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,6 @@ manager:
{{- end -}}
{{- end -}}

{{ define "rate-limiter-config" -}}
groups:
inWorkspaceUserAction:
points: 10
durationsSec: 2
functions:
openPort:
group: inWorkspaceUserAction
closePort:
group: inWorkspaceUserAction
controlAdmission:
group: inWorkspaceUserAction
shareSnapshot:
group: inWorkspaceUserAction
{{- end -}}

{{- define "stable-image-full" -}}
{{- $ := .root -}}
{{- $gp := .gp -}}
Expand Down Expand Up @@ -126,121 +110,12 @@ spec:
{{ include "gitpod.container.messagebusEnv" $this | indent 8 }}
- name: CONFIG_PATH
value: "/config/config.json"
- name: RATE_LIMITER_CONFIG
value: {{ (include "rate-limiter-config" $this) | fromYaml | toJson | quote }}
- name: GITPOD_LICENSE
value: "{{ .Values.license }}"
- name: VERSION
value: "{{ .Values.version }}"
{{- if $comp.githubApp }}
- name: GITPOD_GITHUB_APP_ENABLED
value: "{{ $comp.githubApp.enabled | default "false" }}"
- name: GITPOD_GITHUB_APP_ID
value: "{{ $comp.githubApp.appId }}"
- name: GITPOD_GITHUB_APP_WEBHOOK_SECRET
value: "{{ $comp.githubApp.webhookSecret }}"
- name: GITPOD_GITHUB_APP_AUTH_PROVIDER_ID
value: "{{ $comp.githubApp.authProviderId }}"
{{- if $comp.githubApp.baseUrl }}
- name: GHE_HOST
value: "{{ $comp.githubApp.baseUrl }}"
{{- end }}
- name: GITPOD_GITHUB_APP_CERT_PATH
value: "/github-app-cert/cert"
- name: GITPOD_GITHUB_APP_MKT_NAME
value: "{{ $comp.githubApp.marketplaceName }}"
{{- end }}
- name: GITPOD_DEFINITELY_GP_DISABLED
value: "{{ $comp.definitelyGpDisabled | default "false" }}"
- name: NODE_ENV
value: "{{ .Values.installation.stage }}"
- name: SERVER_VERSION
value: "{{ template "gitpod.comp.version" $this }}"
- name: SHLVL
value: "1"
- name: THEIA_PORT
value: "{{ .Values.components.workspace.ports.http.containerPort | toString }}"
- name: THEIA_IMAGE_REPO
value: "{{ template "gitpod.comp.imageRepo" (dict "root" . "gp" $.Values "comp" .Values.components.workspace.codeImage) }}"
- name: THEIA_VERSION
value: "{{ .Values.components.workspace.codeImage.stableVersion }}"
- name: CODE_IMAGE_REPO
value: "{{ template "gitpod.comp.imageRepo" (dict "root" . "gp" $.Values "comp" .Values.components.workspace.codeImage) }}"
- name: EXPERIMENTAL_FEATURE_FLAGS
value: {{ $comp.previewFeatureFlags | toJson | quote }}
- name: WORKSPACE_DEFAULT_IMAGE
value: "{{ template "gitpod.comp.imageFull" (dict "root" . "gp" $.Values "comp" .Values.components.workspace.defaultImage) }}"
- name: IDE_IMAGE_ALIASES
value: {{ (dict "code-latest" (include "gitpod.comp.imageFull" (dict "root" . "gp" $.Values "comp" .Values.components.workspace.codeImage)) "code" (include "stable-image-full" (dict "root" . "gp" $.Values "comp" .Values.components.workspace.codeImage))) | toJson | quote }}
{{- if $comp.blockNewUsers }}
- name: BLOCK_NEW_USERS
value: {{ $comp.blockNewUsers.enabled | quote }}
- name: BLOCK_NEW_USERS_PASSLIST
value: {{ $comp.blockNewUsers.passlist | toJson | quote }}
{{- end }}
{{- if $comp.makeNewUsersAdmin }}
- name: MAKE_NEW_USERS_ADMIN
value: {{ $comp.makeNewUsersAdmin | quote }}
{{- end }}
{{- if $comp.enableLocalApp }}
- name: ENABLE_LOCAL_APP
value: "true"
{{- end }}
{{- if $comp.oauthServer.enabled }}
- name: ENABLE_OAUTH_SERVER
value: "true"
{{- end }}
{{- if $comp.portAccessForUsersOnly }}
- name: PORT_ACCESS_FOR_USERS_ONLY
value: "true"
{{- end }}
{{- if $comp.session.maxAgeMs }}
- name: SESSION_MAX_AGE_MS
value: "{{ $comp.session.maxAgeMs | toJson }}"
{{- end }}
- name: SESSION_SECRET
value: {{ $comp.session.secret | quote }}
{{- if .Values.components.workspace.localTheia }}
- name: LOCAL_THEIA
value: "true"
{{- end }}
{{- if $comp.theiaPluginsBucketNameOverride }}
- name: THEIA_PLUGINS_BUCKET_NAME_OVERRIDE
value: {{ $comp.theiaPluginsBucketNameOverride }}
{{- end }}
{{- if .Values.devBranch }}
- name: DEV_BRANCH
value: "{{ .Values.devBranch }}"
{{- end }}
- name: WSMAN_CFG_MANAGERS
value: {{ index (include "ws-manager-list" $this | fromYaml) "manager" | default list | toJson | b64enc | quote }}
- name: GITPOD_BASEIMG_REGISTRY_WHITELIST
value: {{ $comp.defaultBaseImageRegistryWhitelist | toJson | quote }}
- name: GITPOD_DEFAULT_FEATURE_FLAGS
value: {{ $comp.defaultFeatureFlags | toJson | quote }}
{{- if $comp.incrementalPrebuilds.repositoryPasslist }}
- name: INCREMENTAL_PREBUILDS_REPO_PASSLIST
value: {{ $comp.incrementalPrebuilds.repositoryPasslist | toJson | quote }}
{{- end }}
{{- if $comp.incrementalPrebuilds.commitHistory }}
- name: INCREMENTAL_PREBUILDS_COMMIT_HISTORY
value: {{ $comp.incrementalPrebuilds.commitHistory | quote }}
{{- end }}
- name: AUTH_PROVIDERS_CONFIG
valueFrom:
configMapKeyRef:
name: auth-providers-config
key: auth-providers.json
- name: BRANDING_CONFIG
value: {{ .Values.branding | toJson | quote }}
{{- if $comp.runDbDeleter }}
- name: RUN_DB_DELETER
value: {{ $comp.runDbDeleter | quote }}
{{- end }}
- name: GITPOD_GARBAGE_COLLECTION_DISABLED
value: {{ $comp.garbageCollection.disabled | default "false" | quote }}
- name: OAUTH_SERVER_JWT_SECRET
value: {{ (randAlphaNum 20) | quote }}
{{- if $comp.serverContainer.env }}
{{ toYaml $comp.serverContainer.env | indent 8 }}
{{- end }}
Expand Down
5 changes: 0 additions & 5 deletions components/server/ee/src/container-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ import { UserDeletionServiceEE } from "./user/user-deletion-service";
import { GitHubAppSupport } from "./github/github-app-support";
import { GitLabAppSupport } from "./gitlab/gitlab-app-support";
import { Config } from "../../src/config";
import { EnvEE } from "./env";
import { Env } from "../../src/env";

export const productionEEContainerModule = new ContainerModule((bind, unbind, isBound, rebind) => {
rebind(Server).to(ServerEE).inSingletonScope();
Expand Down Expand Up @@ -88,9 +86,6 @@ export const productionEEContainerModule = new ContainerModule((bind, unbind, is
bind(AccountStatementProvider).toSelf().inRequestScope();

// various
bind(EnvEE).toSelf().inSingletonScope();
rebind(Env).to(EnvEE).inSingletonScope();

rebind(MessageBusIntegration).to(MessageBusIntegrationEE).inSingletonScope();
rebind(HostContainerMapping).to(HostContainerMappingEE).inSingletonScope();
bind(EMailDomainService).to(EMailDomainServiceImpl).inSingletonScope();
Expand Down
21 changes: 0 additions & 21 deletions components/server/ee/src/env.ts

This file was deleted.

8 changes: 0 additions & 8 deletions components/server/ee/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,12 @@ import { log } from '@gitpod/gitpod-protocol/lib/util/logging';
import { GitLabApp } from './prebuilds/gitlab-app';
import { BitbucketApp } from './prebuilds/bitbucket-app';
import { GithubApp } from './prebuilds/github-app';
import { Config, ConfigEnv } from '../../src/config';
import { EnvEE } from './env';

export class ServerEE<C extends GitpodClient, S extends GitpodServer> extends Server<C, S> {
@inject(GraphQLController) protected readonly adminGraphQLController: GraphQLController;
@inject(GithubApp) protected readonly githubApp: GithubApp;
@inject(GitLabApp) protected readonly gitLabApp: GitLabApp;
@inject(BitbucketApp) protected readonly bitbucketApp: BitbucketApp;
@inject(EnvEE) protected readonly envee: EnvEE;

protected async registerRoutes(app: express.Application): Promise<void> {
await super.registerRoutes(app);
Expand All @@ -42,9 +39,4 @@ export class ServerEE<C extends GitpodClient, S extends GitpodServer> extends Se
app.use(BitbucketApp.path, this.bitbucketApp.router);

}

// TODO(gpl) Sole purpose of this method is to make 1st deployment of Config as safe as possible. Remove afterwards!
protected getConfigFromOldEnv(): Config {
return ConfigEnv.fromEnvEE(this.envee);
}
}
4 changes: 2 additions & 2 deletions components/server/src/auth/auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ export interface AuthProviderParams extends AuthProviderEntry {
}
export function parseAuthProviderParamsFromEnv(json: object): AuthProviderParams[] {
if (Array.isArray(json)) {
return normalizeAuthProviderParamsFromEnv(json as AuthProviderParams[]);
return normalizeAuthProviderParams(json as AuthProviderParams[]);
}
return [];
}
export function normalizeAuthProviderParamsFromEnv(params: Omit<AuthProviderParams, "ownerId" | "builtin" | "status" | "verified">[]): AuthProviderParams[] {
export function normalizeAuthProviderParams(params: Omit<AuthProviderParams, "ownerId" | "builtin" | "status" | "verified">[]): AuthProviderParams[] {
const result: AuthProviderParams[] = [];
for (const p of params) {
result.push({
Expand Down
135 changes: 2 additions & 133 deletions components/server/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { GitpodHostUrl } from '@gitpod/gitpod-protocol/lib/util/gitpod-host-url';
import { AuthProviderParams, normalizeAuthProviderParamsFromEnv } from './auth/auth-provider';
import { AuthProviderParams, normalizeAuthProviderParams } from './auth/auth-provider';

import { Branding, NamedWorkspaceFeatureFlag } from '@gitpod/gitpod-protocol';

Expand All @@ -16,8 +16,6 @@ import * as fs from 'fs';
import { log } from '@gitpod/gitpod-protocol/lib/util/logging';
import { filePathTelepresenceAware, KubeStage, translateLegacyStagename } from '@gitpod/gitpod-protocol/lib/env';
import { BrandingParser } from './branding-parser';
import { Env } from './env';
import { EnvEE } from '../ee/src/env';

export const Config = Symbol("Config");
export type Config = Omit<ConfigSerialized, "hostUrl" | "chargebeeProviderOptionsFile"> & {
Expand Down Expand Up @@ -174,7 +172,7 @@ export namespace ConfigFile {
const hostUrl = new GitpodHostUrl(config.hostUrl);
let authProviderConfigs = config.authProviderConfigs
if (authProviderConfigs) {
authProviderConfigs = normalizeAuthProviderParamsFromEnv(authProviderConfigs);
authProviderConfigs = normalizeAuthProviderParams(authProviderConfigs);
}
const builtinAuthProvidersConfigured = authProviderConfigs.length > 0;
const chargebeeProviderOptions = readOptionsFromFile(filePathTelepresenceAware(config.chargebeeProviderOptionsFile || ""));
Expand Down Expand Up @@ -206,132 +204,3 @@ export namespace ConfigFile {
}
}
}

// TODO(gpl) Remove after config is deployed.
export namespace ConfigEnv {
export function validateAgainstConfigFromEnv(_n: Config, _o: Config): boolean {
const deepCopySorted = <T>(unordered: T): T => Object.keys(unordered).sort().reduce(
(obj, key) => {
let val = (unordered as any)[key];
if (typeof val === "object") {
val = deepCopySorted(val);
}
(obj as any)[key] = val;
return obj as T;
},
{} as T
);
const n = deepCopySorted(_n);
const o = deepCopySorted(_o);

// Changed
if (o.githubApp?.enabled === false && n.githubApp?.enabled === false) {
delete (o as any).githubApp;
delete (n as any).githubApp;
}
if (n.githubApp) {
delete (n as any).githubApp.certSecretName;
}

delete (n as any).chargebeeProviderOptionsFile;
if (o.devBranch === "") {
delete (o as any).devBranch;
}

// Unique
delete (n as any).workspaceGarbageCollection.startDate;
delete (o as any).workspaceGarbageCollection.startDate;

delete (n as any).oauthServer.jwtSecret;
delete (o as any).oauthServer.jwtSecret;

log.info('config', { config: JSON.stringify(n, undefined, 2) });
log.info('oldConfig', { oldConfig: JSON.stringify(o, undefined, 2) });

return JSON.stringify(n, undefined, 2) === JSON.stringify(o, undefined, 2);
}
export function fromEnv(env: Env): Config {
const config: Config = {
version: env.version,
hostUrl: env.hostUrl,
installationShortname: env.installationShortname,
devBranch: env.devBranch,
stage: env.kubeStage,
builtinAuthProvidersConfigured: env.builtinAuthProvidersConfigured,
license: env.gitpodLicense,
workspaceHeartbeat: {
intervalSeconds: env.theiaHeartbeatInterval / 1000,
timeoutSeconds: env.workspaceUserTimeout / 1000,
},
workspaceDefaults: {
ideVersion: env.theiaVersion,
ideImageRepo: env.theiaImageRepo,
ideImage: env.ideDefaultImage,
ideImageAliases: env.ideImageAliases,
workspaceImage: env.workspaceDefaultImage,
previewFeatureFlags: env.previewFeatureFlags,
defaultFeatureFlags: env.defaultFeatureFlags,
},
session: {
maxAgeMs: env.sessionMaxAgeMs,
secret: env.sessionSecret,
},
githubApp: {
enabled: env.githubAppEnabled,
appId: env.githubAppAppID,
webhookSecret: env.githubAppWebhookSecret,
authProviderId: env.githubAppAuthProviderId,
certPath: env.githubAppCertPath,
marketplaceName: env.githubAppMarketplaceName,
logLevel: env.githubAppLogLevel,
},
definitelyGpDisabled: env.definitelyGpDisabled,
workspaceGarbageCollection: {
disabled: env.garbageCollectionDisabled,
startDate: env.garbageCollectionStartDate,
chunkLimit: env.garbageCollectionLimit,
minAgeDays: env.daysBeforeGarbageCollection,
minAgePrebuildDays: env.daysBeforeGarbageCollectingPrebuilds,
contentRetentionPeriodDays: env.workspaceDeletionRetentionPeriodDays,
contentChunkLimit: env.workspaceDeletionLimit,
},
enableLocalApp: env.enableLocalApp,
authProviderConfigs: env.authProviderConfigs,
disableDynamicAuthProviderLogin: env.disableDynamicAuthProviderLogin,
brandingConfig: env.brandingConfig,
maxEnvvarPerUserCount: env.maxUserEnvvarCount,
maxConcurrentPrebuildsPerRef: env.maxConcurrentPrebuildsPerRef,
incrementalPrebuilds: {
repositoryPasslist: env.incrementalPrebuildsRepositoryPassList,
commitHistory: env.incrementalPrebuildsCommitHistory,
},
blockNewUsers: {
enabled: env.blockNewUsers,
passlist: env.blockNewUsersPassList,
},
makeNewUsersAdmin: env.makeNewUsersAdmin,
theiaPluginsBucketNameOverride: env.theiaPluginsBucketNameOverride,
defaultBaseImageRegistryWhitelist: env.defaultBaseImageRegistryWhitelist,
insecureNoDomain: env.insecureNoDomain,
runDbDeleter: env.runDbDeleter,
oauthServer: {
enabled: env.enableOAuthServer,
jwtSecret: env.oauthServerJWTSecret,
},
rateLimiter: env.rateLimiter,
contentServiceAddr: env.contentServiceAddress,
imageBuilderAddr: env.imageBuilderAddress,
codeSync: env.codeSyncConfig,
};

return config;
}
export function fromEnvEE(env: EnvEE): Config {
const config = ConfigEnv.fromEnv(env);
return {
...config,
chargebeeProviderOptions: env.chargebeeProviderOptions,
enablePayment: env.enablePayment,
}
}
}
Loading