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

Upgrade to Spring Cloud 2021.0 #43

Closed

Conversation

arey
Copy link
Member

@arey arey commented Dec 28, 2021

This PR upgrade to Spring Cloud 2021.0.0 and Spring Boot 2.6.2 and, by the way, remove use of Spring Cloud's bootstrap context (see #40).
It's related to the PR spring-petclinic/spring-petclinic-cloud-config#1

The application is working with the local maven profile.
Disabling wavefront by adding the below config is also working on my desktop:

management:
  metrics:
    export:
      wavefront:
        enabled: false

I've tried to deploy it on kubernetes by I'm facing a starting issue:

Setting Active Processor Count to 4
WARNING: Unable to convert memory limit "max" from path "/sys/fs/cgroup/memory.max" as int: memory size "max" does not match pattern "^([\\d]+)([kmgtKMGT]?)$"
Calculating JVM memory based on 4716876K available memory
Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx4031879K -XX:MaxMetaspaceSize=172996K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 4716876K, Thread Count: 250, Loaded Class Count: 28129, Headroom: 0%)
Enabling Java Native Memory Tracking
Adding 128 container CA certificates to JVM truststore
Spring Cloud Bindings Enabled
Picked up JAVA_TOOL_OPTIONS: -Djava.security.properties=/layers/paketo-buildpacks_bellsoft-liberica/java-security-properties/java-security.properties -XX:+ExitOnOutOfMemoryError -XX:ActiveProcessorCount=4 -XX:MaxDirectMemorySize=10M -Xmx4031879K -XX:MaxMetaspaceSize=172996K -XX:ReservedCodeCacheSize=240M -Xss1M -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+PrintNMTStatistics -Dorg.springframework.cloud.bindings.boot.enable=true
2021-12-28 12:45:50.861  INFO [,,] 1 --- [           main] o.s.c.k.client.KubernetesClientUtils     : Created API client in the cluster.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.6.2)

2021-12-28 12:45:51.508  INFO [,,] 1 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2021-12-28 12:45:51.755  INFO [,,] 1 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
2021-12-28 12:45:51.756  WARN [,,] 1 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/visits-service/kubernetes": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
2021-12-28 12:45:51.765  INFO [,,] 1 --- [           main] .KubernetesClientConfigMapPropertySource : Loading ConfigMap with name 'visits-service' in namespace 'spring-petclinic'
2021-12-28 12:45:52.819  INFO [,,] 1 --- [           main] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-configmap.visits-service.spring-petclinic'}]
2021-12-28 12:45:52.893  INFO [,,] 1 --- [           main] o.s.s.p.visits.VisitsServiceApplication  : The following profiles are active: kubernetes
2021-12-28 12:45:58.405  INFO [,,] 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-12-28 12:45:58.576  INFO [,,] 1 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 145 ms. Found 1 JPA repository interfaces.
2021-12-28 12:46:00.708  INFO [,,] 1 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=de5d93d8-1772-3c9a-97d5-8c63d15d5afc
2021-12-28 12:46:02.425  INFO [,,] 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'io.kubernetes.client.spring.extended.manifests.config.KubernetesManifestsAutoConfiguration' of type [io.kubernetes.client.spring.extended.manifests.config.KubernetesManifestsAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-28 12:46:02.511  INFO [,,] 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration' of type [org.springframework.cloud.commons.config.CommonsConfigAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-28 12:46:02.515  INFO [,,] 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-28 12:46:02.519  INFO [,,] 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'loadBalancerClientsDefaultsMappingsProvider' of type [org.springframework.cloud.client.loadbalancer.LoadBalancerDefaultMappingsProviderAutoConfiguration$$Lambda$632/0x0000000800673c40] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-28 12:46:02.526  INFO [,,] 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'defaultsBindHandlerAdvisor' of type [org.springframework.cloud.commons.config.DefaultsBindHandlerAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-28 12:46:02.535  INFO [,,] 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'kubernetes.manifests-io.kubernetes.client.spring.extended.manifests.config.KubernetesManifestsProperties' of type [io.kubernetes.client.spring.extended.manifests.config.KubernetesManifestsProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-12-28 12:46:07.468  INFO [,,] 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2021-12-28 12:46:07.486  INFO [,,] 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-12-28 12:46:07.486  INFO [,,] 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.56]
2021-12-28 12:46:07.830  INFO [,,] 1 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-12-28 12:46:07.839  INFO [,,] 1 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 14875 ms
2021-12-28 12:46:10.494  INFO [,,] 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-12-28 12:46:11.620  INFO [,,] 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-12-28 12:46:11.805  INFO [,,] 1 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-12-28 12:46:11.950  INFO [,,] 1 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.6.3.Final
2021-12-28 12:46:13.257  INFO [,,] 1 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-12-28 12:46:13.792  INFO [,,] 1 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2021-12-28 12:46:16.947  INFO [,,] 1 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-12-28 12:46:16.972  INFO [,,] 1 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-12-28 12:46:17.134  WARN [,,] 1 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-12-28 12:46:24.925  INFO [,,] 1 --- [           main] .s.s.UserDetailsServiceAutoConfiguration : 

Using generated security password: 621cb34f-33bc-4bc0-84f6-ed8a9e62f1be

2021-12-28 12:46:25.243  WARN [,,] 1 --- [           main] o.s.s.p.v.s.InsecurityConfiguration      : configuring insecure HttpSecurity
2021-12-28 12:46:25.278  WARN [,,] 1 --- [           main] o.s.s.p.v.s.InsecurityConfiguration      : configuring insecure WebSecurity
2021-12-28 12:46:25.284  INFO [,,] 1 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure Ant [pattern='/**'] with []
2021-12-28 12:46:26.621  INFO [,,] 1 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@5683a326, org.springframework.security.web.context.SecurityContextPersistenceFilter@492c1b1b, org.springframework.security.web.header.HeaderWriterFilter@c197f46, org.springframework.security.web.authentication.logout.LogoutFilter@5f05cd7e, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@729feae8, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@7000df03, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@7574d30b, org.springframework.security.web.session.SessionManagementFilter@53a20aab, org.springframework.security.web.access.ExceptionTranslationFilter@1927c2c6, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@1512a767]
2021-12-28 12:46:27.813  WARN [,,] 1 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationUpdateStrategy' defined in class path resource [org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadAutoConfiguration$ConfigReloadAutoConfigurationBeans.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationUpdateStrategy]: Factory method 'configurationUpdateStrategy' threw exception; nested exception is java.lang.IllegalArgumentException: Restart endpoint is not enabled
2021-12-28 12:46:27.822  INFO [,,] 1 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2021-12-28 12:46:27.832  INFO [,,] 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2021-12-28 12:46:27.878  INFO [,,] 1 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2021-12-28 12:46:27.881  INFO [,,] 1 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2021-12-28 12:46:27.925  INFO [,,] 1 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-12-28 12:46:27.976 ERROR [,,] 1 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationUpdateStrategy' defined in class path resource [org/springframework/cloud/kubernetes/commons/config/reload/ConfigReloadAutoConfiguration$ConfigReloadAutoConfigurationBeans.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationUpdateStrategy]: Factory method 'configurationUpdateStrategy' threw exception; nested exception is java.lang.IllegalArgumentException: Restart endpoint is not enabled
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290)
	at org.springframework.samples.petclinic.visits.VisitsServiceApplication.main(VisitsServiceApplication.java:29)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationUpdateStrategy]: Factory method 'configurationUpdateStrategy' threw exception; nested exception is java.lang.IllegalArgumentException: Restart endpoint is not enabled
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
	... 27 common frames omitted
