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

          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.

          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 added a comment -

          Ok, confirmed with a minimal change to the pom.xml file it now restores ability to use user/pass based authentication.  I'll prepare a PR.

           

          I appreciate a lot of people would like token based auth, but at least this restores the original functionality.

          Before fix:

          After fix:

           

           

          Richard Cole added a comment - Ok, confirmed with a minimal change to the pom.xml file it now restores ability to use user/pass based authentication.  I'll prepare a PR.   I appreciate a lot of people would like token based auth, but at least this restores the original functionality. Before fix: After fix:    

          Andras Berger added a comment -

          We are also affected by this issue. When will the fix be released?

          Andras Berger added a comment - We are also affected by this issue. When will the fix be released?

          Aleksi Simell added a comment -

          Hi andrasb, I have another PR waiting to have comments answered. I'd like to get that included as well, but I'll make a release probably next week.

          Aleksi Simell added a comment - Hi andrasb , I have another PR waiting to have comments answered. I'd like to get that included as well, but I'll make a release probably next week.

          Richard Cole added a comment -

          andrasb given the code is now merged to development at least, you can always build the hpi yourself whilst you wait for an official release (it's what I did)

          Nothing more than - mvn compile test install

          Richard Cole added a comment - andrasb  given the code is now merged to development at least, you can always build the hpi yourself whilst you wait for an official release (it's what I did) Nothing more than - mvn compile test install

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

              Created:
              Updated:
              Resolved: