-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Make db waiter to wait latest migration #18455
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
Conversation
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.
Generating a go constant directly next to database.go as part of the yarn build
in gitpod-db seems to be less error prone than piping it through installer. Also keeps the interface for service-waiter simpler.
I wonder can we smoke test it in preview envs to see behaviour actual pods on crash? It should be possible to change DB, i.e. rename latest migration and then delete the server to observer? and then undo and check again? |
@akosyakov I tried to do it yesterday with leeway dev:preview
it should be the same with what we're doing in how to test section (open PR with gitpod topic), will try |
As part of #18455 (comment) Smoke tested with leeway dev:preview, with a migration hangs for 10 minutes, we can see:
Going to push remind commits. cc @svenefftinge @akosyakov to view test results Missed a unit test to mock db query and migration check, but it could be a follow up |
What happened to the plan to generate it as part of |
If we consider to use
Do you mean the flag |
I meant running the bash script before tsx, because the input to the bash.script is a *.ts file that is processed by the same command ( From the perspective of the service-waiter it would just use whatever is in the file and doesn't care how it got there. The bash script is just a convenient way to keep things in sync and by adding it to |
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.
I still think the bash script should sit in service-waiter
and be called from its BUILD.yaml
rather than the indirection of having the gitpod-db
generating the file and that it gets copied over. But I'm fine either way and have already blocked you too much with this.
Edit: I have only read through the code but not tested it.
Description
Summary generated by Copilot
### 🤖 Generated by Copilot at cdc4ee6This pull request adds a new feature to the installer and the service-waiter to check and apply database migrations. It embeds a JSON file with the latest migration info into the installer binary and passes it to the service-waiter container. It also improves the database connection and migration check logic in the service-waiter. It adds a new component to the gitpod-db package to produce the JSON file from the migration folder. It updates the installer and the service-waiter packages and adds a new test case for the installer.
Related Issue(s)
Fixes EXP-377
How to test
With preview env
server
) log containschecking if database is migrated
and logwaiting for database
(has migration field that should contains latest migration name / timestamp)Smoke test
See #18455 (comment) #18455 (comment)
Open PR with Gitpod
go run main.go database -P test -u root -p 23306 --migration-check true --timeout 5m
./scripts/generate-latest-migration.sh > ../service-waiter/cmd/resources/latest-migration.txt
yarn typeorm migration:create -n test
cd components/service-waiter
cd components/gitpod-db
leeway run components/gitpod-db:init-testdb
checking if database is migrated
👉 only ping db if no migration requiredchecking if database is migrated
and succeed 👉 works if migratedleeway run components/gitpod-db:init-testdb
Documentation
Preview status
Gitpod was successfully deployed to your preview environment.
Build Options
Build
Run the build with werft instead of GHA
Run Leeway with
--dont-test
Publish
Installer
Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
If enabled this will build
install/preview
If enabled this will create the environment on GCE infra
Valid options are
all
,workspace
,webapp
,ide
,jetbrains
,vscode
,ssh
. If enabled,with-preview
andwith-large-vm
will be enabled./hold