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

Problems in IDE with duplicated actuator #1177

Closed
de-jcup opened this issue Mar 31, 2022 · 1 comment · Fixed by #1198
Closed

Problems in IDE with duplicated actuator #1177

de-jcup opened this issue Mar 31, 2022 · 1 comment · Fixed by #1198
Assignees
Labels
bug Something isn't working
Milestone

Comments

@de-jcup
Copy link
Member

de-jcup commented Mar 31, 2022

Situation

When I start SecHub server inside my IDE (eclipse) with

-Dspring.profiles.active=mocked_products,h2,integrationtest
-Dsechub.server.debug=false
-Dsechub.storage.sharedvolume.upload.dir=temp
-Dsechub.targettype.detection.intranet.hostname.endswith=intranet.example.org
-Dsechub.config.trigger.nextjob.initialdelay=0
-Dsechub.storage.sharedvolume.upload.dir=/home/username/sechub-data/upload
-Dsechub.development.webdesignmode.enabled=true

And executing JobScenario2IntTest I got an Illegal argument exception when second batch job is executed:

Failed to register Collector of type MicrometerCollector: 
The Collector exposes the same name multiple times: spring_batch_job_active_seconds

But when integration tests were executed by github actions via gradle the tests did NOT fail.
So gradle and eclipse IDE run do differ here!

Environment

I tested with

  • Commit 7e8611a from branch develop
    (Spring Boot 2.6.4)
  • Commit 26e197b from branch feature-1098-...
  • Java 8, Java 11
  • Eclipse 2021-12
  • Eclipse 2022-03
  • Eclipse project setup done by gradle call
    ./gradlew cleanEclipse clipse and a refresh inside eclipse IDE
  • Gradle 7.4
  • Linux

Always the first test works, after the job has been created, all other tests do fail, because on server side the mentioned exception happens.
After this it's no longer possible to execute any job test from IDE without restarting the integration test server launch again.

Wanted

Shall work again in eclipse - this is big problem and slows down development.

Analyze

When?

  • After every job this happens
    After the first job has been processed, the problem appears on server side. Means even on first (succesful) test!

How is the server started in eclipse?

I inspected the properties of the server launch in eclipse (for commit 26e197b) ... and I found something very odd (I added some new lines here and it's not the full java command, but it shows the problem):
image

There are two different micrometer-prometheus jars inside the classpath:

micrometer-registry-prometheus-1.8.3.jar
micrometer-registry-prometheus-1.7.2.jar

Looking at the depdencies of sechub-server I found:
image

So inside gradle the library version is updated from 1.7.2 to 1.8.3 (and so should only use 1.8.3)

But where comes the 1.7.2?
Reason found:
image


Solution

The problem is, that for eclipse .classpath generation the gradle eclipse plugin does use not the commonly used jar version, but the project defined one.

I am not sure if
Change build.gradle part to `implementation 'io.micrometer:micrometer-registry-prometheus'

@de-jcup
Copy link
Member Author

de-jcup commented Mar 31, 2022

Here the full stacktrace:

2022-03-30 17:21:40.442 DEBUG 6123 --- [xecutor_thread4] c.m.s.d.a.j.JobInformationCreateService  : creating a new job information entry for project=s02_0001project1, job=44fdf031-34f7-4902-ab50-bc4bc024e118
Exception in thread "async-job-launcher1" java.lang.IllegalArgumentException: Failed to register Collector of type MicrometerCollector: The Collector exposes the same name multiple times: spring_batch_job_active_seconds
    at io.prometheus.client.CollectorRegistry.assertNoDuplicateNames(CollectorRegistry.java:71)
    at io.prometheus.client.CollectorRegistry.register(CollectorRegistry.java:51)
    at io.prometheus.client.Collector.register(Collector.java:308)
    at io.micrometer.prometheus.PrometheusMeterRegistry.lambda$applyToCollector$16(PrometheusMeterRegistry.java:479)
    at java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1853)
    at io.micrometer.prometheus.PrometheusMeterRegistry.applyToCollector(PrometheusMeterRegistry.java:475)
    at io.micrometer.prometheus.PrometheusMeterRegistry.newLongTaskTimer(PrometheusMeterRegistry.java:288)
    at io.micrometer.core.instrument.MeterRegistry$More.lambda$longTaskTimer$0(MeterRegistry.java:884)
    at io.micrometer.core.instrument.MeterRegistry.getOrCreateMeter(MeterRegistry.java:620)
    at io.micrometer.core.instrument.MeterRegistry.registerMeterIfNecessary(MeterRegistry.java:569)
    at io.micrometer.core.instrument.MeterRegistry.access$600(MeterRegistry.java:78)
    at io.micrometer.core.instrument.MeterRegistry$More.longTaskTimer(MeterRegistry.java:882)
    at io.micrometer.core.instrument.LongTaskTimer$Builder.register(LongTaskTimer.java:408)
    at io.micrometer.core.instrument.composite.CompositeLongTaskTimer.registerNewMeter(CompositeLongTaskTimer.java:98)
    at io.micrometer.core.instrument.composite.CompositeLongTaskTimer.registerNewMeter(CompositeLongTaskTimer.java:30)
    at io.micrometer.core.instrument.composite.AbstractCompositeMeter.add(AbstractCompositeMeter.java:66)
    at java.lang.Iterable.forEach(Iterable.java:75)
    at java.util.Collections$SetFromMap.forEach(Collections.java:5530)
    at io.micrometer.core.instrument.composite.CompositeMeterRegistry.lambda$new$0(CompositeMeterRegistry.java:65)
    at io.micrometer.core.instrument.composite.CompositeMeterRegistry.lock(CompositeMeterRegistry.java:184)
    at io.micrometer.core.instrument.composite.CompositeMeterRegistry.lambda$new$1(CompositeMeterRegistry.java:65)
    at io.micrometer.core.instrument.MeterRegistry.getOrCreateMeter(MeterRegistry.java:630)
    at io.micrometer.core.instrument.MeterRegistry.registerMeterIfNecessary(MeterRegistry.java:569)
    at io.micrometer.core.instrument.MeterRegistry.access$600(MeterRegistry.java:78)
    at io.micrometer.core.instrument.MeterRegistry$More.longTaskTimer(MeterRegistry.java:882)2022-03-30 17:21:40.455 DEBUG 6123 --- [xecutor_thread4] c.m.s.d.a.j.JobInformationCreateService  : saved new job information entry uuid=s02_0001project1 - for project=44fdf031-34f7-4902-ab50-bc4bc024e118, job=0c2353d5-347b-44e0-9f35-815147efe3e1,

    at io.micrometer.core.instrument.LongTaskTimer$Builder.register(LongTaskTimer.java:408)
    at org.springframework.batch.core.metrics.BatchMetrics.createLongTaskTimer(BatchMetrics.java:88)
    at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:304)
    at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:149)
    at java.lang.Thread.run(Thread.java:748)

@de-jcup de-jcup self-assigned this Mar 31, 2022
@de-jcup de-jcup added the bug Something isn't working label Mar 31, 2022
de-jcup added a commit that referenced this issue Apr 1, 2022
- removed version number prometheus micrometer registry in
  `sechub-server-core` so we have not two different registration
   on eclipes launches
@de-jcup de-jcup added this to the Server 0.31.0 milestone Apr 5, 2022
de-jcup added a commit that referenced this issue May 25, 2022
- documentation
- minor changes
- added missing spdx headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant