UCL-CloudLabs / user-portal

Front end user portal for CloudLabs
0 stars 0 forks source link

Change host link to include 'ucl' prefix #49

Closed ageorgou closed 7 years ago

ageorgou commented 7 years ago

Fixes #47.

jonc125 commented 7 years ago

This certainly works, but it's a little fragile as you need to put the same prefix here and in deployer.py. It'd be nicer if this was defined in just one place. Perhaps a better design would be to move the naming adjustments out of the deployer class into their own module?

jonc125 commented 7 years ago

What do you think @raquel-ucl ?

raquelalegre commented 7 years ago

Yes, I agree. It would be better that the deployer just takes a DNS prefix given from elsewhere. Also perhaps instead of ucl+user_given_prefix we could put something random so we don't end up with several ucldemo urls :) I was using haikunator for the tests, but perhaps it'd be better to have something numeric instead, so we do user given url + random numbers.

jonc125 commented 7 years ago

Well, the DNS names the users choose will still have to be unique across UCL, because they'll be accessible via name.cloudlabs.rc.ucl.ac.uk eventually...

But random numbers for the domain within Azure would at least reduce further the chance of unexpected conflicts with non-UCL names.

raquelalegre commented 7 years ago

So there's three things to do:

ageorgou commented 7 years ago

Checking that the URL is unique within UCL is already done when adding a new host, I believe? (I remember getting messages that another VM existed with the same name in the database when playing around)

Edit: In cloudlabs.forms.add_host.py

raquelalegre commented 7 years ago

It is checked in the DB, but there might be (a bit unlikely maybe, specially if we go with the <name>.cloudlabs.rc.ucl.ac.uk) other URLs related outside of cloudlabs that happen to have the same url. But still worth checking in case of inconsistencies between the DB and the real world.

raquelalegre commented 7 years ago

Also it's very late! Let's stop talking about this :)

ageorgou commented 7 years ago

Yes, resuming another day :)

ageorgou commented 7 years ago

Noting this here as it is related: This also potentially affects how services are run from within docker containers on the deployed VM. This is because the setup script running the docker container sets the environment variable AZURE_URL from the raw dns_name field on the form, without any substitution or prefix. This means that any commands in the Dockerfile that refer to $AZURE_URL will have a wrong value, possibly breaking them. For example, this is why bokeh was not playing nice on the levine branch of docker-sample.

jonc125 commented 7 years ago

Ouch! Right, probably we need to update it within the DB then, or at least have a property on the Host model that supplies the correct value for everywhere that needs it :)

ageorgou commented 7 years ago

The setup script is built as the new entry is added to the DB (in Host.__init__), using the arguments from the form, so I think changing the DB entry or the model would be too late? We could preprocess the form fields so that the dns_name field has the right format. Maybe (as suggested) move all the name generation to a different module and use that at all stages (DB population, deployment, wherever else).