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

Thanos bucket Web: Provide support to flag web.route-prefix which help to route UI properly #3211

Closed
dmilind opened this issue Sep 23, 2020 · 13 comments · Fixed by #3690
Closed

Comments

@dmilind
Copy link

dmilind commented Sep 23, 2020

Thanos, Prometheus and Golang version used:
Using official docker image: thanosio/thanos:v0.15.0

Object Storage Provider: Ceph storage blocks

What happened:
I am using Thanos tools bucket web with --web.external-prefix=/thanos/bucket. Once I hit URL http://localhost:9090/thanos/bucket (k8s service being forwarded to 9090 from 10902 internally), I get 404. When I hit http://localhost:9090 then it shows HTML links only, and when I click on any link it routes me via a prefix path which is okay but again 404. When going through the documentation, I found

      --web.external-prefix=""  Static prefix for all HTML links and redirect
                                URLs in the bucket web UI interface. Actual
                                endpoints are still served on / or the
                                web.route-prefix. This allows thanos bucket web
                                UI to be served behind a reverse proxy that
                                strips a URL sub-path.

Flagweb.route-prefix is mentioned but bucket web does not support it.
I faced a similar issue with the querier and it got resolved when I used web.route-prefix flag.
When I am trying to use this flag for Thanos tools bucket web, it says there is not support for the flag web.route-prefix.

What you expected to happen:
Bucket web UI should be loaded behind the proxy and this can be done by providing support of web.route-prefix flag which is missing as of now.

How to reproduce it (as minimally and precisely as possible):
1

      containers:
        - name: thanos-bucketweb
          image: thanosio/thanos:v0.15.0
          imagePullPolicy: IfNotPresent
          args:
            - tools
            - bucket 
            - web  
            - --log.level=info
            - --http-address=0.0.0.0:10902
            - --web.external-prefix=thanos/bucket
            - --refresh=30m
            - --objstore.config-file=/etc/thanos-store/ceph-object-storage.yaml

2 http://localhost:9090/thanos/bucket 404 page not found
3 http://localhost:9090 HTML UI is displayed and then 404 page not found after clicking a link

Full logs to relevant components:
After providing '--web.route-prefix':

│ Error parsing commandline arguments: [/bin/thanos tools bucket web --log.level=info --http-address=0.0.0.0:10902 --web.route-prefix=thanos/bucket --web.external-prefix=thanos/bucket --refresh=30m --objstore.config-file=/etc/thanos-store/ceph-object-storage.yaml]: unknown long flag '--we │
│ thanos: error: unknown long flag '--web.route-prefix'                                                                                                                                                                                                                                           │
│ stream closed

Anything else we need to know:
I see a similar issue with compact web #2727. If it is fixed then bucket web UI can be fixed easily.

@bwplotka
Copy link
Member

Thanks for reporting, it's a bug, help wanted to fix it. (:

@fagossa
Copy link

fagossa commented Sep 24, 2020

hello, can I take a look into it?

@onprem
Copy link
Member

onprem commented Sep 24, 2020

@fagossa Yeah sure. Please go ahead.

@aribalam
Copy link
Contributor

What is the status of the issue? Is it alright to take it?

@fagossa
Copy link

fagossa commented Sep 28, 2020

hello @aribalam , I'm new to this project so I'm having a hard time testing. If you have the time please go ahead!

Anyways I was looking to this place in bucket.go#L53 where there is a missing / between the prefix and the resource name, which might result in a 404. But again, hard time testing it

instrf := func(name string, next func(w http.ResponseWriter, r *http.Request)) http.HandlerFunc {
    return ins.NewHandler(b.externalPrefix + "/" + name, http.HandlerFunc(next))
}

@dmilind
Copy link
Author

dmilind commented Sep 28, 2020

@fagossa I think still it will error out for unknown flag web.route-prefix.
While looking in query.go, I found something relative.

if webRoutePrefix != "/" {
			router.Get("/", func(w http.ResponseWriter, r *http.Request) {
				http.Redirect(w, r, webRoutePrefix+"/graph", http.StatusFound)
			})
			router.Get(webRoutePrefix, func(w http.ResponseWriter, r *http.Request) {
				http.Redirect(w, r, webRoutePrefix+"/graph", http.StatusFound)
			})
			router = router.WithPrefix(webRoutePrefix)
}

I think this logic might be helpful.

@aribalam
Copy link
Contributor

@dmilind You are right. The router is not getting prefixed with the web.external-prefix string. Plus, there was another issue that the bucket.html template file did not have a proper link to the new UI. Will open a PR soon.

@dmilind
Copy link
Author

dmilind commented Sep 30, 2020

Any update on this?

@stale
Copy link

stale bot commented Nov 30, 2020

Hello 👋 Looks like there was no activity on this issue for the last two months.
Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗
If there will be no activity in the next two weeks, this issue will be closed (we can always reopen an issue if we need!). Alternatively, use remind command if you wish to be reminded at some point in future.

@stale stale bot added the stale label Nov 30, 2020
@bwplotka bwplotka removed the stale label Nov 30, 2020
@Abhishek357
Copy link
Contributor

I would like to work on this issue.

@stale
Copy link

stale bot commented Feb 15, 2021

Hello 👋 Looks like there was no activity on this issue for the last two months.
Do you mind updating us on the status? Is this still reproducible or needed? If yes, just comment on this PR or push a commit. Thanks! 🤗
If there will be no activity in the next two weeks, this issue will be closed (we can always reopen an issue if we need!). Alternatively, use remind command if you wish to be reminded at some point in future.

@stale stale bot added the stale label Feb 15, 2021
@onprem onprem removed the stale label Feb 19, 2021
@nextrevision
Copy link

@Abhishek357 Thanks for providing a fix for this. Would it be possible to rebase the open MR? I think that's all that is blocking it from merging.

@Abhishek357
Copy link
Contributor

Yeah! sure. Done :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment