jenkinsci / opentelemetry-plugin

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

Unable to change creds by jenkins UI if first time set None #373

Closed sappersd closed 2 years ago

sappersd commented 2 years ago

Jenkins and plugins versions report

Jenkins OpenTelemetry Plugin version: 2.2.2

Environment ```text Jenkins: 2.339 OS: Linux - 5.4.181-1.el7.elrepo.x86_64 --- Parameterized-Remote-Trigger:3.1.5.1 ace-editor:1.1 active-directory:2.25.1 allure-jenkins-plugin:2.30.2 analysis-model-api:10.9.3 ansible:1.1 ansicolor:1.0.1 ant:1.13 antisamy-markup-formatter:2.7 apache-httpcomponents-client-4-api:4.5.13-1.0 artifactory:3.15.3 authentication-tokens:1.4 aws-java-sdk:1.12.163-315.v2b_716ec8e4df aws-java-sdk-cloudformation:1.12.163-315.v2b_716ec8e4df aws-java-sdk-codebuild:1.12.163-315.v2b_716ec8e4df aws-java-sdk-ec2:1.12.163-315.v2b_716ec8e4df aws-java-sdk-ecr:1.12.163-315.v2b_716ec8e4df aws-java-sdk-ecs:1.12.163-315.v2b_716ec8e4df aws-java-sdk-elasticbeanstalk:1.12.163-315.v2b_716ec8e4df aws-java-sdk-iam:1.12.163-315.v2b_716ec8e4df aws-java-sdk-logs:1.12.163-315.v2b_716ec8e4df aws-java-sdk-minimal:1.12.163-315.v2b_716ec8e4df aws-java-sdk-ssm:1.12.163-315.v2b_716ec8e4df aws-secrets-manager-credentials-provider:1.0.0 aws-secrets-manager-secret-source:0.0.2 bootstrap4-api:4.6.0-3 bootstrap5-api:5.1.3-6 bouncycastle-api:2.25 branch-api:2.7.0 build-name-setter:2.2.0 build-pipeline-plugin:1.5.8 build-timeout:1.20 build-timestamp:1.0.3 build-user-vars-plugin:1.8 buildrotator:1.2 caffeine-api:2.9.2-29.v717aac953ff3 checks-api:1.7.2 cloudbees-disk-usage-simple:0.10 cloudbees-folder:6.708.ve61636eb_65a_5 cobertura:1.17 code-coverage-api:2.0.4 command-launcher:1.6 conditional-buildstep:1.4.1 config-file-provider:3.9.0 configuration-as-code:1414.v878271fc496f configuration-as-code-groovy:1.1 copyartifact:1.46.3 credentials:1074.v60e6c29b_b_44b_ credentials-binding:1.27.1 custom-tools-plugin:0.8 dashboard-view:2.18 data-tables-api:1.11.4-3 display-url-api:2.3.5 docker-build-publish:1.3.3 docker-commons:1.19 docker-java-api:3.1.5.2 docker-plugin:1.2.6 docker-workflow:1.28 dtkit-api:3.0.0 durable-task:493.v195aefbb0ff2 dynamic_extended_choice_parameter:1.0.1 echarts-api:5.3.0-2 email-ext:2.87 emailext-template:1.4 envinject:2.839.v52c702c10635 envinject-api:1.180.v98d833b_27470 extended-choice-parameter:346.vd87693c5a_86c extended-read-permission:3.2 extensible-choice-parameter:1.8.0 external-monitor-job:191.v363d0d1efdf8 files-found-trigger:1.5 fluentd:0.1.5 font-awesome-api:6.0.0-1 forensics-api:1.12.0 generic-webhook-trigger:1.83 git:4.10.3 git-client:3.11.0 git-parameter:0.9.15 git-server:1.10 github:1.34.3 github-api:1.301-378.v9807bd746da5 github-autostatus:3.6.2 github-branch-source:1583.v18d333ef7379 gitlab-plugin:1.5.29 google-oauth-plugin:1.0.6 gradle:1.38 groovy:2.4 h2-api:1.4.199 handlebars:3.0.8 hashicorp-vault-plugin:336.v182c0fbaaeb7 hidden-parameter:0.0.4 htmlpublisher:1.29 http_request:1.14 ivy:2.1 jackson2-api:2.13.2-260.v43d711474c77 jacoco:3.3.1 javadoc:217.v905b_86277a_2a_ javax-activation-api:1.2.0-2 javax-mail-api:1.6.2-5 jaxb:2.3.0.1 jdk-tool:1.5 jersey2-api:2.35-4 jira-steps:1.6.0 jjwt-api:0.11.2-9.c8b45b8bb173 jnr-posix-api:3.1.7-2 job-dsl:1.78.3 job-parameter-summary:0.5 jquery:1.12.4-1 jquery-detached:1.2.1 jquery3-api:3.6.0-2 jsch:0.1.55.2 junit:1.56 junit-attachments:92.v46b_185115f82 kubernetes:3546.v6103d89542d6 kubernetes-client-api:5.11.2-182.v0f1cf4c5904e kubernetes-credentials:0.9.0 ldap:2.8 lockable-resources:2.14 mailer:408.vd726a_1130320 mapdb-api:1.0.9.0 mask-passwords:3.0 matrix-auth:3.1 matrix-groovy-execution-strategy:1.0.7 matrix-project:758.v7a_ea_491852f3 maven-artifact-choicelistprovider:1.9.0 maven-plugin:3.18 metrics:4.1.6.1 momentjs:1.1.1 monitoring:1.90.0 nc-jenkins-jobs-importer-plugin:2.0.0 nodejs:1.5.1 oauth-credentials:0.5 okhttp-api:4.9.3-105.vb96869f8ac3a opentelemetry:2.2.2 pam-auth:1.7 parameterized-scheduler:1.0 parameterized-trigger:2.43 performance:3.20 permissive-script-security:0.7 pipeline-aggregator-view:1.11 pipeline-build-step:2.16 pipeline-github-lib:36.v4c01db_ca_ed16 pipeline-graph-analysis:188.v3a01e7973f2c pipeline-input-step:446.vf27b_0b_83500e pipeline-maven:3.10.0 pipeline-milestone-step:100.v60a_03cd446e1 pipeline-model-api:2.2064.v5eef7d0982b_e pipeline-model-definition:2.2064.v5eef7d0982b_e pipeline-model-extensions:2.2064.v5eef7d0982b_e pipeline-rest-api:2.23 pipeline-stage-step:291.vf0a8a7aeeb50 pipeline-stage-tags-metadata:2.2064.v5eef7d0982b_e pipeline-stage-view:2.23 pipeline-utility-steps:2.12.0 plain-credentials:1.8 plugin-util-api:2.14.0 popper-api:1.16.1-2 popper2-api:2.11.2-1 prism-api:1.26.0-2 publish-over:0.22 python:1.3 rebuild:1.33 remoting-opentelemetry:1.0-rc89.d67d14d05962 resource-disposer:0.17 rich-text-publisher-plugin:1.4 role-strategy:3.2.0 run-condition:1.5 saml:2.291.vd3f2cd6d1c3e scm-api:595.vd5a_df5eb_0e39 scoring-load-balancer:1.0.1 script-security:1140.vf967fb_efa_55a_ simple-theme-plugin:103.va_161d09c38c7 slave-setup:1.10 snakeyaml-api:1.29.1 ssh-agent:1.24.1 ssh-credentials:1.19 ssh-slaves:1.806.v2253cedd3295 sshd:3.1.0 structs:308.v852b473a2b8c subversion:2.15.2 throttle-concurrents:2.6 timestamper:1.17 token-macro:280.v97a_82642793c trilead-api:1.0.13 uno-choice:2.6.0 update-sites-manager:2.0.0 variant:1.4 versioncolumn:2.2 warnings-ng:9.11.1 windows-slaves:1.8 workflow-aggregator:2.7 workflow-api:1143.v2d42f1e9dea_5 workflow-basic-steps:941.vdfe1b_a_132c64 workflow-cps:2660.vb_c0412dc4e6d workflow-cps-global-lib:564.ve62a_4eb_b_e039 workflow-durable-task-step:1121.va_65b_d2701486 workflow-job:1174.vdcb_d054cf74a_ workflow-multibranch:711.vdfef37cda_816 workflow-remote-loader:1.5 workflow-scm-step:2.13 workflow-step-api:622.vb_8e7c15b_c95a_ workflow-support:815.vd60466279fc8 ws-cleanup:0.40 xunit:3.0.5 ```

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

