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

Make UI URL links relative #692

Merged
merged 1 commit into from
May 29, 2018

Conversation

karol-brejna-i
Copy link
Contributor

@karol-brejna-i karol-brejna-i commented Nov 21, 2017

Fixes #149

When using proxy or exposing Locust UI in Kubernetes (via ingress) the URLs get prefixed (for example, served under http://domain.com/locust instead of http://domain.com).

On the other hand, links in html template and JS (rest calls) are absolute (starting with '/') which makes the UI inoperable.

This PR makes the links relative - they work fine both with and without a prefix.

To validate:

git clone https://github.com/karol-brejna-i/locust.git
git checkout origin/149_url-prefix-for-web-ui
pip3.6 uninstall locustio -y 
pip3.6 install ./locust/ 
locust -f locust/examples/basic.py --host=http://localhost:8089

When looking at HTML page sources you should see <link rel="stylesheet" type="text/css" href="./static/style.css?v=0.8" media="screen"> somewhere at the beginning of the doc.

Verify if the UI works: starting, stopping the tests, browsing the stats produce valid rest calls.
(Be aware of browser caching; sometimes "old" HTML and JS are served.)

@codecov
Copy link

codecov bot commented Nov 21, 2017

Codecov Report

Merging #692 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #692   +/-   ##
=======================================
  Coverage   65.93%   65.93%           
=======================================
  Files          14       14           
  Lines        1374     1374           
  Branches      214      214           
=======================================
  Hits          906      906           
  Misses        421      421           
  Partials       47       47

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4bc679c...06fab82. Read the comment docs.

@karol-brejna-i
Copy link
Contributor Author

Rebased against latest master.

Copy link
Member

@cgoldberg cgoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 let's merge this

@cgoldberg cgoldberg merged commit 50b1e80 into locustio:master May 29, 2018
@kasturichavan
Copy link

@cgoldberg Im facing this issue even now.
I am on locustio - 0.11.0
But im seeing the same issue when running locust in kubernetes and when the path is is changed in kubernetes ingress from / to /locust. Everything should work right ? Considering this bug is fixed.

@cgoldberg
Copy link
Member

@kasturichavan
please open a new issue and provide more detail (fill out the issue template)

@w32-blaster
Copy link

@cgoldberg Im facing this issue even now.
I am on locustio - 0.11.0
But im seeing the same issue when running locust in kubernetes and when the path is is changed in kubernetes ingress from / to /locust. Everything should work right ? Considering this bug is fixed.

Did you find any solution for this? We would like to expose locust on different paths in k8s using the nginx ingress rewrite annotation feature. Looks like static files are still served from wrong path.

@dchourasia
Copy link

@karol-brejna-i does this PR make url-prefix configurable for the web-ui... did not see any such parameter in locust documentation.. not sure if I am missing something. if you can help please.

@awalker125
Copy link

If anyone comes here looking for the annotations to make this work with k8s ingress-nginx then here is what I used:

- apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    annotations:
      nginx.ingress.kubernetes.io/rewrite-target: /$2
      nginx.ingress.kubernetes.io/use-regex: "true"
    name: locust
    namespace: locust
  spec:
    ingressClassName: nginx
    rules:
    - http:
        paths:
        - backend:
            service:
              name: locust-master
              port:
                number: 8089
          path: /locust(/|$)(.*)
          pathType: Prefix

This is based on https://kubernetes.github.io/ingress-nginx/examples/rewrite/

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

Successfully merging this pull request may close these issues.

URL_PREFIX feature for web UI?
6 participants