-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Tune JB backend dev loop #12390
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
Tune JB backend dev loop #12390
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# See https://stackoverflow.com/a/47607857/961588 | ||
systemProp.org.gradle.internal.http.socketTimeout=100000 | ||
systemProp.org.gradle.internal.http.connectionTimeout=100000 | ||
systemProp.org.gradle.internal.http.connectionTimeout=100000 | ||
# See https://docs.gradle.org/current/userguide/build_cache.html#sec:build_cache_enable | ||
org.gradle.caching=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/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. | ||
|
||
if [ "${NO_VERIFY_JB_PLUGIN}" == "true" ]; then | ||
echo "build.sh: skip verify plugin step" | ||
else | ||
./gradlew -PsupervisorApiProjectPath=components-supervisor-api-java--lib/ -PgitpodProtocolProjectPath=components-gitpod-protocol-java--lib/ -PenvironmentName="$JB_QUALIFIER" runPluginVerifier | ||
fi | ||
./gradlew -PsupervisorApiProjectPath=components-supervisor-api-java--lib/ -PgitpodProtocolProjectPath=components-gitpod-protocol-java--lib/ -PenvironmentName="$JB_QUALIFIER" buildPlugin | ||
unzip ./build/distributions/gitpod-remote.zip -d ./build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/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 | ||
|
||
# This script builds the backend plugin and updates the IDE config map. | ||
|
||
qualifier=${1:-latest} | ||
echo "Plugin Qualifier: $qualifier" | ||
|
||
# TODO(AK) optimize to produce a new version only if plugin was rebuilt | ||
version="dev-jb-backend-plugin-$(date +%F_T"%H-%M-%S")" | ||
echo "Image Version: $version" | ||
|
||
bldfn="/tmp/build-$version.tar.gz" | ||
|
||
docker ps &> /dev/null || (echo "You need a working Docker daemon. Maybe set DOCKER_HOST?"; exit 1) | ||
leeway build -DnoVerifyJBPlugin=true -Dversion="$version" -DimageRepoBase=eu.gcr.io/gitpod-core-dev/build .:"$qualifier" --save "$bldfn" | ||
dev_image="$(tar xfO "$bldfn" ./imgnames.txt | head -n1)" | ||
echo "Dev Image: $dev_image" | ||
|
||
if [ "$qualifier" == "stable" ]; then | ||
prop="pluginImage" | ||
else | ||
prop="pluginLatestImage" | ||
fi | ||
|
||
cf_patch=$(kubectl get cm server-ide-config -o=json | jq '.data."config.json"' |jq -r) | ||
cf_patch=$(echo "$cf_patch" |jq ".ideOptions.options.intellij.$prop = \"$dev_image\"") | ||
cf_patch=$(echo "$cf_patch" |jq ".ideOptions.options.goland.$prop = \"$dev_image\"") | ||
cf_patch=$(echo "$cf_patch" |jq ".ideOptions.options.pycharm.$prop = \"$dev_image\"") | ||
cf_patch=$(echo "$cf_patch" |jq ".ideOptions.options.phpstorm.$prop = \"$dev_image\"") | ||
cf_patch=$(echo "$cf_patch" |jq tostring) | ||
cf_patch="{\"data\": {\"config.json\": $cf_patch}}" | ||
|
||
kubectl patch cm server-ide-config --type=merge -p "$cf_patch" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/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 | ||
|
||
# This script builds the backend plugin, replaces the backend plugin on a running workspace and restarts the JB backend. | ||
|
||
workspaceUrl=${1-} | ||
[ -z "$workspaceUrl" ] && echo "Please provide a workspace URL as first argument." && exit 1 | ||
workspaceUrl=$(echo "$workspaceUrl" |sed -e "s/\/$//") | ||
echo "URL: $workspaceUrl" | ||
|
||
workspaceDesc=$(gpctl workspaces describe "$workspaceUrl" -o=json) | ||
|
||
podName=$(echo "$workspaceDesc" | jq .runtime.pod_name -r) | ||
echo "Pod: $podName" | ||
|
||
workspaceId=$(echo "$workspaceDesc" | jq .metadata.meta_id -r) | ||
echo "ID: $workspaceId" | ||
|
||
clusterHost=$(kubectl exec -it "$podName" -- printenv GITPOD_WORKSPACE_CLUSTER_HOST |sed -e "s/\s//g") | ||
echo "Cluster Host: $clusterHost" | ||
|
||
qualifier=$(kubectl exec -it "$podName" -- printenv JETBRAINS_BACKEND_QUALIFIER |sed -e "s/\s//g") | ||
echo "Version Qualifier: $qualifier" | ||
|
||
# prepare build | ||
component="gitpod-remote-$qualifier-$(date +%F_T"%H-%M-%S")" | ||
tarDir="/tmp/hot-swap/$component" | ||
mkdir -p "$tarDir" | ||
echo "Build Dir: $tarDir" | ||
|
||
# prepare ssh | ||
ownerToken=$(kubectl get pod "$podName" -o=json | jq ".metadata.annotations.\"gitpod\/ownerToken\"" -r) | ||
sshConfig="$tarDir/ssh-config" | ||
echo "Host $workspaceId" > "$sshConfig" | ||
echo " Hostname \"$workspaceId.ssh.$clusterHost\"" >> "$sshConfig" | ||
echo " User \"$workspaceId#$ownerToken\"" >> "$sshConfig" | ||
|
||
# build | ||
tarFile="$tarDir/build.tar.gz" | ||
leeway build -DnoVerifyJBPlugin=true .:"plugin-$qualifier" --save "$tarFile" | ||
tar -xf "$tarFile" -C "$tarDir" | ||
|
||
# upload | ||
uploadDest="/ide-desktop-plugins/$component" | ||
echo "Upload Dest: $uploadDest" | ||
scp -F "$sshConfig" -r "$tarDir/build/gitpod-remote" "$workspaceId":"$uploadDest" | ||
|
||
# link | ||
link="/ide-desktop/backend/plugins/gitpod-remote" | ||
ssh -F "$sshConfig" "$workspaceId" ln -sfn "$uploadDest" "$link" | ||
echo "Link: $link -> $uploadDest" | ||
|
||
# restart | ||
ssh -F "$sshConfig" "$workspaceId" curl http://localhost:24000/restart | ||
echo "Restarted: please reconenct to JB backend to try new changes." | ||
|
||
# clean up | ||
rm -rf "$tarDir" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (c) 2021 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. | ||
|
||
FROM alpine:3.16 as base_builder | ||
RUN mkdir /ide-desktop-plugins | ||
|
||
# for debugging | ||
# FROM alpine:3.16 | ||
FROM scratch | ||
ARG JETBRAINS_BACKEND_QUALIFIER | ||
# ensures right permissions for /ide-desktop-plugins | ||
COPY --from=base_builder --chown=33333:33333 /ide-desktop-plugins/ /ide-desktop-plugins/ | ||
COPY --chown=33333:33333 components-ide-jetbrains-backend-plugin--plugin-${JETBRAINS_BACKEND_QUALIFIER}/build/gitpod-remote /ide-desktop-plugins/gitpod-remote/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/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 configure remote debugging in a workspace running in a preview environment. | ||
# It updates VM options with remote debug agent, restart the JB backend to apply them, | ||
# and start port forwarding of the remote debug port. You can configure `Remote JVM Debug` | ||
# run configuration using the forwarded port. | ||
# | ||
# ./remote-debug.sh <workspaceUrl> (<localPort>)? | ||
|
||
workspaceUrl=${1-} | ||
[ -z "$workspaceUrl" ] && echo "Please provide a workspace URL as first argument." && exit 1 | ||
workspaceUrl=$(echo "$workspaceUrl" |sed -e "s/\/$//") | ||
echo "URL: $workspaceUrl" | ||
|
||
workspaceDesc=$(gpctl workspaces describe "$workspaceUrl" -o=json) | ||
|
||
podName=$(echo "$workspaceDesc" | jq .runtime.pod_name -r) | ||
echo "Pod: $podName" | ||
|
||
workspaceId=$(echo "$workspaceDesc" | jq .metadata.meta_id -r) | ||
echo "ID: $workspaceId" | ||
|
||
clusterHost=$(kubectl exec -it "$podName" -- printenv GITPOD_WORKSPACE_CLUSTER_HOST |sed -e "s/\s//g") | ||
echo "Cluster Host: $clusterHost" | ||
|
||
# prepare ssh | ||
ownerToken=$(kubectl get pod "$podName" -o=json | jq ".metadata.annotations.\"gitpod\/ownerToken\"" -r) | ||
sshConfig="/tmp/$workspaceId-ssh-config" | ||
echo "Host $workspaceId" > "$sshConfig" | ||
echo " Hostname \"$workspaceId.ssh.$clusterHost\"" >> "$sshConfig" | ||
echo " User \"$workspaceId#$ownerToken\"" >> "$sshConfig" | ||
|
||
while true | ||
do | ||
# configure remote debugging | ||
remotePort=$(ssh -F "$sshConfig" "$workspaceId" curl http://localhost:24000/debug) | ||
if [ -n "$remotePort" ]; then | ||
localPort=${2-$remotePort} | ||
# forward | ||
echo "Forwarding Debug Port: $localPort -> $remotePort" | ||
ssh -F "$sshConfig" -L "$remotePort:localhost:$localPort" "$workspaceId" -N | ||
fi | ||
|
||
sleep 1 | ||
done |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion(minor): spotted this one in the Loom you shared 😄