You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Thomas Diesler (Jira)" <ji...@apache.org> on 2025/01/14 14:06:00 UTC

[jira] [Commented] (CAMEL-21621) camel-jbang - regression with k8s-run shutdown

    [ https://issues.apache.org/jira/browse/CAMEL-21621?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17912916#comment-17912916 ] 

Thomas Diesler commented on CAMEL-21621:
----------------------------------------

Recreating the k8s client in the k8s-run shutdown hook does not work eitherĀ 

{code}
Exception in thread "Camel Thread #7 - CamelShutdownInterceptor" java.util.ServiceConfigurationError: io.fabric8.kubernetes.client.http.HttpClient$Factory: Provider io.fabric8.kubernetes.client.vertx.VertxHttpClientFactory could not be instantiated
	at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:586)
	at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:813)
	at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729)
	at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403)
	at java.base/java.lang.Iterable.forEach(Iterable.java:74)
	at io.fabric8.kubernetes.client.utils.HttpClientUtils.getFactory(HttpClientUtils.java:179)
	at io.fabric8.kubernetes.client.utils.HttpClientUtils.getHttpClientFactory(HttpClientUtils.java:167)
	at io.fabric8.kubernetes.client.KubernetesClientBuilder.build(KubernetesClientBuilder.java:76)
	at org.apache.camel.dsl.jbang.core.commands.kubernetes.KubernetesHelper.getKubernetesClient(KubernetesHelper.java:78)
	at org.apache.camel.dsl.jbang.core.commands.kubernetes.KubernetesBaseCommand.client(KubernetesBaseCommand.java:137)
	at org.apache.camel.dsl.jbang.core.commands.kubernetes.KubernetesDelete.doCall(KubernetesDelete.java:91)
	at org.apache.camel.dsl.jbang.core.commands.kubernetes.KubernetesRun.lambda$installShutdownHook$10(KubernetesRun.java:511)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.IllegalStateException: Shutdown in progress
	at java.base/java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:66)
	at java.base/java.lang.Runtime.addShutdownHook(Runtime.java:216)
	at io.fabric8.kubernetes.client.vertx.VertxHttpClientFactory.<init>(VertxHttpClientFactory.java:60)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789)
	... 11 more
{code}

This code effectively prevents the use of k8s in any shutdown hook

{code}
    public VertxHttpClientFactory() {
        this(VertxHttpClientFactory.VertxHolder.INSTANCE);
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            if (this.vertx != null) {
                this.vertx.close();
            }

        }));
    }
{code}

In Java, shutdown hook are executed in a non-deterministic order from separate threads.

Any idea on how to fix (or work around) this are very welcome ;-)

> camel-jbang - regression with k8s-run shutdown
> ----------------------------------------------
>
>                 Key: CAMEL-21621
>                 URL: https://issues.apache.org/jira/browse/CAMEL-21621
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jbang
>            Reporter: Thomas Diesler
>            Assignee: Thomas Diesler
>            Priority: Major
>
> {code}
> Exception in thread "Camel Thread #7 - CamelShutdownInterceptor" java.lang.RuntimeException: java.lang.IllegalStateException: Client is closed
> 	at org.apache.camel.dsl.jbang.core.commands.kubernetes.KubernetesRun.lambda$installShutdownHook$10(KubernetesRun.java:514)
> 	at java.base/java.lang.Thread.run(Thread.java:833)
> Caused by: java.lang.IllegalStateException: Client is closed
> 	at io.vertx.core.http.impl.HttpClientImpl.checkClosed(HttpClientImpl.java:405)
> 	at io.vertx.core.http.impl.HttpClientImpl.doRequest(HttpClientImpl.java:281)
> 	at io.vertx.core.http.impl.HttpClientImpl.request(HttpClientImpl.java:191)
> 	at io.fabric8.kubernetes.client.vertx.VertxHttpRequest.consumeBytes(VertxHttpRequest.java:124)
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)