CentOS 8 Stream

Reproduction steps

  1. Go to Manage Jenkins -> System Configuration -> Configure System
  2. Find "OpenTelemetry", fill "OTLP Endpoint"
  3. Click "Add Visualisation Observability Backend", choise "Elastic Observability"
  4. Into section "Elastic Observability" choise "Store pipeline logs In Elastic and visualize logs both in Elastic and through Jenkins"
  5. Fill "Elasticsearch URL"
  6. For "Elasticsearch credentials" leave "none"
  7. Click Apply (you get error)
  8. Choise exist cred and click apply

Expected Results

cred id changed, configuration saved.

Actual Results

I got UI error when click apply/save button:

A problem occurred while processing the request.
Logging ID=7c5c0692-5cef-45d7-95e6-ae030b9b4d09

alose error into logs of jenkins:

2022-03-17 11:55:33.072+0000 [id=1032]  WARNING h.i.i.InstallUncaughtExceptionHandler#handleException: Caught unhandled exception with ID 7c5c0692-5cef-45d7-95e6-ae030b9b4d09
java.util.NoSuchElementException: No credentials found for id '' and type 'com.cloudbees.plugins.credentials.common.UsernamePasswordCredentials'
        at io.jenkins.plugins.opentelemetry.backend.elastic.ElasticsearchLogStorageRetriever.getCredentials(ElasticsearchLogStorageRetriever.java:323)

