configs should read ws ip addr from current url

Bug #1130228 reported by Richard Harding
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
juju-gui
Fix Released
Low
Benjamin Saller

Bug Description

In development, testing would be much easier if the url of the socket_url wasn't hard coded to localhost, for example, testing froma virtualmachine. If the config would assume that the ws is available on the same host as the current url, it could be much more flexible for dev uses.

Currently doing this requires manually hacking the socket_url and then making sure to revert that change before submitting branches.

WORKAROUND: set the correct hostname in /var/lib/juju/units/juju-gui-[unit-id]/charm/juju-gui/build-prod/juju-ui/assets/config.js

Revision history for this message
Jeff Pihach (hatch) wrote :

+1

I agree that we need a better approach for this as this has also bitten me.

In a past project we had a similar config that was generated on build time from a json object whos properties could be overridden by environment variables. Considering that we already have most of that infrastructure in place this fix shouldn't be too much work to implement.

Gary Poster (gary)
Changed in juju-gui:
status: New → Triaged
importance: Undecided → Low
Revision history for this message
Gary Poster (gary) wrote :

Rick, +1 on making this change if you would like, as a slack or dev support task. We would appreciate it.

I (somewhat strongly) suggest that the socket_url be calculated dynamically in the browser, and not as a build time value.

In order to support the charm, the logic in the JS needs to be backwards compatible. That is, it must support either a full url (as it does now, and as the charm provides it) or what I think you would want: only a port and path.

full url -> unchanged
:port/path -> ws://[HOSTNAME]:port/path

Revision history for this message
Gary Poster (gary) wrote :

hm. It would be nice if we could support wss with this too. Then the charm could be taught to take advantage of it.

How about this?

full url -> unchanged
wss://:port/path -> wss://[HOSTNAME]:port/path
ws://:port/path -> ws://[HOSTNAME]:port/path

Maybe also

ws:///path -> ws://[HOSTNAME]:[CURRENT PORT]/path
wss:///path -> wss://[HOSTNAME]:[CURRENT PORT]/path

shrug. That would be slightly convenient for the charm.

I don't want to bikeshed. If you have a better idea I'll want to approve it. :-)

Revision history for this message
Richard Harding (rharding) wrote :

Thanks Gary. My main concern, and reason I didn't just drop something as a drive by in the other branch, was that I'm not aware of the actual deploy situation. could the web front end talking to another hostname for the ws connection? I've not done any ws tinkering other than the typical 'hello world' examples and I don't want to change the code to assume same host and then break a real world deployment story.

Revision history for this message
Gary Poster (gary) wrote :

In all the stories I know about, we talk to the same host name. However, we still need to support the full URL spelling. I think what I sketched, or something similar, would do the trick for both the current deploy story and for what you want.

Gary Poster (gary)
summary: - config-debug should read ws ip addr from current url
+ configs should read ws ip addr from current url
Jeff Pihach (hatch)
Changed in juju-gui:
assignee: nobody → Benjamin Saller (bcsaller)
Changed in juju-gui:
status: Triaged → Fix Committed
description: updated
Changed in juju-gui:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.