Upgrading 18.0.2 to 19.0.2

189 views
Skip to first unread message

tomidiecat84

unread,
Oct 13, 2022, 2:48:18 AM10/13/22
to Keycloak User

Summary: After upgrading Keycloak docker image version from 18.0.2 to 19.0.2 database auto migration does not take place and all the data post upgrade is still present in database but not visible in admin console.

Steps to reproduce:

1.Start MySQL database and create user/database for Keycloak

2.Start Keycloak version 18.0.2

docker run -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin -e KC_DB_URL_HOST=mysql -e KC_DB_URL_PORT=3306 -e KC_DB_URL_DATABASE=keycloak_db -e KC_DB_USERNAME=mysql_user -e KC_DB_PASSWORD=mysql_password quay.io/keycloak/keycloak:18.0.2 start-dev

3. Create realm ‘demo’ and add user ‘us...@example.com
4. Stop Keycloak
5. Start Keycloak 19.0.2

docker run -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin -e KC_DB_URL_HOST=mysql -e KC_DB_URL_PORT=3306 -e KC_DB_URL_DATABASE=keycloak_db -e KC_DB_USERNAME=mysql_user -e KC_DB_PASSWORD=mysql_password quay.io/keycloak/keycloak:19.0.2 start-dev --spi-connections-jpa-default-migration-strategy=update

6. See that migration is executed in the logs
INFO [org.keycloak.quarkus.runtime.storage.legacy.liquibase.QuarkusJpaUpdaterProvider] (main) Initializing database schema. Using changelog META-INF/jpa-changelog-master.xml

7.Navigate to Admin Console - only master realm is available.

Is there some step that I am missing? Why I am unable to see realm created in previous version of Keycloak?

Juan Pablo Gardella

unread,
Oct 13, 2022, 6:51:27 AM10/13/22
to tomidiecat84, Keycloak User
I have the same problem and tracked it here without success.

--
You received this message because you are subscribed to the Google Groups "Keycloak User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keycloak-user/5ae3ad93-df03-40e5-9f6b-3dd34b42f1f6n%40googlegroups.com.

tomidiecat84

unread,
Oct 13, 2022, 8:57:54 AM10/13/22
to Keycloak User
It appears that setting KC_DB environment variable is required in start command. Once I have added -e KC_DB=mysql to my docker command when starting 19.0.2 migration succeeded. Setting --spi-connections-jpa-default-migration-strategy=update is not required, as this is default value.

Here is command that worked:
docker run -p 8080:8080 -e KEYCLOAK_ADMIN=admin -e KC_DB=mysql -e KEYCLOAK_ADMIN_PASSWORD=admin -e KC_DB_URL_HOST=mysql -e KC_DB_URL_PORT=3306 -e KC_DB_URL_DATABASE=keycloak_db -e KC_DB_USERNAME=mysql_user -e KC_DB_PASSWORD=mysql_password quay.io/keycloak/keycloak:19.0.2 start-dev 

Juan Pablo Gardella

unread,
Oct 13, 2022, 10:26:50 AM10/13/22
to tomidiecat84, Keycloak User
Awesome! I will check that!

gilles.etc...@gmail.com

unread,
Oct 13, 2022, 10:40:39 AM10/13/22
to Keycloak User
If you want to persist this config with custom built image (with a two stage dockerfile), It seems that you have to use a build --db=mysql to perisit this conf (the use of the env_var KC_DB during a build does not work)

Then, you can use you custom built image without the env var.

Is it a regression vs KC 18? I don't know,

gilles.etc...@gmail.com

unread,
Oct 13, 2022, 10:54:58 AM10/13/22
to Keycloak User
My bad... even if show-config display the configuration after a build --db=mysql, the db is not updated until the env var or the --db=mysql is used with the start command

Juan Pablo Gardella

unread,
Oct 13, 2022, 11:10:32 AM10/13/22
to gilles.etc...@gmail.com, Keycloak User
For me it is a regression, until now upgrades were smooth.

Reply all
Reply to author
Forward
0 new messages