Skip to content

Speed up edit-compile-run loop for workspace components #9569

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

Merged
merged 1 commit into from
Apr 26, 2022
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
7 changes: 7 additions & 0 deletions components/blobserve/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License-AGPL.txt in the project root for license information.

set -Eeuo pipefail
source /workspace/gitpod/scripts/ws-deploy.sh deployment blobserve
8 changes: 8 additions & 0 deletions components/content-service/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License-AGPL.txt in the project root for license information.


set -Eeuo pipefail
source /workspace/gitpod/scripts/ws-deploy.sh deployment content-service
7 changes: 7 additions & 0 deletions components/ee/agent-smith/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License-AGPL.txt in the project root for license information.

set -Eeuo pipefail
source /workspace/gitpod/scripts/ws-deploy.sh daemonset agent-smith
22 changes: 5 additions & 17 deletions components/image-builder-mk3/debug.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
#!/bin/bash
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License-AGPL.txt in the project root for license information.

# This script builds the image builder and replaces the current deployment with it.

docker ps &> /dev/null || (echo "You need a working Docker daemon. Maybe set DOCKER_HOST?"; exit 1)
gcloud auth list | grep typefox &>/dev/null || (echo "Login using 'gcloud auth login' for the docker push to work"; exit 1)


readonly tag
tag="dev-$(date +%s)"
leeway build -v .:docker -Dversion="${tag}" -DimageRepoBase=eu.gcr.io/gitpod-core-dev/build
devImage="eu.gcr.io/gitpod-core-dev/build/image-builder-mk3:${tag}"

kubectl patch deployment image-builder-mk3 --patch '{"spec": {"template": {"spec": {"containers": [{"name": "image-builder-mk3","imagePullPolicy":"Always","image": "'"$devImage"'"}]}}}}'
kubectl rollout restart deployment/image-builder-mk3
kubectl rollout status -w deployment/image-builder-mk3
# give the old pod time to disappear
sleep 20
gpctl debug logs image-builder-mk3
set -Eeuo pipefail
source /workspace/gitpod/scripts/ws-deploy.sh deployment image-builder-mk3
7 changes: 7 additions & 0 deletions components/registry-facade/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License-AGPL.txt in the project root for license information.

set -Eeuo pipefail
source /workspace/gitpod/scripts/ws-deploy.sh daemonset registry-facade
19 changes: 1 addition & 18 deletions components/ws-daemon/debug.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
#!/bin/bash

# ws-daemon runs as daemonset on each node which renders telepresence useless for debugging.
# This script builds ws-daemon locally, puts it in a Dockerfile, builds the image, pushes it,
# patches the daemonset and restarts all pods.
#
# This way you can test out your changes with a 30 sec turnaround.
#
# BEWARE: the properly built version of ws-daemon may behave differently.

set -Eeuo pipefail

docker ps &> /dev/null || (echo "You need a working Docker daemon. Maybe set DOCKER_HOST?"; exit 1)

version=dev-0
leeway build .:docker -Dversion="$version" -DimageRepoBase=eu.gcr.io/gitpod-core-dev/dev
devImage=eu.gcr.io/gitpod-core-dev/dev/ws-daemon:"$version"

kubectl set image daemonset ws-daemon ws-daemon="$devImage"
kubectl annotate daemonset ws-daemon kubernetes.io/change-cause="$version"
kubectl rollout restart daemonset ws-daemon
source /workspace/gitpod/scripts/ws-deploy.sh daemonset ws-daemon
8 changes: 8 additions & 0 deletions components/ws-manager/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License-AGPL.txt in the project root for license information.

set -Eeuo pipefail

source /workspace/gitpod/scripts/ws-deploy.sh deployment ws-manager
7 changes: 7 additions & 0 deletions components/ws-proxy/debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License-AGPL.txt in the project root for license information.

set -Eeuo pipefail
source /workspace/gitpod/scripts/ws-deploy.sh deployment ws-proxy false
31 changes: 31 additions & 0 deletions scripts/ws-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Copyright (c) 2022 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License-AGPL.txt in the project root for license information.

# This script builds a workspace component and updates the cluster

set -Eeuo pipefail

resource_type=$1
resource_name=$2
enable_debug=${3:-true}
version="dev-$(date +%F_T"%H-%M-%S")"
dev_image=eu.gcr.io/gitpod-core-dev/dev/$resource_name:"$version"

docker ps &> /dev/null || (echo "You need a working Docker daemon. Maybe set DOCKER_HOST?"; exit 1)
leeway build .:docker -Dversion="$version" -DimageRepoBase=eu.gcr.io/gitpod-core-dev/dev

kubectl set image "$resource_type" "$resource_name" "$resource_name"="$dev_image"
kubectl rollout restart "$resource_type" "$resource_name"
kubectl annotate "$resource_type" "$resource_name" kubernetes.io/change-cause="$version"
kubectl rollout status -w "$resource_type" "$resource_name"

while kubectl get pods -l component="$resource_name" | grep -q Terminating;
do
echo "Waiting for old pods to terminate"
sleep 3
done
if [[ "$enable_debug" = true ]]; then
gpctl debug logs "$resource_name" > /dev/null
fi