Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-67519

Token required for authentication with influxdb 2.1.1

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Blocker Blocker
    • influxdb-plugin
    • None
    • Jenkins 2.319.1, InfluxDB Plugin 3.0.2

      Since we updated to influxdb 2.1.1 the plugin stopped reporting events to influxdb.

      The following error can be found in our jenkins logs whenever an event should be pushed to influxdb:

      2022-01-06 07:39:14.384+0000 [id=37596]	WARNING	h.model.listeners.RunListener#report: RunListener failed
      com.influxdb.exceptions.UnauthorizedException: unauthorized access
      	at com.influxdb.internal.AbstractRestClient.responseToError(AbstractRestClient.java:98)
      	at com.influxdb.internal.AbstractRestClient.execute(AbstractRestClient.java:81)
      	at com.influxdb.client.internal.WriteApiBlockingImpl.write(WriteApiBlockingImpl.java:235)
      	at com.influxdb.client.internal.WriteApiBlockingImpl.lambda$writePoints$1(WriteApiBlockingImpl.java:152)
      	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
      	at com.influxdb.client.internal.WriteApiBlockingImpl.writePoints(WriteApiBlockingImpl.java:152)
      	at com.influxdb.client.internal.WriteApiBlockingImpl.writePoints(WriteApiBlockingImpl.java:136)
      	at jenkinsci.plugins.influxdb.InfluxDbPublicationService.writeToInflux(InfluxDbPublicationService.java:361)
      Caused: jenkinsci.plugins.influxdb.InfluxReportException
      	at jenkinsci.plugins.influxdb.InfluxDbPublicationService.writeToInflux(InfluxDbPublicationService.java:364)
      	at jenkinsci.plugins.influxdb.InfluxDbPublicationService.perform(InfluxDbPublicationService.java:301)
      	at jenkinsci.plugins.influxdb.global.GlobalRunListener.onCompleted(GlobalRunListener.java:75)
      	at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:208)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.finish(WorkflowRun.java:625)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun.access$800(WorkflowRun.java:138)
      	at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:1045)
      	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:1473)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$3.run(CpsThreadGroup.java:491)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:38)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
      	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
      	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	at java.base/java.lang.Thread.run(Thread.java:829)
      

      at the same time the following error can be found in the influxdb log:

      ts=2022-01-06T07:44:11.169611Z lvl=debug msg=Request log_id=0YsTKpqW000 service=http method=POST host=myhost path=/api/v2/signin query= proto=HTTP/1.1 status_code=204 response_size=0 content_length=0 referrer= remote=10.141.4.1:33740 user_agent=influxdb-client-java took=63.624ms
      ts=2022-01-06T07:44:11.172385Z lvl=info msg=Unauthorized log_id=0YsTKpqW000 error="token required"
      ts=2022-01-06T07:44:11.172458Z lvl=debug msg=Request log_id=0YsTKpqW000 service=http method=POST host=myhost path=/api/v2/write query="bucket=jenkins&org=Myorg&precision=ns" proto=HTTP/1.1 status_code=401 response_size=55 content_length=654 referrer= remote=10.141.4.1:33740 user_agent=influxdb-client-java took=0.117ms error=unauthorized error_code=unauthorized
      ts=2022-01-06T07:44:11.173602Z lvl=error msg="api error encountered" log_id=0YsTKpqW000 handler=session error="unauthorized access"
      

      It seems that authentication via token is now required and the plugin needs to support this.

          [JENKINS-67519] Token required for authentication with influxdb 2.1.1

          Philipp Moeller created issue -

          Aleksi Simell added a comment -

          Closing this as a duplicate.

          Supporting token based authentication is already under development.

          Aleksi Simell added a comment - Closing this as a duplicate. Supporting token based authentication is already under development.
          Aleksi Simell made changes -
          Link New: This issue duplicates JENKINS-65830 [ JENKINS-65830 ]
          Aleksi Simell made changes -
          Resolution New: Duplicate [ 3 ]
          Status Original: Open [ 1 ] New: Closed [ 6 ]

          Richard Cole added a comment -

          I've faced a similar issue.  I've been able to replicate by using the influxdb-client-java version 1.15.0 (the same as you do).  This causes the unauthorized exception.

          By upgrading to the latest client-java version (4.1.0) the issue appears to ago away.

          Happy to submit a PR for this.  Seems to also relate to JENKINS-67051

          Richard Cole added a comment - I've faced a similar issue.  I've been able to replicate by using the influxdb-client-java version 1.15.0 (the same as you do).  This causes the unauthorized exception. By upgrading to the latest client-java version (4.1.0) the issue appears to ago away. Happy to submit a PR for this.  Seems to also relate to JENKINS-67051

          Aleksi Simell added a comment -

          richardcole PRs are always welcome. I am currently trying to add token based authentication support, but given the amount of knowledge I have of the credentials plugin and the amount of time I can afford this, any help is appreciated.

          Aleksi Simell added a comment - richardcole PRs are always welcome. I am currently trying to add token based authentication support, but given the amount of knowledge I have of the credentials plugin and the amount of time I can afford this, any help is appreciated.

          Richard Cole added a comment -

          Ok will take a look.  Could you just confirm which version of Java you're developing with locally please?  mvn test throwing some obscure issues which I think relate to the fact I have java 15 locally.

          Richard Cole added a comment - Ok will take a look.  Could you just confirm which version of Java you're developing with locally please?  mvn test throwing some obscure issues which I think relate to the fact I have java 15 locally.

          Aleksi Simell added a comment -

          I have Java 8

          $ java -version
          java version "1.8.0_192"
          Java(TM) SE Runtime Environment (build 1.8.0_192-b12)
          Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode)
          

          and according to official Jenkins Java requirements documentation, Java 8 or Java 11 are required to build plugins.

          Aleksi Simell added a comment - I have Java 8 $ java -version java version "1.8.0_192" Java(TM) SE Runtime Environment (build 1.8.0_192-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.192-b12, mixed mode) and according to official Jenkins Java requirements documentation , Java 8 or Java 11 are required to build plugins.
          Richard Cole made changes -
          Attachment New: image-2022-01-24-16-31-09-386.png [ 57147 ]
          Richard Cole made changes -
          Attachment New: image-2022-01-24-16-31-38-403.png [ 57148 ]

            aleksisimell Aleksi Simell
            pmr Philipp Moeller
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: