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
Feature Implementation for External URL prefix #5219
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Sidhartha-Biswal <[email protected]>
Signed-off-by: Sidhartha-Biswal <[email protected]>
Signed-off-by: Sidhartha-Biswal <[email protected]>
Signed-off-by: Sidhartha-Biswal <[email protected]>
Hi @yurishkuro, Please find the below configuration. The static files loading error is still there. Could you please check the code changes and give some suggestions to proceed ahead? |
Signed-off-by: Sidhartha-Biswal <[email protected]>
How is this different from the other PR? |
Hi @yurishkuro, We have tried setting the QUERY_UI_BASE_PATH="/hub/jaeger" and tried to access the Jaeger UI. But still we found that static assets are not getting loaded. |
Hi @yurishkuro I was also facing a similar issue, unable to load the static assets in Jaeger UI when both the parameters are set. I was trying with the code changes in this PR and also with those mentioned in this [https://github.com//pull/5189]. Unfortunately still the issue exists and not able to load the static assets. Can you please provide some suggestions that would help to proceed further. |
Signed-off-by: Sidhartha-Biswal <[email protected]>
Hi @yurishkuro, We have tried adding the QUERY_UI_BASE_PATH parameter. Expected log entry should have url entry like below Below is the code change I have tried for appending the UIBasePath to static folder, but still we see the issue. Can you please review the latest changes and let us know where we are missing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting closer
cmd/query/app/static_handler.go
Outdated
@@ -139,11 +140,21 @@ func (sH *StaticAssetsHandler) loadAndEnrichIndexHTML(open func(string) (http.Fi | |||
if sH.options.BasePath == "" { | |||
sH.options.BasePath = "/" | |||
} | |||
if sH.options.UIBasePath == "" { | |||
sH.options.UIBasePath = "/ui" // default value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should default to BasePath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified the code so that it should default to BasePath.
@@ -139,11 +140,21 @@ func (sH *StaticAssetsHandler) loadAndEnrichIndexHTML(open func(string) (http.Fi | |||
if sH.options.BasePath == "" { | |||
sH.options.BasePath = "/" | |||
} | |||
if sH.options.UIBasePath == "" { | |||
sH.options.UIBasePath = "/ui" // default value | |||
} | |||
if sH.options.BasePath != "/" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BasePath no longer relevant to indexBytes, only ui path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the UIBasePath instead of BasePath
cmd/query/app/static_handler.go
Outdated
} else { | ||
if !strings.HasPrefix(sH.options.BasePath, "/") || strings.HasSuffix(sH.options.BasePath, "/") { | ||
return nil, fmt.Errorf("invalid base path '%s'. Must start but not end with a slash '/', e.g. '/jaeger/ui'", sH.options.BasePath) | ||
} | ||
indexBytes = basePathPattern.ReplaceAll(indexBytes, []byte(fmt.Sprintf(`<base href="%s/"`, sH.options.BasePath))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else { | |
if !strings.HasPrefix(sH.options.BasePath, "/") || strings.HasSuffix(sH.options.BasePath, "/") { | |
return nil, fmt.Errorf("invalid base path '%s'. Must start but not end with a slash '/', e.g. '/jaeger/ui'", sH.options.BasePath) | |
} | |
indexBytes = basePathPattern.ReplaceAll(indexBytes, []byte(fmt.Sprintf(`<base href="%s/"`, sH.options.BasePath))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented the suggested code change as mentioned above.
cmd/query/app/static_handler.go
Outdated
if sH.options.BasePath != "/" { | ||
if !strings.HasPrefix(sH.options.BasePath, "/") || strings.HasSuffix(sH.options.BasePath, "/") { | ||
return nil, fmt.Errorf("invalid base path '%s'. Must start but not end with a slash '/', e.g. '/jaeger/ui'", sH.options.BasePath) | ||
if sH.options.UIBasePath != "/ui" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the check.
cmd/query/app/static_handler.go
Outdated
@@ -225,8 +236,8 @@ func (sH *StaticAssetsHandler) loggingHandler(handler http.Handler) http.Handler | |||
// RegisterRoutes registers routes for this handler on the given router | |||
func (sH *StaticAssetsHandler) RegisterRoutes(router *mux.Router) { | |||
fileServer := http.FileServer(sH.assetsFS) | |||
if sH.options.BasePath != "/" { | |||
fileServer = http.StripPrefix(sH.options.BasePath+"/", fileServer) | |||
if sH.options.UIBasePath != "/" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File serving is unaffected by ui path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the code that is not required.
Signed-off-by: Sidhartha-Biswal <[email protected]>
Signed-off-by: Sidhartha-Biswal <[email protected]>
Signed-off-by: Sidhartha-Biswal <[email protected]>
Hi @yurishkuro, Tested with the latest changes, we still see issues with loading the static assets as shown below.
|
Signed-off-by: Sidhartha-Biswal <[email protected]>
Hi @yurishkuro, With the latest changes, I have tried to test with the below combination of QUERY_BASE_PATH and QUERY_UI_BASE_PATH values and please find the results below. When both the QUERY_BASE_PATH & QUERY_UI_BASE_PATH values are different as shown above, static assets are not getting loaded in Jaeger UI with the below errors in console log. Can you please review the code changes and help us with some suggestions what we are missing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your PR still has no changes to the configuration of the reverse proxy. How are you expecting it to work if you're giving different prefixes and nothing in between that is rewriting the URLs?
Hi @yurishkuro, Is it mandatory to use a reverse proxy when both the QUERY_BASE_PATH & QUERY_UI_BASE_PATH parameters are set at the same time? The changes in reverseproxy configuration which you mentioned above are they related to source code changes or test code changes? |
It's a test file |
Hi @yurishkuro, Thanks for the support. |
This is a valid use case: flowchart LR
Browser -->|/foo/bar/...\nUI_BASE_PATH| Proxy
Proxy -->|/baz/...\nBASE_PATH| JaegerQuery
InternalClient -->|/baz/api/traces/...\nBASE_PATH| JaegerQuery
|
Hi @yurishkuro, Just to clarify my understanding based on the code changes and above diagram, I am writing again here the below scenarios. Please correct it if I am wrong.
|
Correct. Jaeger can serve only one version of the UI assets which are dynamically modified to match UI_BASE_PATH.
Correct, because Jaeger will simply default UI_BASE_PATH to BASE_PATH if the former is not set.
No. Traffic coming into Jaeger is only recognized if it's relative to BASE_PATH. If you try to access it via different URL you will get 404. |
Hi @yurishkuro, Thanks for all your support and inputs. We have tested accessing Query-UI for both the products using this configuration with the latest changes. But currently when both values are set, Product "Y" using gateway2 is able to access Query-UI. Unfortunately we don't have a possibility to have a separate configuration for both the gateways. So in this case, do you think can we achieve this kind of use-case requirement from Jaeger side in any way? |
The only way to run UI under two external URLs is if the rewriting is taken care of by the proxy, not only on the way in, but in the responses as well (i.e. altering the returned HTML and static assets by replacing the prefix). I don't know how difficult the output rewriting would be and if proxies support that out of the box. If you're in the middle of migration, I would just run a second instance of Jaeger UI, since it's stateless (unless you're using in-process storage like Badger, then you would need to reconfigure it as a remote storage so that it can be shared across multiple Jaeger processes). |
Hi @yurishkuro, Thanks for all the support. I am confused with the below two responses given by you. Can you please clarify them 1. When proxy is involved and both the parameters are set, say UI_BASE_PATH = /foo/bar and BASE_PATH=/baz, Query-UI can only be accessed via UI_BASE_PATH. There is no possibility to access the Query-UI via BASE_PATH. Please correct it if I am wrong. But in the latest comment, you have mentioned that it is still possible to run UI under two external URL's if rewriting can be take care by proxy..... The only way to run UI under two external URLs is if the rewriting is taken care of by the proxy, not only on the way in, but in the responses as well (i.e. altering the returned HTML and static assets by replacing the prefix). I don't know how difficult the output rewriting would be and if proxies support that out of the box. The above two comments seem to be confusing & contradicting for me. Which one is correct? |
Hi @yurishkuro, Thanks for the support, sorry for delayed reply we were busy with some other works, we wanted resume to this activity. But in Jaeger not sure how to test it, can you please suggest where tests needs to be added and how it should be tested. |
the end to end test is here: https://github.com/jaegertracing/jaeger/tree/main/examples/reverse-proxy |
Hi @yurishkuro, Thanks for the inputs. |
Signed-off-by: Sidhartha-Biswal <[email protected]>
Signed-off-by: Sidhartha-Biswal <[email protected]>
Hi @yurishkuro, We were going through the reverse-proxy file shared by you above. We have made the the changes in the PR as per our understanding. We are facing some issues while building the jaeger-all-in-one-image locally which is preventing us from manually checking the Jaeger-UI. Can you please review the changes and let us know if we have to make some modifications in the test files. |
Signed-off-by: Sidhartha-Biswal <[email protected]>
Hi @yurishkuro, Thanks for all the inputs. But in order to manually test using the reverseproxy example provided by you above, we need to build the jaeger-all-in-one image with our changes I guess. But when we try to run the ./build-all-in-one-image in our local, we are facing one or other issue. Currently we are seeing the below issue. We are trying to fix the above error. But in meantime, we observed that a job was triggered for the commit where different stages like build, test, publish were executed. So if possible can you please provide us the jaeger-all-in-one-image tag with our changes. So that we can use that image and try to execute the docker compose up and check if we are able to access the Jaeger-UI using the UI-Base-Path. Can you please help us with this & also can you please confirm if the changes in this PR are fine? |
Which problem is this PR solving?
Resolves #5157
Description of the changes
How was this change tested?