jenkinsci / opentelemetry-plugin

Monitor and observe Jenkins with OpenTelemetry.
https://plugins.jenkins.io/opentelemetry/
Apache License 2.0
98 stars 51 forks source link

Cannot install latest version of OpenTelemetry ver 3.1320.v2eededb_d909e on Jenkins ver 2.452.2 - service.name can't be null #906

Closed craigtmoore closed 2 months ago

craigtmoore commented 2 months ago

Jenkins and plugins versions report

Environment ```text Paste the output here ```

What Operating System are you using (both controller, and any agents involved in the problem)?

I installed Jenkins on Oracle Linux Server 8.5

root@jenkins-user ~
$ sysinfo
******************************************************************************
**                                                                          **
**                          Agfa Healthcare                                 **
**                                                                          **
******************************************************************************

 Welcome root This is your System Information

 Date: Fri Jul 26 09:41:13 EDT 2024

 Hostname:   jenkins-user.med.agfa.be

 CPU Info:

CPU(s):              4
On-line CPU(s) list: 0-3
Thread(s) per core:  1
Socket(s):           1
NUMA node(s):        1
Model name:          AMD EPYC 9334 32-Core Processor
BIOS Model name:     AMD EPYC 9334 32-Core Processor
NUMA node0 CPU(s):   0-3

 Total Memory:         7887232 kB
 Free Memory:           523592 kB

 Swap Total:          16777212 kB
 Swap Free:           16772828 kB

 Oracle Linux Version:    Oracle Linux Server release 8.5

 Kernel Version:    5.4.17-2136.306.1.3.el8uek.x86_64

 Patch Version:    Patch-Package-2022.4-R8U5

 OVA Version:    Original-OVA-2022.3

 STIG Version:    Oracle_Linux_8_V1R1-20220517-092121

 Agfa-OL8-Update:    Agfa-OL8-Update-V1R5

******************************************************************************

I installed Jenkins via the dnf installer

root@jenkins-user ~
$ sudo dnf install jenkins --nobest

The command installed this version

$ dnf info jenkins
Oracle Linux 8 x86_64 Latest                                                                                                                                                                                                                   ...
Jenkins-stable                                                                                                                                                                                                                                 179 kB/s |  29 kB     00:00
Installed Packages
Name         : jenkins
Version      : 2.452.2
Release      : 1.1
Architecture : noarch
Size         : 89 M
Source       : jenkins-2.452.2-1.1.src.rpm
Repository   : @System
From repo    : jenkins
Summary      : Jenkins Automation Server
URL          : https://www.jenkins.io/
License      : MIT/X License, GPL/CDDL, ASL2
Description  : Jenkins is the leading open source automation server supported by a large and growing community of developers, testers, designers and other people interested in continuous integration, continuous delivery and modern software delivery practices. Built on
             : the Java Virtual Machine (JVM), it provides more than 1,800 plugins that extend Jenkins to automate with practically any technology software delivery teams use. In 2022, Jenkins reached 300,000 known installations making it the most widely deployed
             : automation server.
             :
             : For more information, see https://www.jenkins.io.

Reproduction steps

I installed OpenTelemetry using Manage Jenkins > Plugins > Available Plugins page and searched for the OpenTelemetry plugin.

Expected Results

After installing the OpenTelemetry plugin, I expected that Jenkins would restart without failure.

Actual Results

After installing the OpenTelemetry plugin, Jenkins crashes with the following error in the logs

$ journalctl -u jenkins
...
java.lang.NullPointerException: service.name can't be null
     at java.base/java.util.Objects.requireNonNull(Objects.java:235)
     at io.jenkins.plugins.opentelemetry.JenkinsOpenTelemetryPluginConfiguration.resolveLogStorageRetriever(JenkinsOpenTelemetryPluginConf>
     at io.jenkins.plugins.opentelemetry.JenkinsOpenTelemetryPluginConfiguration.initializeOpenTelemetry(JenkinsOpenTelemetryPluginConfigu>
Caused: java.lang.reflect.InvocationTargetException
     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.base/java.lang.reflect.Method.invoke(Method.java:568)
     at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:109)
Caused: java.lang.Error
     at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:115)
     at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:185)
     at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:305)
     at jenkins.model.Jenkins$5.runTask(Jenkins.java:1175)
     at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:221)
     at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:120)
     at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
     at java.base/java.lang.Thread.run(Thread.java:840)
Caused: org.jvnet.hudson.reactor.ReactorException
     at org.jvnet.hudson.reactor.Reactor.execute(Reactor.java:290)
     at jenkins.InitReactorRunner.run(InitReactorRunner.java:49)
     at jenkins.model.Jenkins.executeReactor(Jenkins.java:1210)
     at jenkins.model.Jenkins.<init>(Jenkins.java:997)
     at hudson.model.Hudson.<init>(Hudson.java:86)
     at hudson.model.Hudson.<init>(Hudson.java:82)
     at hudson.WebAppMain$3.run(WebAppMain.java:248)
Caused: hudson.util.HudsonFailedToLoad
     at hudson.WebAppMain$3.run(WebAppMain.java:273)

Anything else?

I should point out that I had the following values in my jenkins.service file each time I tried to install the OpenTelemetry plugin, as you can see I had an OTEL_SERVICE_NAME environmental variable as well as a otel.service.name Java system property. Neither of which were observed by OpenTelemetry plugin for the serivce.name value.

[Unit]
Description=Jenkins Continuous Integration Server
Requires=network.target
After=network.target
[Service]
Type=notify
NotifyAccess=main
ExecStart=/usr/bin/jenkins
Restart=on-failure
SuccessExitStatus=143
Environment="OTEL_EXPORTER_OTLP_ENDPOINT=http://jaeger-user.med.agfa.be:4317"
Environment="OTEL_SERVICE_NAME=jenkins"
Environment="OTEL_METRICS_EXPORTER=none"
Environment="OTEL_LOGS_EXPORTER=none"
Environment="OTEL_JAVAAGENT_LOGGING=simple"
User=jenkins
Group=jenkins
Environment="JENKINS_HOME=/var/lib/jenkins"
WorkingDirectory=/var/lib/jenkins
Environment="JENKINS_WEBROOT=%C/jenkins/war"
Environment="JAVA_OPTS=-Djava.awt.headless=true -Dotel.service.name=jenkins"
Environment="JENKINS_PORT=8080"
[Install]
WantedBy=multi-user.target

To resolve the issue I had to uninstall the OpenTelemetry plugin so that I could get Jenkins running again.

root@jenkins-user /var/lib/jenkins/plugins
$ systemctl stop jenkins

root@jenkins-user /var/lib/jenkins/plugins
$ rm -rf opentelemetry opentelemetry.jpi opentelemetry-api.jpi opentelemetry-api

root@jenkins-user /var/lib/jenkins/plugins
$ systemctl daemon-reload  # I think this is optional

root@jenkins-user /var/lib/jenkins/plugins
$ systemctl start jenkins

Once I was able to get Jenkins to deploy again, I downloaded the opentelemetry source code for the version (I think I was using before) based on the release notes

I then built the code using

user@computer MINGW64  ~/opentelemetry-plugin-3.1215.vc9db_a_0b_34c2a_
$ ./mvnw clean install -Dmaven.test.skip.exec -DskipTests

Once the build finished succesuflly, I installed the .hpi file via the Manage Jenkins > Plugins > Advanced settings page. This installed successfully, and I was able to start Jenkins without failure.

Are you interested in contributing a fix?

I'm not sure if the problem is with the plugin or the OpenTelemetry code that resolves the environmental variables for the client configuration. I can contribute a fix once I have more time to look into the issue.

cyrille-leclerc commented 2 months ago

Please upgrade opentelemetry-api-plugin to 1.40.0-23.v7da_9d4c543d3

cyrille-leclerc commented 2 months ago

Could you test @craigtmoore ?

cyrille-leclerc commented 2 months ago

Fixed in opentelemetry-api-plugin to 1.40.0-23.v7da_9d4c543d3