Skip to content

[kots]: delete workspace pods before installing Gitpod #13215

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 2 commits into from
Sep 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
1 change: 1 addition & 0 deletions install/installer/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ packages:
- "scripts/*.sh"
deps:
- :app
- dev/gpctl:app
argdeps:
- imageRepoBase
config:
Expand Down
1 change: 1 addition & 0 deletions install/installer/leeway.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RUN apk add --no-cache bash curl jq openssh-keygen yq \
&& curl -L "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl
COPY install-installer--app/installer install-installer--app/provenance-bundle.jsonl /app/
COPY dev-gpctl--app/gpctl /app/
COPY scripts/*.sh /app/scripts/
ENTRYPOINT [ "/app/installer" ]
CMD [ "help" ]
24 changes: 24 additions & 0 deletions install/installer/scripts/kots-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ catch() {
exit "${1}"
}

stop_running_workspaces() {
echo "Gitpod: shut down any running workspaces/image-builders"

# Create a context for gpctl
kubectl config set-context "${NAMESPACE}"
kubectl config use-context "${NAMESPACE}"
# gpctl doesn't have a namespace flag
kubectl config set-context --current --namespace="${NAMESPACE}"

# Get list of workspace instances from gpctl
for instance in $(/app/gpctl workspaces list -o json | jq -r 'select(. != null) | .[] | .Instance'); do
echo "Gitpod: shutting down workspace ${instance}"
/app/gpctl workspaces stop "${instance}" || eval "$(echo "Gitpod: retrying shutting down workspace" && \
sleep 10 && \
/app/gpctl workspaces stop "${instance}")"
done

# Delete the context
kubectl config unset "contexts.${NAMESPACE}"
kubectl config unset current-context
}

main() {
if [ "${INSTALLER_DRY_RUN}" != "true" ]; then
echo "Gitpod: Killing any in-progress installations"
Expand Down Expand Up @@ -156,6 +178,8 @@ EOF
HELM_TIMEOUT="1h"
fi

stop_running_workspaces

# The long timeout is to ensure the TLS cert is created (if required)
echo "Gitpod: Apply the Kubernetes objects with timeout of ${HELM_TIMEOUT}"
helm upgrade \
Expand Down
2 changes: 1 addition & 1 deletion install/kots/manifests/gitpod-installation-status.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
containers:
- name: installation-status
# This will normally be the release tag
image: "eu.gcr.io/gitpod-core-dev/build/installer:tar-installer-env-refactor.2"
image: "eu.gcr.io/gitpod-core-dev/build/installer:sje-installer-kill-workspaces.14"
envFrom:
- configMapRef:
name: gitpod-kots-config
Expand Down
2 changes: 1 addition & 1 deletion install/kots/manifests/gitpod-installer-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
containers:
- name: installer
# This will normally be the release tag
image: "eu.gcr.io/gitpod-core-dev/build/installer:tar-installer-env-refactor.2"
image: "eu.gcr.io/gitpod-core-dev/build/installer:sje-installer-kill-workspaces.14"
volumeMounts:
- mountPath: /mnt/node0
name: node-fs0
Expand Down
14 changes: 14 additions & 0 deletions install/kots/manifests/kots-preflight.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ spec:
namespace: '{{repl Namespace }}'
podSpec:
containers: []
- clusterResources:
namespaces:
- '{{repl Namespace }}'
- run:
collectorName: database
image: eu.gcr.io/gitpod-core-dev/build/kots-config-check/database:sje-kots-config-check.9
Expand Down Expand Up @@ -429,3 +432,14 @@ spec:
message: Registry is accessible
- fail:
message: Registry is inaccessible. Please check your network and firewall settings
- textAnalyze:
checkName: Check running workspaces
fileName: cluster-resources/pods/{{repl Namespace }}.json
regex: '"component": "workspace"'
outcomes:
- pass:
when: "false"
message: No running workspaces. Any workspaces started during the deployment process will be stopped.
- fail:
when: "true"
message: There are running workspaces. These will be stopped during the deployment process.