diff --git a/.werft/util/kubectl.ts b/.werft/util/kubectl.ts index 667684ba897794..7c8df23c321996 100644 --- a/.werft/util/kubectl.ts +++ b/.werft/util/kubectl.ts @@ -68,14 +68,7 @@ async function wipePreviewEnvironmentInstaller(namespace: string, kubeconfig: st }).code === 0; if (hasGitpodConfigmap) { werft.log(slice, `${namespace} has Gitpod configmap, proceeding with removal`); - const inWerftFolder = exec(`pwd`, { slice, dontCheckRc: true }).stdout.trim().endsWith(".werft"); - if (inWerftFolder) { - // used in .werft/wipe-devstaging.yaml on preview environment clean-up - exec(`./util/uninstall-gitpod.sh ${namespace} ${kubeconfig}`, { slice }); - } else { - // used in .werft/build.yaml on 'with-clean-slate-deployment=true' - exec(`./.werft/util/uninstall-gitpod.sh ${namespace} ${kubeconfig}`, { slice }); - } + exec(`./util/uninstall-gitpod.sh ${namespace} ${kubeconfig}`, { slice }); } else { werft.log(slice, `There is no Gitpod configmap, moving on`); } diff --git a/.werft/wipe-devstaging.ts b/.werft/wipe-devstaging.ts deleted file mode 100644 index ad46d24ade842d..00000000000000 --- a/.werft/wipe-devstaging.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { Werft } from "./util/werft"; -import { wipePreviewEnvironmentAndNamespace, listAllPreviewNamespaces, helmInstallName } from "./util/kubectl"; -import * as Tracing from "./observability/tracing"; -import { SpanStatusCode } from "@opentelemetry/api"; -import { ExecOptions } from "./util/shell"; -import { env } from "./util/util"; -import { CORE_DEV_KUBECONFIG_PATH } from "./jobs/build/const"; - -// Will be set once tracing has been initialized -let werft: Werft; - -async function wipePreviewCluster(shellOpts: ExecOptions) { - const namespace_raw = process.env.NAMESPACE; - const namespaces: string[] = []; - if (namespace_raw === "" || !namespace_raw) { - werft.log("wipe", "Going to wipe all namespaces"); - listAllPreviewNamespaces(CORE_DEV_KUBECONFIG_PATH, shellOpts).map((ns) => namespaces.push(ns)); - } else { - werft.log("wipe", `Going to wipe namespace ${namespace_raw}`); - namespaces.push(namespace_raw); - } - - for (const namespace of namespaces) { - await wipePreviewEnvironmentAndNamespace(helmInstallName, namespace, CORE_DEV_KUBECONFIG_PATH, { - ...shellOpts, - slice: "wipe", - }); - } -} - -// clean up the dev cluster in gitpod-core-dev -async function devCleanup() { - await wipePreviewCluster(env("")); -} - -Tracing.initialize() - .then(() => { - werft = new Werft("wipe-devstaging"); - werft.phase("wipe"); - }) - .then(() => devCleanup()) - .then(() => werft.done("wipe")) - .then(() => werft.endAllSpans()) - .catch((err) => { - werft.rootSpan.setStatus({ - code: SpanStatusCode.ERROR, - message: err, - }); - werft.endAllSpans(); - console.log("Error", err); - // Explicitly not using process.exit as we need to flush tracing, see tracing.js - process.exitCode = 1; - }); diff --git a/.werft/wipe-devstaging.yaml b/.werft/wipe-devstaging.yaml deleted file mode 100644 index 7a1790b0e0d8f2..00000000000000 --- a/.werft/wipe-devstaging.yaml +++ /dev/null @@ -1,49 +0,0 @@ -args: - - name: namespace - desc: "The namespace to remove - if left empty this job removes all preview environments" - required: false -pod: - serviceAccount: werft - nodeSelector: - dev/workload: builds - imagePullSecrets: - - name: eu-gcr-io-pull-secret - volumes: - - name: gcp-sa - secret: - secretName: gcp-sa-gitpod-dev-deployer - containers: - - name: wipe-devstaging - image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:aledbf-dl.1 - workingDir: /workspace - imagePullPolicy: IfNotPresent - volumeMounts: - - name: gcp-sa - mountPath: /mnt/secrets/gcp-sa - readOnly: true - env: - - name: HONEYCOMB_DATASET - value: "werft" - - name: HONEYCOMB_API_KEY - valueFrom: - secretKeyRef: - name: honeycomb-api-key - key: apikey - command: - - bash - - -c - - | - sleep 1 - set -Eeuo pipefail - - werft log phase prepare - gcloud auth activate-service-account --key-file /mnt/secrets/gcp-sa/service-account.json - - export NAMESPACE="{{ .Annotations.namespace }}" - sudo chown -R gitpod:gitpod /workspace - - KUBECONFIG=/workspace/gitpod/kubeconfigs/core-dev gcloud container clusters get-credentials core-dev --zone europe-west1-b --project gitpod-core-dev - - cd .werft - yarn install - npx ts-node ./wipe-devstaging.ts