Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-8297

JolokiaClients don't pass the openshift user bearer token to the openshift api

    XMLWordPrintable

Details

    • % %
    • FIS 2.0 Sprint 7, FIS 2.0 Sprint 8

    Description

      Trying to use jolokia asssertions on an A-MQ pod

      @ArquillianResource
      JolokiaClients jolokiaClients;
      
      J4pReadRequest request = new J4pReadRequest("org.apache.activemq:type=Broker,brokerName=" + amqPodName);
      jolokiaClients.clientForReplicationController(amqReplicationController).execute(request)
      

      fails with

      java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long
              at org.jolokia.client.request.ValidatingResponseExtractor.extract(ValidatingResponseExtractor.java:58)
              at org.jolokia.client.J4pClient.execute(J4pClient.java:195)
              at org.jolokia.client.J4pClient.execute(J4pClient.java:168)
              at org.jolokia.client.J4pClient.execute(J4pClient.java:117)
              at com.redhat.xpaas.qe.KubernetesIntegrationKT.jolokiaClientsInjection(KubernetesIntegrationKT.java:128)
      

      The problem seems to be that the jolokia request via the openshift API lacks the openshift client's token (other kubernetes clients requests work fine in the tests, so the kubernetes client seems to be configured properly)

      Note the wire logs:

      20:19:37.143 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->https://x.x.x.x:8443
      20:19:37.144 [main] DEBUG org.apache.http.impl.conn.HttpClientConnectionOperator - Connecting to /x.x.x.x:8443
      20:19:37.422 [main] DEBUG org.apache.http.impl.conn.HttpClientConnectionOperator - Connection established x.x.x.x:41068<->x.x.x.x:8443
      20:19:37.423 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Executing request GET /api/v1/namespaces/maschmid-test/pods/https:f8-arq-1-zshnc:8778/proxy/jolokia/read/org.apache.activemq:brokerName=f
      8-arq-1-zshnc,type=Broker HTTP/1.1
      20:19:37.423 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
      20:19:37.423 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
      20:19:37.427 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> GET /api/v1/namespaces/maschmid-test/pods/https:f8-arq-1-zshnc:8778/proxy/jolokia/read/org.apache.activemq:brokerName=f8-arq-1-zshnc,type=Broker HTTP/1.1
      20:19:37.427 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: x.x.x.x:8443
      20:19:37.427 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
      20:19:37.427 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Jolokia JMX-Client (using Apache-HttpClient/4.3.3)
      20:19:37.427 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
      20:19:37.427 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "GET /api/v1/namespaces/maschmid-test/pods/https:f8-arq-1-zshnc:8778/proxy/jolokia/read/org.apache.activemq:brokerName=f8-arq-1-zshnc,type=Broker HTTP/1.1[\r][\n]"
      20:19:37.427 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: x.x.x.x:8443[\r][\n]"
      20:19:37.427 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
      20:19:37.427 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Jolokia JMX-Client (using Apache-HttpClient/4.3.3)[\r][\n]"
      20:19:37.427 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
      20:19:37.427 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
      20:19:37.479 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 403 Forbidden[\r][\n]"
      20:19:37.479 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Cache-Control: no-store[\r][\n]"
      20:19:37.479 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Type: application/json[\r][\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Fri, 23 Sep 2016 18:19:37 GMT[\r][\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Length: 317[\r][\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "{[\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "  "kind": "Status",[\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "  "apiVersion": "v1",[\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "  "metadata": {},[\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "  "status": "Failure",[\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "  "message": "User \"system:anonymous\" cannot get pods/unsafeproxy in project \"maschmid-test\"",[\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "  "reason": "Forbidden",[\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "  "details": {[\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "    "name": "https:f8-arq-1-zshnc:8778",[\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "    "kind": "pods/unsafeproxy"[\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "  },[\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "  "code": 403[\n]"
      20:19:37.480 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "}[\n]"
      20:19:37.485 [main] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 403 Forbidden
      20:19:37.485 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Cache-Control: no-store
      20:19:37.485 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: application/json
      20:19:37.485 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Fri, 23 Sep 2016 18:19:37 GMT
      20:19:37.485 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Length: 317
      

      Requests generally need to pass "Authorization: Bearer $TOKEN" to not be treated as system:anonymous

      Attachments

        Activity

          People

            Unassigned Unassigned
            maschmid@redhat.com Marek Schmidt
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: