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

Migrate jpa-idempotent-repository example from deprecated derby container image to MariaDB #195

Merged

Conversation

jamesnetherton
Copy link
Contributor

Kind of an extension to apache/camel-quarkus#5634. We should avoid using the deprecated Derby container image if possible. So I switched to MariaDB, as it supports a nice range of different architectures.

I also dropped the dual database setup between dev & prod mode (E.g no more H2). IMO it simplifies things.

@aldettinger
Copy link
Contributor

@jamesnetherton Many thanks for stepping in.

Could you please share how/where the derby container image is identified as deprecated ?

Also trying to rehearse locally, mvn clean package -DskipTests is successful. However, java -jar target/quarkus-app/quarkus-run.jar fails with below stack trace:

[main_upstream @ jpa-idempotent-repository]$ java -jar target/quarkus-app/quarkus-run.jar
Jan 08, 2024 1:24:50 PM org.hibernate.Version
INFO: HHH000412: Hibernate ORM core version %s
Jan 08, 2024 1:24:50 PM org.hibernate.cfg.Environment
INFO: HHH000406: Using bytecode reflection optimizer
Jan 08, 2024 1:24:50 PM org.hibernate.orm.deprecation
WARN: HHH90000025: %s does not need to be specified explicitly using 'hibernate.dialect' (remove the property setting and it will be selected by default)
Jan 08, 2024 1:24:50 PM org.hibernate.resource.beans.container.spi.AbstractCdiBeanContainer stop
INFO: HHH10005004: Stopping BeanContainer : %s
Jan 08, 2024 1:24:50 PM io.quarkus.runtime.ApplicationLifecycleManager run
ERROR: Failed to start application (with profile [prod])
java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
	at io.quarkus.runtime.Application.start(Application.java:101)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:111)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:61)
	at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:32)
Caused by: java.lang.RuntimeException: Unable to obtain configuration for Secret objects from Kubernetes API Server at: https://kubernetes.default.svc/
	at io.quarkus.kubernetes.config.runtime.KubernetesConfigSourceFactory.getSecretConfigSources(KubernetesConfigSourceFactory.java:160)
	at io.quarkus.kubernetes.config.runtime.KubernetesConfigSourceFactory.getConfigSources(KubernetesConfigSourceFactory.java:75)
	at io.quarkus.kubernetes.config.runtime.KubernetesConfigSourceFactory.getConfigSources(KubernetesConfigSourceFactory.java:61)
	at io.quarkus.kubernetes.config.runtime.KubernetesConfigSourceFactoryBuilder$KubernetesConfigFactory.getConfigSources(KubernetesConfigSourceFactoryBuilder.java:32)
	at io.quarkus.kubernetes.config.runtime.KubernetesConfigSourceFactoryBuilder$KubernetesConfigFactory.getConfigSources(KubernetesConfigSourceFactoryBuilder.java:22)
	at io.smallrye.config.ConfigSourceFactory$ConfigurableConfigSourceFactory.getConfigSources(ConfigSourceFactory.java:58)
	at io.smallrye.config.ConfigurableConfigSource.getConfigSources(ConfigurableConfigSource.java:50)
	at io.smallrye.config.SmallRyeConfig$ConfigSources.mapLateSources(SmallRyeConfig.java:687)
	at io.smallrye.config.SmallRyeConfig$ConfigSources.<init>(SmallRyeConfig.java:577)
	at io.smallrye.config.SmallRyeConfig.<init>(SmallRyeConfig.java:68)
	at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:698)
	at io.quarkus.runtime.generated.Config.readConfig(Unknown Source)
	at io.quarkus.runtime.generated.Config.createRunTimeConfig(Unknown Source)
	at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(Unknown Source)
	... 13 more
Caused by: io.fabric8.kubernetes.client.KubernetesClientException: namespace not specified for an operation requiring one and no default was found in the Config.
	at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.checkNamespace(OperationSupport.java:267)
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.getCompleteResourceUrl(BaseOperation.java:797)
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.requireFromServer(BaseOperation.java:191)
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.get(BaseOperation.java:148)
	at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.get(BaseOperation.java:97)
	at io.quarkus.kubernetes.config.runtime.KubernetesConfigSourceFactory.getSecretConfigSources(KubernetesConfigSourceFactory.java:146)
	... 26 more

Any idea why the kubernetes-client is already involved at this step ?

@jamesnetherton
Copy link
Contributor Author

Could you please share how/where the derby container image is identified as deprecated ?

See here az82/docker-derby@ad7612b.

Any idea why the kubernetes-client is already involved at this step ?

Yes, It's because I introduced quarkus.kubernetes-config.secrets.enabled = true for when the DB is running in k8s. I got so hung up on the cloud testing I forgot to retest the local scenario 😅. I'll work on fixing that.

@jamesnetherton
Copy link
Contributor Author

I'll work on fixing that

I reworked how the secret config is done. The issue should be fixed in the latest commit.

@aldettinger
Copy link
Contributor

aldettinger commented Jan 8, 2024

There was a situation where the cleanup was not done fully:

Executing kubectl delete all -l job-name=camel-quarkus-examples-jpa-idempotent-repository-flyway-init helped to remove the left over.

And I end up with 2 jpa-idempotent-repository pods:

[main_upstream @ jpa-idempotent-repository]$ kubectl get pods
NAME                                                              READY   STATUS    RESTARTS      AGE
camel-quarkus-examples-jpa-idempotent-repository-6c4f9c56cn4c8g   1/1     Running   2 (19s ago)   27s
camel-quarkus-examples-jpa-idempotent-repository-flyway-inhxft5   1/1     Running   2 (21s ago)   27s
camel-quarkus-examples-mariadb-database-deployment-7d64645thl26   1/1     Running   0             27s

Actually, it's just the flyway one. I was mislead by the expectation from the doc where there are only 2 pods expected.

@jamesnetherton
Copy link
Contributor Author

Latest commit tweaks the README docs to mention the additional pod and modifies the cleanup step.

Copy link
Contributor

@aldettinger aldettinger left a comment

Choose a reason for hiding this comment

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

Well done @jamesnetherton 👍 Indeed looking at container image project source could help to spot deprecation of images.

Also, removing dual database setup is also more consistent. This is less maintenance cost for just a few seconds more of testing delay.

At the end of the day, the example experience remains relevant with mariadb too.

@jamesnetherton jamesnetherton merged commit 7ee831b into apache:camel-quarkus-main Jan 8, 2024
13 checks passed
@jamesnetherton jamesnetherton deleted the derby-to-mariadb branch January 8, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants