Spring Cloud Config Server spams "Adding property source" during health check [Spring Boot 2.6+]? - spring

For a Spring Cloud Config Server project, we recently migrated from Spring Boot 2.1.8.RELEASE to 2.6.6. However, the application seemed to be flooded with below logs that eventually leads to k8s pod crashing/restarting. And the INFO log is generated each time /actuator/health from kube-probe is called.
2022-08-30 19:20:19.182 INFO [config-server,5bd83ee81e7d3ccb,e17a13026d9c85ee] 1 --- [nio-8888-exec-5] o.s.c.c.s.e.NativeEnvironmentRepository : Adding property source: Config resource 'file [{spring.cloud.config.server.git.basedir}/application.yml]' via location 'file:{spring.cloud.config.server.git.basedir}'
2022-08-30 19:20:19.543 INFO [config-server,7557d9d04d71f6c7,a3d5954fe6ebbab1] 1 --- [nio-8888-exec-8] o.s.c.c.s.e.NativeEnvironmentRepository : Adding property source: Config resource 'file [{spring.cloud.config.server.git.basedir}/application.yml]' via location 'file:{spring.cloud.config.server.git.basedir}'
...
Note that I have replaced the actual file path to config repo in the container with spring.cloud.config.server.git.basedir.
Is there something that we missed on how Spring Cloud Config Server behaves differently since the update? Or how to disable health check endpoint to add a property source? As EnvironmentController.java seems to be the culprit.

Related

ActiveMQ Artemis broker and Spring Boot - prevent from starting embedded

I have a project, where I want to use ActiveMQ Artemis with Spring Boot 3.0.1, but I have an issue with embedded server.
Dependencies used:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-artemis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-server</artifactId>
</dependency>
The drill should be: when needed, start embedded server, but there is no need for that, connect to existing instance.
From I understand, there are two parameters, that might be useful here:
spring.artemis.mode - I should set it whenever want to start embedded service or connect to native instance of the server and:
spring.artemis.embedded.enabled - Quote from documentation, "Whether to enable embedded mode if the Artemis server APIs are available."
All that said, setting first one to native and second one to false does not do the trick. Native server is still starting. Am I missing something? Is there a simple way to tell Spring Boot via property or any other way to not start server if not needed?
EDIT1:
Maybe I'll provide some more details.
All configuration for the Artemis goes into separate module, where dependencies that has been provided above are.
Then, this module (let's call it "message") has only following properties:
spring:
artemis:
broker-url: tcp://localhost:61616
mode: native
Then, other module has than module as a dependency (has changed names of the groupId and artifactId for simplicity):
<dependency>
<groupId>org.example.company</groupId>
<artifactId>message</artifactId>
</dependency>
Then, changing the value in the properties does nothing to starting the server, in both configurations I see in logs:
2023-01-23T11:41:18.445+01:00 INFO 35336 --- [ restartedMain] o.apache.activemq.artemis.core.server : AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,journalDirectory=C:\Users\USR~1.JAR\AppData\Local\Temp\artemis-data/journal,bindingsDirectory=data/bindings,largeMessagesDirectory=data/largemessages,pagingDirectory=data/paging)
...
2023-01-23T11:41:19.058+01:00 INFO 35336 --- [ restartedMain] o.apache.activemq.artemis.core.server : AMQ221007: Server is now live
2023-01-23T11:41:19.059+01:00 INFO 35336 --- [ restartedMain] o.apache.activemq.artemis.core.server : AMQ221001: Apache ActiveMQ Artemis Message Broker version 2.26.0 [localhost, nodeID=78075d71-9b0a-11ed-8116-3cf011ac7196]
In this second module, where "message" is being imported as a dependency, I'm sending and receiving some messages, if that matters.

Spring Cloud Bootstrap Config prepending "bootstrapProperties-" to all of my BootstrapProperties

My team and I updated a spring boot application in order to work with oauth2, but with the updated we jumped from Spring Boot 1.5.2 to Spring Boot 2.5.8. The oauth2 is now implemented although the new version of the app cannot found any client encryption keys from the config server. Checking the logs of the last version I have:
INFO Nov 17 16:30:51 [main] org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration: LOCAL_HOST:, APP_ID:, OPERATION_NAME:, TRANSACTION_ID:, CALL_PATH:, REMOTE_HOST:, USER: - Located property source: CompositePropertySource [name='configService', propertySources=[MapPropertySource [name='fulfillments-event-validation-job'], MapPropertySource [name='config-internal']]]
After this log there are several com.esrx.inf.config.client.CustomEnvironmentDecryptApplicationInitializer* logs where it loads the values of config server and decrypts them
But in the new version I have this logs:
INFO Nov 18 02:25:53 [main] org.springframework.cloud.bootstrap.config.PropertySourceBootstrapConfiguration: LOCAL_HOST:, APP_ID:, OPERATION_NAME:, TRANSACTION_ID:, CALL_PATH:, REMOTE_HOST:, USER: - Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-fulfillments-event-validation-job'}, BootstrapPropertySource {name='bootstrapProperties-config-internal'}]
After this log there are not even one log for com.esrx.inf.config.client.CustomEnvironmentDecryptApplicationInitializer*
The old app can load and decrypt the config server values, the new version doesn't even load the values of config server.
old version
new version
spring-boot-starter-test 1.5.2
2.5.8
it does not have this one
spring-cloud-starter-bootstrap 3.0.5
spring-cloud-starter-config 1.3.0
3.0.6
configService
bootstrapProperties-configClient
fulfillments-event-validation-job
bootstrapProperties-fulfillments-event-validation-job
config-internal
bootstrapProperties-config-internal
So I'm thinking the error is with the values of the new version, for some reason is prepending en every value the string "bootstrapProperties-". You know any related to this issue?
I changed the configuration of my pom and application.properties several times.
At the end I stayed with spring-cloud-starter-bootstrap in order for the app to run.

AWS Secret Manager with Spring Boot Application

I tried to get secret manager value use this answer
How to integrate AWS Secret Manager with Spring Boot Application
But my application get secrets 2 times, first as I want with local profile, but second without any profile. Why application go to secret second time and how can I off this?
2021-08-19 11:40:01.214 INFO 9141 --- [ restartedMain] s.AwsSecretsManagerPropertySourceLocator : Loading secrets from AWS Secret Manager secret with name: secret/test_local, optional: false
2021-08-19 11:40:02.702 INFO 9141 --- [ restartedMain] s.AwsSecretsManagerPropertySourceLocator : Loading secrets from AWS Secret Manager secret with name: secret/test, optional: false
2021-08-19 11:40:02.956 ERROR 9141 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
my config in bootstrap.yaml
aws:
secretsmanager:
prefix: secret
defaultContext: application
profileSeparator: _
name: test
start application with -Dspring.profiles.active=local
upd. If I create secret for secret/test I have the next one
s.AwsSecretsManagerPropertySourceLocator : Loading secrets from AWS Secret Manager secret with name: secret/application_local, optional: false
Currently there is no way to disable prefix/defaultContext look up.
If you take a look here you will see that prefix/ + defaultcontext of loading is always added and used.
You can check docs as well, to have more clear way what is being loaded and in what order.
My recommendation is to switch to spring.config.import since that will be the way we are going to take Secrets Manager importing. Big difference is that, it gives users a lot more control of which secrets they want to import since you can specify each key individually. spring.config.import can be found explained in docs or you can check the project sample .

Why doesn't h2-console default db name match the db name defined in application.properties file?

I am new to spring boot and taking a beginner course on udemy developing a project.
Below is my application.properties file -
application.properties
#logging
logging.level.com.vega.springit=DEBUG
info.application.name=Springit
info.application.description=Reddit clone using spring boot 2
info.application.version=0.0.1
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
#h2
spring.h2.console.enabled=true
#datasource (default to testdb)
spring.datasource.name=springit
The default database on the h2-console is still testdb
And this is what I see on the console -
2020-11-29 01:19:29.315 INFO 28396 --- [ restartedMain] o.s.b.a.h2.H2ConsoleAutoConfiguration : H2 console available at '/h2-console'. Database available at 'jdbc:h2:mem:358023a0-911e-4064-b2ec-e7046556c517'
My questions are -
Why doesn't h2-console display the database name that is set in the app.properties file?
Why does the console say database available at 'jdbc:hs:mem:xxx'?
When I try to connect to testdb or springit (as set in the file), I get following error -
Database "C:/Users/zankh/test" not found, either pre-create it or allow remote database creation (not recommended in secure environments) [90149-200] 90149/90149 (Help)
Also tried, connecting to 'jdbc:h2:mem:springit', but still get the same error.
I can connect to 'jdbc:hs:mem:xxx' but that's not how it works for the instructor in the course. What am I doing wrong here?
TIA
I fixed the problem by adding spring.datasource.url to the app.properties file
application.properties
#logging
logging.level.com.vega.springit=DEBUG
info.application.name=Springit
info.application.description=Reddit clone using spring boot 2
info.application.version=0.0.1
management.endpoints.web.exposure.include=*
management.endpoint.health.show-details=always
#h2
spring.h2.console.enabled=true
#datasource (default to testdb)
spring.datasource.name=springit
spring.datasource.url=jdbc:h2:mem:springit

Stream deployment failing with CloudFoundryAppDeployer: Error: Organization does not exist

I have deployed data-flow server and skipper successfully on cloud foundry but when I try to deploy stream with all deployer properties configured, it is complaining org doesn't exist.
I have tried to configured different properties from data flow web UI but when I deploy stream it fails with error: org doesn't exist. I gave all cloud foundry credential everything that I provided to skipper and server, which are working fine, just stream inside data flow is not able to understand cloud foundry app deployer properties.
enter image description here
In the pic above you can see how I am providing properties value to stream from data flow web UI.
I am getting below error message :
2019-07-23T09:48:37.50-0400 [APP/PROC/WEB/0] OUT 2019-07-23 13:48:37.509 INFO 9 --- [eTaskExecutor-3] o.s.c.s.s.s.StateMachineConfiguration : Entering state ObjectState [getIds()=[INSTALL_INSTALL], getClass()=class org.springframework.statemachine.state.ObjectState, hashCode()=444730043, toString()=AbstractState [id=INSTALL_INSTALL, pseudoState=org.springframework.statemachine.state.DefaultPseudoState#49b9c289, deferred=[], entryActions=[org.springframework.cloud.skipper.server.statemachine.InstallInstallAction#6981f8f3], exitActions=[], stateActions=[], regions=[], submachine=null]]
2019-07-23T09:48:38.44-0400 [APP/PROC/WEB/0] OUT 2019-07-23 13:48:38.440 INFO 9 --- [eTaskExecutor-3] o.s.c.d.s.c.AbstractCloudFoundryDeployer : Preparing to push an application from org.springframework.cloud.stream.app:log-sink-rabbit:jar:2.1.1.RELEASE. This may take some time if the artifact must be downloaded from a remote host.
2019-07-23T09:48:41.70-0400 [APP/PROC/WEB/0] OUT 2019-07-23 13:48:41.708 ERROR 9 --- [eTaskExecutor-3] o.s.c.d.s.c.CloudFoundryAppDeployer : Error: Organization RE-Pheonix-DataFlow-NonProd does not exist creating app DAu4sEO-MyStream1-log-v1
2019-07-23T09:48:41.72-0400 [APP/PROC/WEB/0] OUT 2019-07-23 13:48:41.719 ERROR 9 --- [eTaskExecutor-3] o.s.c.d.s.c.AbstractCloudFoundryDeployer : Failed to deploy DAu4sEO-MyStream1-log-v1
2019-07-23T09:48:41.72-0400 [APP/PROC/WEB/0] OUT java.lang.IllegalArgumentException: Organization RE-Pheonix-DataFlow-NonProd does not exist
2019-07-23T09:48:41.72-0400 [APP/PROC/WEB/0] OUT at org.cloudfoundry.util.ExceptionUtils.illegalArgument(ExceptionUtils.java:45) ~[cloudfoundry-util-3.15.0.RELEASE.jar!/:na]
Following is my deploy properties:
enter image description here
[1]: https://i.stack.imgur.com/cVXKf.png
enter image description here
Please find exported deploy prop:
Deployer Prop
Skipper Config
Skipper Config
For the stream deployment, the Cloud Foundry connection properties (org, space, url, username, password, skipSslValidation) are obtained either from the global Skipper configuration properties for the chosen platform or via the deployment properties set when deploying the stream.
You should be able to provide the org connection property when deploying the stream like this:
If you don't specify this property as a deployer property when deploying the stream, then the Skipper configuration for the corresponding platform will be used.
Can you share how you configured your Skipper configuration properties for Cloud Foundry connection for the chosen platform?

Resources