Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recording summary reports show as plain text #35

Closed
tabjy opened this issue Oct 2, 2019 · 7 comments
Closed

Recording summary reports show as plain text #35

tabjy opened this issue Oct 2, 2019 · 7 comments
Assignees

Comments

@tabjy
Copy link
Contributor

tabjy commented Oct 2, 2019

This Content-Type response header for /reports/<recording> endpoint has incorrect value: text/plain.

screenshot

This problem is reproducible by running kube-setup.sh against a fresh Openshift installation. Looking at the script content, it's fetching the latest of quay.io/rh-jmc-team/container-jfr, which is currently v0.4.3

Interestingly, it appears the response content type is explicitly set to NanoHTTPD.MIME_HTML since v0.3.2.

It's possible that Openshift's reverse proxy somehow overwrote this header field.

$ curl --head -H "Accept: text/html" http://container-jfr-container-jfr.10.15.17.89.nip.io/reports/test
HTTP/1.1 200 OK 
Content-Type: text/plain; charset=UTF-8
Date: Wed, 2 Oct 2019 19:33:32 GMT
Access-Control-Allow-Origin: *
Content-Length: 122387
Set-Cookie: 98c81825faae9a2f4c5de3ce34beb5a5=160b9b5980b10c3e9837d7d18ffece6b; path=/; HttpOnly
Cache-control: private

@andrewazores andrewazores self-assigned this Oct 3, 2019
@andrewazores
Copy link
Member

Thanks for the report. I haven't seen this before so I'm looking to reproduce it now.

@andrewazores
Copy link
Member

Hmm. I tried to reproduce this using both the kube-setup.sh script as well as using the Minishift setup in https://github.com/rh-jmc-team/jmc-robots-demo, and in both cases the report is rendered as HTML as expected, and checking the response headers with cURL shows text/html as well. What kind of Openshift deployment are you using? Proxy rewriting of the response sounds maybe plausible?

@tabjy
Copy link
Contributor Author

tabjy commented Oct 3, 2019

I'm using OpenShift Origin (or, OKD). The cluster is setup with oc cluster up, where the oc command is provided by the origin-clients-3.11.1-1.fc30.x86_64 package on Fedora.

$ oc version 
oc v3.11.0+8de5c34
kubernetes v1.10.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO

I'll try to docker exec into the actual container and see what the response is before any kind of proxy.

@tabjy
Copy link
Contributor Author

tabjy commented Oct 3, 2019

The following is executed directly inside the container:

$ busybox wget -S -O - localhost:8181/reports/test
Connecting to localhost:8181 (127.0.0.1:8181)
  HTTP/1.1 200 OK 
  Content-Type: text/plain; charset=UTF-8
  Date: Thu, 3 Oct 2019 16:23:39 GMT
  Access-Control-Allow-Origin: *
  Connection: close
  Content-Length: 122357
  
<!--
   Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
   Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
-->
...

It's still text/plain. I have no idea what's happening...

@andrewazores
Copy link
Member

Can you double check the image hash? The latest should be sha256:0afea49f6cd34f09e753a2a1f4014576aa4ee3c6a92135bd5a7d8b7b6675c8fc, which you can see via docker inspect and probably somehow with oc as well.

@tabjy
Copy link
Contributor Author

tabjy commented Oct 3, 2019

I managed to pull the class files out from the container.

$ javap -v -private WebServer.ServerImpl | grep -A30 "Response newReportResponse"
Warning: File ./WebServer$ServerImpl.class does not contain class WebServer.ServerImpl
  private fi.iki.elonen.NanoHTTPD$Response newReportResponse(java.lang.String, java.io.InputStream) throws java.io.IOException, org.openjdk.jmc.flightrecorder.CouldNotLoadRecordingException;
    descriptor: (Ljava/lang/String;Ljava/io/InputStream;)Lfi/iki/elonen/NanoHTTPD$Response;
    flags: (0x0002) ACC_PRIVATE
    Code:
      stack=3, locals=7, args_size=3
         0: aload_2
         1: astore_3
         2: aload_2
         3: invokestatic  #103                // Method org/openjdk/jmc/flightrecorder/rules/report/html/JfrHtmlRulesReport.createReport:(Ljava/io/InputStream;)Ljava/lang/String;
         6: astore        4
         8: aload_0
         9: aload         4
        11: invokevirtual #50                 // Method serveTextResponse:(Ljava/lang/String;)Lfi/iki/elonen/NanoHTTPD$Response;
        14: astore        5
        16: aload         5
        18: ldc           #80                 // String Access-Control-Allow-Origin
        20: ldc           #81                 // String *
        22: invokevirtual #82                 // Method fi/iki/elonen/NanoHTTPD$Response.addHeader:(Ljava/lang/String;Ljava/lang/String;)V
        25: aload_0
        26: getfield      #6                  // Field TRIM_WORKER:Ljava/util/concurrent/ExecutorService;
        29: aload_0
        30: aload_1
        31: invokedynamic #104,  0            // InvokeDynamic #2:run:(Lcom/redhat/rhjmc/containerjfr/net/WebServer$ServerImpl;Ljava/lang/String;)Ljava/lang/Runnable;
        36: invokeinterface #105,  2          // InterfaceMethod java/util/concurrent/ExecutorService.submit:(Ljava/lang/Runnable;)Ljava/util/concurrent/Future;
        41: pop
        42: aload         5
        44: astore        6
        46: aload_3
        47: ifnull        54
        50: aload_3
        51: invokevirtual #106                // Method java/io/InputStream.close:()V

The response.setMimeType() call is missing. I guess I somehow pulled an outdated image.

It seems to be most likely an issue on my side. I'll close the issue once confirmed.

@tabjy
Copy link
Contributor Author

tabjy commented Oct 3, 2019

The kube-setup.sh on my fork is outdated and is still pulling from quay.io/andrewazores. Sorry...

I'm closing this issue. I'm really sorry for the confusion.

@tabjy tabjy closed this as completed Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants