From 1cf92f2a3a811aaea89a4b2e192cfd931745f6e2 Mon Sep 17 00:00:00 2001 From: "Cornelius A. Ludmann" Date: Fri, 18 Dec 2020 14:48:23 +0000 Subject: [PATCH 1/2] [proxy] Remove http2 /werft with-installer /werft no-preview --- chart/config/proxy/vhost.server.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chart/config/proxy/vhost.server.conf b/chart/config/proxy/vhost.server.conf index 4f5ebc5b76f31a..2abe004c68ab11 100644 --- a/chart/config/proxy/vhost.server.conf +++ b/chart/config/proxy/vhost.server.conf @@ -3,7 +3,7 @@ {{- $useHttps := eq (include "gitpod.scheme" $this) "https" -}} {{- $builtinRegistry := (index .Values "docker-registry" "enabled") -}} {{- $builtinRegistryBypassProxy := (index .Values.components.imageBuilder.registry.bypassProxy ) -}} -{{- $listen := index ( dict "true" "443 ssl http2" "false" "80" ) ( $useHttps | toString ) -}} +{{- $listen := index ( dict "true" "443 ssl" "false" "80" ) ( $useHttps | toString ) -}} {{ if $useHttps }} {{- if eq .Values.ingressMode "hosts" }} From d690360e66d99440d6f252734074981e753eb2d6 Mon Sep 17 00:00:00 2001 From: "Cornelius A. Ludmann" Date: Fri, 18 Dec 2020 17:27:05 +0000 Subject: [PATCH 2/2] [server] Fix user bucket name calculation for minio /werft with-installer --- components/server/src/storage/commons.ts | 14 +------------- .../server/src/storage/gcloud-storage-client.ts | 10 +++++++++- .../server/src/storage/minio-storage-client.ts | 3 +++ components/server/src/storage/storage-client.ts | 4 +++- .../server/src/user/user-deletion-service.ts | 8 +++----- .../src/workspace/workspace-deletion-service.ts | 3 +-- .../src/workspace/workspace-download-service.ts | 9 +-------- 7 files changed, 21 insertions(+), 30 deletions(-) diff --git a/components/server/src/storage/commons.ts b/components/server/src/storage/commons.ts index ec2eb65031da29..b98095d2ff25cf 100644 --- a/components/server/src/storage/commons.ts +++ b/components/server/src/storage/commons.ts @@ -4,23 +4,11 @@ * See License-AGPL.txt in the project root for license information. */ -import { KubeStage } from "@gitpod/gitpod-protocol/lib/env"; - -/** - * This is the analogon to the code in ws-daemon/pkg/storage/storage_gcloud.go:bucketName - * @param userId - * @param stage - */ -export function getBucketName(userId: string, stage: KubeStage): string { - const bucketPrefix = getBucketNamePrefix(stage); - return `gitpod-${bucketPrefix}-user-${userId}`; -} - /** * This is the analogon to the code in ws-daemon/pkg/syncd/config.go:NewStorage * @param stage */ -export function getBucketNamePrefix(stage: KubeStage): string { +export function getBucketNamePrefix(stage: string): string { switch (stage) { case "production": return "prod"; diff --git a/components/server/src/storage/gcloud-storage-client.ts b/components/server/src/storage/gcloud-storage-client.ts index 3f929e32125af3..07563c0c3031ab 100644 --- a/components/server/src/storage/gcloud-storage-client.ts +++ b/components/server/src/storage/gcloud-storage-client.ts @@ -9,6 +9,7 @@ import { Storage, GetSignedUrlConfig } from "@google-cloud/storage"; import { Response } from 'request'; import { log } from '@gitpod/gitpod-protocol/lib/util/logging'; import { StorageClient, CreateSignedUrlOptions } from "./storage-client"; +import { getBucketNamePrefix } from "./commons"; export namespace GCloudStorageClient { export interface Params { @@ -25,13 +26,15 @@ export class GCloudStorageClient implements StorageClient { static URL_EXPIRES_IN_SECONDS = 600; protected authenticatedStorage: Storage; + protected stage: string; constructor(protected params: GCloudStorageClient.Params) { - const { keyFilename, projectId } = params; + const { keyFilename, projectId, stage } = params; this.authenticatedStorage = new Storage({ keyFilename, projectId }); + this.stage = stage; } get storage(): Storage { @@ -114,4 +117,9 @@ export class GCloudStorageClient implements StorageClient { throw new Error(`Unable to ${description}, status code: ${response.statusCode}.`); } } + + bucketName(userId: string): string { + const bucketPrefix = getBucketNamePrefix(this.stage); + return `gitpod-${bucketPrefix}-user-${userId}`; + } } diff --git a/components/server/src/storage/minio-storage-client.ts b/components/server/src/storage/minio-storage-client.ts index 69d77984512dfe..6fa272726c979f 100644 --- a/components/server/src/storage/minio-storage-client.ts +++ b/components/server/src/storage/minio-storage-client.ts @@ -57,4 +57,7 @@ export class MinIOStorageClient implements StorageClient { await this.client.makeBucket(bucketName, this.region); } + bucketName(userId: string): string { + return `gitpod-user-${userId}`; + } } \ No newline at end of file diff --git a/components/server/src/storage/storage-client.ts b/components/server/src/storage/storage-client.ts index ca7a545f05303c..fe7c52a286826c 100644 --- a/components/server/src/storage/storage-client.ts +++ b/components/server/src/storage/storage-client.ts @@ -4,7 +4,6 @@ * See License-AGPL.txt in the project root for license information. */ - export const StorageClient = Symbol("StorageClient") export interface StorageClient { @@ -22,6 +21,9 @@ export interface StorageClient { // ensureBucketExists makes sure the bucket exists and creates it if needed ensureBucketExists(bucketName: string): Promise; + + // bucketName returns the bucket name for a given user + bucketName(userId: string): string; } export interface CreateSignedUrlOptions { diff --git a/components/server/src/user/user-deletion-service.ts b/components/server/src/user/user-deletion-service.ts index 8579bb60a0fe6d..8147def264d4a0 100644 --- a/components/server/src/user/user-deletion-service.ts +++ b/components/server/src/user/user-deletion-service.ts @@ -15,8 +15,6 @@ import { log } from '@gitpod/gitpod-protocol/lib/util/logging'; import { WorkspaceManagerClientProvider } from "@gitpod/ws-manager/lib/client-provider"; import { StopWorkspaceRequest, StopWorkspacePolicy } from "@gitpod/ws-manager/lib"; import { WorkspaceDeletionService } from "../workspace/workspace-deletion-service"; -import { getBucketName } from "../storage/commons"; -import { KubeStage } from "@gitpod/gitpod-protocol/lib/env"; import { AuthProviderService } from "../auth/auth-provider-service"; @injectable() @@ -74,7 +72,7 @@ export class UserDeletionService { // UserStorageResourcesDB this.userStorageResourcesDb.deleteAllForUser(user.id), // Bucket - this.deleteUserBucket(id, this.env.kubeStage) + this.deleteUserBucket(id) ]); } @@ -117,10 +115,10 @@ export class UserDeletionService { })); } - protected async deleteUserBucket(userId: string, stage: KubeStage) { + protected async deleteUserBucket(userId: string) { const client = this.storageClient; if (client) { - const bucketName = getBucketName(userId, stage); + const bucketName = this.storageClient.bucketName(userId); try { await client.deleteBucket(bucketName); } catch(error) { diff --git a/components/server/src/workspace/workspace-deletion-service.ts b/components/server/src/workspace/workspace-deletion-service.ts index a1f81600918016..c9cbf6e5199dea 100644 --- a/components/server/src/workspace/workspace-deletion-service.ts +++ b/components/server/src/workspace/workspace-deletion-service.ts @@ -11,7 +11,6 @@ import { StorageClient } from "../storage/storage-client"; import { Env } from "../env"; import { TracedWorkspaceDB, DBWithTracing } from "@gitpod/gitpod-db/lib/traced-db"; import { TraceContext } from "@gitpod/gitpod-protocol/lib/util/tracing"; -import { getBucketName } from "../storage/commons"; @injectable() export class WorkspaceDeletionService { @@ -91,7 +90,7 @@ export class WorkspaceDeletionService { let prefix = `workspaces/${ws.id}`; try { - const bucketName = getBucketName(ws.ownerId, this.env.kubeStage); + const bucketName = this.storageClient.bucketName(ws.ownerId); if (includeSnapshots) { await this.storageClient.deleteObjects(bucketName, prefix); } else { diff --git a/components/server/src/workspace/workspace-download-service.ts b/components/server/src/workspace/workspace-download-service.ts index c970a5146cbc88..47ccc806086ce2 100644 --- a/components/server/src/workspace/workspace-download-service.ts +++ b/components/server/src/workspace/workspace-download-service.ts @@ -49,14 +49,7 @@ export class WorkspaceDownloadService { return; } - // we must harmonize this with https://github.com/TypeFox/gitpod/blob/8fc0c82a55da1ca4b5f6ab61deb9c9cd49eff644/components/ws-daemon/pkg/storage/storage.go - // Beware: do NOT use env.kube_stage which has some "legacy" translation mechanism which doesn't fit the ws-daemon mapping. - const stage: string = ({ - "production": "prod", - "staging": "prodcopy", - } as any)[process.env.KUBE_STAGE || ""] || "dev"; - - const bucketName = `gitpod-${stage}-user-${wsi.ownerId}`; + const bucketName = this.storageClient.bucketName(userId); const path = `/workspaces/${workspaceId}/full.tar`; const signedUrl = await this.storageClient.createSignedUrl(bucketName, path, "read", { promptSaveAs: `${workspaceId}.tar`