but I see that FireFox/Chrom send correct cred id (not empty/none):

{
  "elasticLogsBackend": {
    "value": "2",
    "elasticsearchUrl": "http://10.101.95.70:9200",
    "includeUser": "false",
    "elasticsearchCredentialsId": "elastic",
    "stapler-class": "io.jenkins.plugins.opentelemetry.backend.elastic.ElasticLogsBackendWithJenkinsVisualization",
    "$class": "io.jenkins.plugins.opentelemetry.backend.elastic.ElasticLogsBackendWithJenkinsVisualization"
  }
}

Anything else?

After that not be able to run jobs. Every job just fail with error.

Console Output

java.lang.NullPointerException
    at io.jenkins.plugins.opentelemetry.job.log.OtelLogStorage.getLogStorageRetriever(OtelLogStorage.java:171)
    at io.jenkins.plugins.opentelemetry.job.log.OtelLogStorage.overallLog(OtelLogStorage.java:89)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.getLogText(WorkflowRun.java:1070)
    at hudson.model.Run.writeLogTo(Run.java:1543)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.apache.commons.jexl.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:258)
    at org.apache.commons.jexl.parser.ASTMethod.execute(ASTMethod.java:104)

you can't modify configs (full remove "Elastic Observability" doesn't help) - every time you got error during saving. Jut only one wey helped:

cd "$JENKINS_HOME"
touch opentelemetry.jpi.disabled
reboot
cyrille-leclerc commented 2 years ago

Fixed by https://github.com/jenkinsci/opentelemetry-plugin/commit/94271c6475d6a6398ad5c8c15e5b85c981107aa7

cyrille-leclerc commented 2 years ago

@sappersd can you please test https://github.com/jenkinsci/opentelemetry-plugin/releases/tag/opentelemetry-2.3.0-rc1? It should fix your problem.

sappersd commented 2 years ago

Sorry for waiting. It works! Thx a lot!

cyrille-leclerc commented 2 years ago

Thanks, GA fix with https://github.com/jenkinsci/opentelemetry-plugin/releases/tag/opentelemetry-2.3.0