Skip to content
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

[kots]: allow deployment whilst installer job running #9471

Merged
merged 1 commit into from
Apr 25, 2022

Conversation

mrsimonemms
Copy link
Contributor

@mrsimonemms mrsimonemms commented Apr 21, 2022

Description

In this PR, install means "install or upgrade" unless otherwise stated

Allow deployment whilst an existing Installer job running. This should allow for recovery in the following scenarios:

  1. Deployment failed/stopped mid-install and user wants to redeploy same version
  2. Deployment failed/stopped mid-install and user wants to deploy a different version
  3. User decides to trigger a new deployment whilst an existing deployment is in progress

This appends the cursor to the job name. This is necessary to allow us to change the image on the container, effectively replacing the existing job. The first part of this script then removes any already running jobs/pods, thus clearing up the state.

It then rolls back (or uninstalls if it's the first deployment) before starting the next helm upgrade. For a user, this should then allow them to unstick their issues.

Setting of the ttlSecondsAfterFinished to 0 means that the "redeploy" button works as soon as the job as finished

How to test

Get your Helm deployment into either a pending-install or pending-upgrade state. The script does this anyway for an upgrade, but to do this manually, suggest starting an install job then running:

kubectl delete jobs.batch -n gitpod -l component=gitpod-installer --force --grace-period 0
kubectl delete pod -n gitpod -l component=gitpod-installer --force --grace-period 0

The reason it doesn't work for a redeployment is because Kubernetes sees the request to deploy a job called installer-1234 and, as that's already deployed, it thinks "oooh, nothing to do". There seems to be no way of generating a random value at deploy-time with KOTS - have asked as a question in our channel

Ensure by running helm ls -aA.

Now, run the following - all of these should result in a successful deployment, and will need you to get it to enter the same "pending" state as above:

  1. Redeploy the existing deployment.
  2. Publish a new version to KOTS and deploy that

For regression, we should also test:

  1. A fresh installation (run helm un -n gitpod gitpod)
  2. An upgrade that's not in a "pending" state
  3. A redeployment that's not in a "pending" state

Release Notes

[kots]: allow deployment whilst installer job running

Documentation

@mrsimonemms
Copy link
Contributor Author

mrsimonemms commented Apr 21, 2022

/werft run no-preview publish-to-kots with-clean-deployment

👍 started the job as gitpod-build-sje-kots-install-cancel.2

@mrsimonemms mrsimonemms force-pushed the sje/kots-install-cancel branch from b2abce6 to e5f610c Compare April 22, 2022 09:44
@roboquat roboquat added size/M and removed size/L labels Apr 22, 2022
@mrsimonemms mrsimonemms force-pushed the sje/kots-install-cancel branch from e5f610c to 2c5e20e Compare April 22, 2022 09:45
@mrsimonemms mrsimonemms changed the title Sje/kots install cancel WIP: [kots]: allow deployment whilst installer job running Apr 22, 2022
@mrsimonemms mrsimonemms force-pushed the sje/kots-install-cancel branch from 2c5e20e to edfad6b Compare April 22, 2022 10:52
@mrsimonemms
Copy link
Contributor Author

mrsimonemms commented Apr 22, 2022

/werft run no-preview publish-to-kots

👍 started the job as gitpod-build-sje-kots-install-cancel.6

@mrsimonemms
Copy link
Contributor Author

mrsimonemms commented Apr 22, 2022

/werft run no-preview publish-to-kots with-clean-deployment

👍 started the job as gitpod-build-sje-kots-install-cancel.7

@mrsimonemms
Copy link
Contributor Author

mrsimonemms commented Apr 22, 2022

/werft run no-preview publish-to-kots

👍 started the job as gitpod-build-sje-kots-install-cancel.9

@mrsimonemms mrsimonemms force-pushed the sje/kots-install-cancel branch from 99b6af4 to 5c4a263 Compare April 22, 2022 13:50
@roboquat roboquat added size/S and removed size/M labels Apr 22, 2022
@mrsimonemms mrsimonemms force-pushed the sje/kots-install-cancel branch 2 times, most recently from 2149ecb to e3cbae6 Compare April 22, 2022 14:27
@mrsimonemms
Copy link
Contributor Author

mrsimonemms commented Apr 22, 2022

/werft run no-preview publish-to-kots

👍 started the job as gitpod-build-sje-kots-install-cancel.13
(with .werft/ from main)

@mrsimonemms mrsimonemms changed the title WIP: [kots]: allow deployment whilst installer job running [kots]: allow deployment whilst installer job running Apr 22, 2022
@mrsimonemms mrsimonemms marked this pull request as ready for review April 22, 2022 14:46
@mrsimonemms mrsimonemms requested a review from a team April 22, 2022 14:46
@github-actions github-actions bot added the team: delivery Issue belongs to the self-hosted team label Apr 22, 2022
echo "Gitpod: Killing any in-progress installations"

kubectl delete jobs.batch -n {{repl Namespace }} -l component=gitpod-installer,cursor!={{repl Cursor }} --force || true
kubectl delete pod -n {{repl Namespace }} -l component=gitpod-installer,cursor!={{repl Cursor }} --force || true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a --grace-period=0 could be added too, just to be sure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call

@nandajavarma
Copy link
Contributor

nandajavarma commented Apr 22, 2022

Tested and works like a charm! LGTM! Merging on Friday early evening is bad luck. Will approve on Monday 🤓

@mrsimonemms
Copy link
Contributor Author

Merging on Friday early evening is bad luck

You are very wise

@mrsimonemms mrsimonemms force-pushed the sje/kots-install-cancel branch from e3cbae6 to 52ebc12 Compare April 23, 2022 15:13
Copy link
Contributor

@corneliusludmann corneliusludmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since @nandajavarma is OOO today, I'm happy to add my approval. I am very curious to see how well this works in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note size/S team: delivery Issue belongs to the self-hosted team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants