quarkiverse / quarkus-azure-services

Quarkus extensions for Azure services
Apache License 2.0
13 stars 18 forks source link

SearchDomainUnknownHostException #74

Open agoncal opened 1 year ago

agoncal commented 1 year ago

@radcortez I've created a branch (https://github.com/quarkiverse/quarkus-azure-services/tree/agoncal/playback) where I am putting PlayBack Tests in action (see https://github.com/quarkiverse/quarkus-azure-services/issues/37).

When I execute my PlayBack test I get the Netty exception below. I set the right properties and get the right connection string to App Configuration (I know it's the right connection string because a simple Hello World using this string connection works).

In the code (https://github.com/quarkiverse/quarkus-azure-services/blob/main/extensions/azure-app-configuration/runtime/src/main/java/io/quarkiverse/azure/app/configuration/AzureAppConfigurationConfigSourceFactory.java#L36) you added the following comment:

// We cannot use the Quarkus Vert.x instance, because the configuration executes before starting Vert.x
2023-02-03 12:26:06,713 ERROR [com.azu.cor.htt.pol.RetryPolicy] (vert.x-eventloop-thread-4) {"az.sdk.message":"Retry attempts have been exhausted.","exception":"Failed to resolve 'appcs-quarkus-azure-app-configuration-true.azconfig.io' and search domain query for configured domains failed as well: [numericable.fr]","tryCount":3}
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 8.173 s <<< FAILURE! - in io.quarkiverse.azure.app.configuration.pt.AzureAppConfigurationTest
[ERROR] io.quarkiverse.azure.app.configuration.pt.AzureAppConfigurationTest  Time elapsed: 8.173 s  <<< ERROR!
java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus

Caused by: reactor.core.Exceptions$ReactiveException: io.netty.resolver.dns.DnsResolveContext$SearchDomainUnknownHostException: Failed to resolve 'appcs-quarkus-azure-app-conf.azconfig.io' and search domain query for configured domains failed as well: [numericable.fr]
        at reactor.core.Exceptions.propagate(Exceptions.java:396)
        at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:97)
        at reactor.core.publisher.Mono.block(Mono.java:1742)
        at com.azure.core.implementation.http.rest.AsyncRestProxy.handleRestReturnType(AsyncRestProxy.java:229)
        at com.azure.core.implementation.http.rest.AsyncRestProxy.invoke(AsyncRestProxy.java:80)
        at com.azure.core.implementation.http.rest.RestProxyBase.invoke(RestProxyBase.java:105)
        at com.azure.core.http.rest.RestProxy.invoke(RestProxy.java:92)
        at jdk.proxy4/jdk.proxy4.$Proxy66.listKeyValues(Unknown Source)
        at com.azure.data.appconfiguration.implementation.ConfigurationClientImpl.listConfigurationSettingsSinglePage(ConfigurationClientImpl.java:757)
        at com.azure.data.appconfiguration.implementation.ConfigurationClientImpl.lambda$listConfigurationSettings$24(ConfigurationClientImpl.java:626)
agoncal commented 1 year ago

After some investigation, I noticed that when we use the Netty HTTP Client, it works.

Today the extension uses the Vertx HTTP Client and this causes the exception:

Vertx vertx = Vertx.vertx();
HttpClient vertxAsyncHttpClient = new VertxAsyncHttpClientBuilder().vertx(vertx).build();

ConfigurationClientBuilder clientBuilder = new ConfigurationClientBuilder()
        .httpClient(vertxAsyncHttpClient)
        .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.NONE))
        .connectionString(config.connectionString());

But if I change the HTTP Client to Netty, it works:

HttpClient nettyAsyncHttpClient = new NettyAsyncHttpClientBuilder().build();

ConfigurationClientBuilder clientBuilder = new ConfigurationClientBuilder()
        .httpClient(nettyAsyncHttpClient)
        .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.NONE))
        .connectionString(config.connectionString());

And within the repository we have a http-client-vertx. I am confused about which HTTP Client to use.

There is a related issue: https://github.com/quarkusio/quarkus/issues/26879

radcortez commented 1 year ago

Yes, we changed to the Vert.x one because we cannot compile the Netty one to native (as described in https://github.com/quarkusio/quarkus/issues/26879)

I don't see a reason for the Vert.x one not to work. Maybe we are missing something there. I'll try to have a look.