Caused by: java.lang.IllegalArgumentException: Restart endpoint is not enabled
	at org.springframework.util.Assert.notNull(Assert.java:201)
	at org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadAutoConfiguration$ConfigReloadAutoConfigurationBeans.configurationUpdateStrategy(ConfigReloadAutoConfiguration.java:82)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	... 28 common frames omitted

The restart endpoint seems to be enabled

management:
  endpoint:
    restart:
      enabled: true

@odedia, @snicoll did you have any idea ?

@odedia
Copy link
Contributor

odedia commented Dec 29, 2021

When you removed the bootstrap context, did you move the that existed there to application.yml? A example: https://stackoverflow.com/questions/64994034/bootstrap-yml-configuration-not-processed-anymore-with-spring-cloud-2020-0
It's possible it's not picking up the updated config.

@arey
Copy link
Member Author

arey commented Dec 29, 2021

Yes, I've renamed or merged the bootstrap.yml file to application.yml.
Apart from restart-context renamed to restart_context (according to https://docs.spring.io/spring-cloud-kubernetes/docs/current/reference/html/#propertysource-reload), I don't do any changes into the spring.cloud.kubernetes section of the kubernetes profile. I also test the shutdown value.

@arey
Copy link
Member Author

arey commented Jan 21, 2022

@odedia could you please checkout this branch and test it to look what was wrong?
Maybe I has to do two PR: a first for one for Sping Cloud 2021.0 upgrade and a second one for removing the spring-cloud-starter-bootstrap dependency.

arey added a commit to arey/spring-petclinic-cloud that referenced this pull request Feb 6, 2022
@arey
Copy link
Member Author

arey commented Feb 6, 2022

I propre another PR with the same stack version but without removing the spring-cloud-starter-bootstrap. #44

arey added a commit to arey/spring-petclinic-cloud that referenced this pull request Feb 7, 2022
@arey arey closed this Feb 7, 2022
arey added a commit that referenced this pull request Mar 12, 2022
#43 Upgrade to Spring Cloud 2021.0 and Spring Boot 2.6.3
HakjunMIN pushed a commit to HakjunMIN/spring-petclinic-cloud that referenced this pull request Mar 20, 2024
HakjunMIN pushed a commit to HakjunMIN/spring-petclinic-cloud that referenced this pull request Mar 20, 2024
HakjunMIN pushed a commit to HakjunMIN/spring-petclinic-cloud that referenced this pull request Mar 20, 2024
HakjunMIN pushed a commit to HakjunMIN/spring-petclinic-cloud that referenced this pull request Mar 20, 2024
HakjunMIN pushed a commit to HakjunMIN/spring-petclinic-cloud that referenced this pull request Mar 20, 2024
…-2021.0-bis

spring-petclinic#43 Upgrade to Spring Cloud 2021.0 and Spring Boot 2.6.3
HakjunMIN pushed a commit to HakjunMIN/spring-petclinic-cloud that referenced this pull request Mar 20, 2024
…-2021.0-bis

spring-petclinic#43 Upgrade to Spring Cloud 2021.0 and Spring Boot 2.6.3
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.

None yet

2 participants