Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,096
Community Members
 
Community Events
165
Community Groups

The gradlew clean build command failed with an error reading from client configuration

I have a micronaut service up and running, recently I added the discovery client configurations for reading the values from bootstrap.yaml. When I apply gradlew clean test in my local test is executed properly it is a success. But when it runs from the bitbucket pipeline it fails.

Below are the dependencies added in build.gradle

implementation("io.micronaut.kubernetes:micronaut-kubernetes-discovery-client")
implementation("io.micronaut.kubernetes:micronaut-kubernetes-client")

Below are the errors from the pipeline

09:51:06.448 [Test worker] INFO i.m.context.env.DefaultEnvironment - Established active environments: [test, k8s, cloud, ec2]
09:51:06.453 [Test worker] INFO i.m.context.env.DefaultEnvironment - Established active environments: [test, k8s, cloud, ec2]
09:51:06.635 [Test worker] INFO i.m.context.DefaultBeanContext - Reading bootstrap environment configuration
09:51:06.692 [Test worker] DEBUG i.m.context.condition.Condition - Configuration: io.micronaut.discovery.spring.config will not be loaded due to failing conditions:
09:51:06.692 [Test worker] DEBUG i.m.context.condition.Condition - * Property [micronaut.config-client.enabled] with value [false] does not equal required value: true
09:51:06.693 [Test worker] DEBUG i.m.context.condition.Condition - Configuration: io.micronaut.discovery.vault.config will not be loaded due to failing conditions:
09:51:06.695 [Test worker] DEBUG i.m.context.condition.Condition - * Property [micronaut.config-client.enabled] with value [false] does not equal required value: true
09:51:06.696 [Test worker] DEBUG i.m.context.condition.Condition - Configuration: io.micronaut.http.server.cors will not be loaded due to failing conditions:
09:51:06.696 [Test worker] DEBUG i.m.context.condition.Condition - * Required property [micronaut.server.cors.enabled] with value [true] not present
09:51:06.697 [Test worker] DEBUG i.m.context.condition.Condition - Configuration: io.micronaut.discovery.consul.client.v1 will not be loaded due to failing conditions:
09:51:06.697 [Test worker] DEBUG i.m.context.condition.Condition - * Required property [consul.client] with value [null] not present
09:51:06.698 [Test worker] DEBUG i.m.context.condition.Condition - Configuration: io.micronaut.discovery.vault.config.v1 will not be loaded due to failing conditions:
09:51:06.699 [Test worker] DEBUG i.m.context.condition.Condition - * Required property [vault.client.kv-version] with value [V1] not present
09:51:06.699 [Test worker] DEBUG i.m.context.condition.Condition - Configuration: io.micronaut.discovery.vault.config.v2 will not be loaded due to failing conditions:
09:51:06.699 [Test worker] DEBUG i.m.context.condition.Condition - * Required property [vault.client.kv-version] with value [V2] not present
09:51:06.703 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.discovery.client.config.$DistributedPropertySourceLocator$Definition] will not be loaded due to failing conditions:
09:51:06.703 [Test worker] DEBUG i.m.context.condition.Condition - * Property [micronaut.config-client.enabled] with value [false] does not equal required value: true
09:51:06.736 [Test worker] DEBUG i.m.context.condition.Condition - Configuration: io.micronaut.discovery.spring.config will not be loaded due to failing conditions:
09:51:06.737 [Test worker] DEBUG i.m.context.condition.Condition - * Property [micronaut.config-client.enabled] with value [false] does not equal required value: true
09:51:06.738 [Test worker] DEBUG i.m.context.condition.Condition - Configuration: io.micronaut.discovery.vault.config will not be loaded due to failing conditions:
09:51:06.738 [Test worker] DEBUG i.m.context.condition.Condition - * Property [micronaut.config-client.enabled] with value [false] does not equal required value: true
09:51:06.739 [Test worker] DEBUG i.m.context.condition.Condition - Configuration: io.micronaut.discovery.consul.client.v1 will not be loaded due to failing conditions:
09:51:06.739 [Test worker] DEBUG i.m.context.condition.Condition - * Required property [consul.client] with value [null] not present
09:51:06.740 [Test worker] DEBUG i.m.context.condition.Condition - Configuration: io.micronaut.discovery.vault.config.v1 will not be loaded due to failing conditions:
09:51:06.740 [Test worker] DEBUG i.m.context.condition.Condition - * Required property [vault.client.kv-version] with value [V1] not present
09:51:06.740 [Test worker] DEBUG i.m.context.condition.Condition - Configuration: io.micronaut.discovery.vault.config.v2 will not be loaded due to failing conditions:
09:51:06.740 [Test worker] DEBUG i.m.context.condition.Condition - * Required property [vault.client.kv-version] with value [V2] not present
09:51:06.766 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.liquibase.$GormMigrationRunnerDefinition] will not be loaded due to failing conditions:
09:51:06.766 [Test worker] DEBUG i.m.context.condition.Condition - * Class [org.grails.orm.hibernate.HibernateDatastore] is not present
09:51:06.767 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.liquibase.$$GormMigrationRunnerDefinition$InterceptedDefinition] will not be loaded due to failing conditions:
09:51:06.768 [Test worker] DEBUG i.m.context.condition.Condition - * Class [org.grails.orm.hibernate.HibernateDatastore] is not present
09:51:06.772 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.rabbitmq.metrics.$RabbitMetricsInterceptor$Definition] will not be loaded due to failing conditions:
09:51:06.773 [Test worker] DEBUG i.m.context.condition.Condition - * Class [io.micrometer.core.instrument.MeterRegistry] is not present
09:51:06.788 [Test worker] DEBUG i.m.context.condition.Condition - Bean [Definition: io.micronaut.transaction.jdbc.TransactionAwareDataSource] will not be loaded due to failing conditions:
09:51:06.790 [Test worker] DEBUG i.m.context.condition.Condition - * Existing bean [io.micronaut.jdbc.spring.DataSourceTransactionManagerFactory] of type [class io.micronaut.jdbc.spring.DataSourceTransactionManagerFactory] registered in context
09:51:06.795 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.web.router.version.$VersionAwareRouterListener$Definition] will not be loaded due to failing conditions:
09:51:06.795 [Test worker] DEBUG i.m.context.condition.Condition - * Required property [micronaut.router.versioning.enabled] with value [true] not present
09:51:06.932 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.transaction.jdbc.$DelegatingDataSourceResolver$Definition] will not be loaded due to failing conditions:
09:51:06.934 [Test worker] DEBUG i.m.context.condition.Condition - * Class [org.springframework.jdbc.datasource.DataSourceTransactionManager] is not absent
09:51:07.048 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.reactor.convert.$ReactorToRxJava3ConverterRegistrar$Definition] will not be loaded due to failing conditions:
09:51:07.049 [Test worker] DEBUG i.m.context.condition.Condition - * Class [io.reactivex.rxjava3.core.Maybe] is not present
09:51:07.050 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.http.netty.channel.converters.$KQueueChannelOptionFactory$Definition] will not be loaded due to failing conditions:
09:51:07.050 [Test worker] DEBUG i.m.context.condition.Condition - * Class [io.netty.channel.kqueue.KQueue] is not present
09:51:07.052 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.reactive.flow.converters.$FlowConverterRegistrar$Definition] will not be loaded due to failing conditions:
09:51:07.052 [Test worker] DEBUG i.m.context.condition.Condition - * Class [kotlinx.coroutines.reactive.ReactiveFlowKt] is not present
09:51:07.067 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.http.netty.channel.converters.$EpollChannelOptionFactory$Definition] will not be loaded due to failing conditions:
09:51:07.068 [Test worker] DEBUG i.m.context.condition.Condition - * Class [io.netty.channel.epoll.Epoll] is not present
09:51:07.069 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.http.netty.channel.converters.$EpollChannelOptionFactory$Definition] will not be loaded due to failing conditions:
09:51:07.070 [Test worker] DEBUG i.m.context.condition.Condition - * Class [io.netty.channel.epoll.Epoll] is not present
09:51:07.071 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.http.netty.channel.converters.$KQueueChannelOptionFactory$Definition] will not be loaded due to failing conditions:
09:51:07.071 [Test worker] DEBUG i.m.context.condition.Condition - * Class [io.netty.channel.kqueue.KQueue] is not present
09:51:07.071 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.http.netty.channel.converters.$KQueueChannelOptionFactory$Definition] will not be loaded due to failing conditions:
09:51:07.072 [Test worker] DEBUG i.m.context.condition.Condition - * Class [io.netty.channel.kqueue.KQueue] is not present
09:51:07.359 [Test worker] DEBUG i.m.context.condition.Condition - Bean [io.micronaut.logging.$PropertiesLoggingLevelsConfigurer$Definition] will not be loaded due to failing conditions:
09:51:07.360 [Test worker] DEBUG i.m.context.condition.Condition - * Required property [logger.levels] with value [null] not present
09:51:07.371 [Test worker] WARN i.m.k.c.DefaultNamespaceResolver - An error has occurred when reading the file: [/var/run/secrets/kubernetes.io/serviceaccount/namespace]. Kubernetes namespace will be set to: default
09:51:08.110 [OkHttp http://localhost:8080/...] ERROR i.m.k.client.OkHttpClientLogging - HTTP FAILED: Failed to connect to localhost/0:0:0:0:0:0:0:1:8080
java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:8080

 

1 answer

0 votes
Patrik S Atlassian Team May 17, 2022

Hello @apulikkal ,

Welcome to Atlassian Community!

From the error being shown in the logs it looks like your build is trying to connect to a service in http://localhost:8080/ which seems to have not been correctly started in the previous commands.

Since you mentioned you were able to execute it successfully when running locally, in order to understand if the issue is with Pipelines environment itself or with your current build setup, I'd like to ask you to run the build locally in a docker container and check if the same error happens.

You can follow the below documentation to debug your build locally :

This will make your environment closer to what you have when executing the build in Bitbucket Pipelines. Please make sure to use the same docker image as your pipeline build when starting your local container. Once you run it locally you can share the logs with us, so we can investigate further.

In case you have any questions, please let me know!

Thank you, @apulikkal .

Kind regards,

Patrik S

Thanks @Patrik S for the reply,

Yes, the log says it is not able to connect to a localhost service, am getting this message when I apply command like bash gradlew clean test, below is the step from bitbucket-pipeline.yml file

- step:
name: "Test"
script:
- export TESTCONTAINERS_RYUK_DISABLED=true
- cd product-api
- bash ./gradlew clean test

 

When I try this gradlew clean test command from my local windows machine it is successfully running, and also I tried it from a linux machine there also it worked.

Interesting this when I comment below two lines from build.gradle file it successfully running in bitbucket pipeline.

implementation("io.micronaut.kubernetes:micronaut-kubernetes-discovery-client")
implementation("io.micronaut.kubernetes:micronaut-kubernetes-client")
 

Bitbucket pipeline was running successfully before adding these dependencies, I added this because I want to read some configurations from bootstrap.yml file

Yevhen Atlassian Team May 23, 2022

@apulikkal the client fails to connect to a K8s cluster and falls back to localhost:8080. I do not think you are allowed to use incluster auth in pipelines otherwise you'd get access to the actual cluster where your job pod is running.

You can configure which cluster to connect to: https://micronaut-projects.github.io/micronaut-kubernetes/snapshot/guide/#_authentication but this has to be your Kube cluster.

@Yevhen When running the test it is not supposed to use the K8 cluster, it should run in the test container.

Yevhen Atlassian Team May 24, 2022

@apulikkal correct, a test container that a test wants to create using K8s API. This isn't supported in pipelines for obvious reasons. I'm just explaining what happens and why it works locally for you.

@Yevhen Thanks for the reply, I agree that a test with K8 API may not work, but let's say my data source configurations are reading from a config-map, but when a test runs it is not required to read from config-map that means when a test runs it is not required to use K8 API.

Datasource I have tested with bootstrap-test.yml by removing the config-map configurations but it is not working.

Any other way to not use K8 API in test mode?

Yevhen Atlassian Team May 30, 2022

@apulikkal I am sorry, I am not familiar with the framework you use. If during a test phase it needs access to K8s API...it needs it for some reason. I can only recommend using an external k8s cluster of course if you have a public one. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,223 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you