Remove region from controller

Hey guys,

A vsphere datacenter was renamed therefore I updated my configured cloud/credentials. Problem now is that I cannot remove the old datacenter from the controller. juju status list it still wrong. How can I refresh the controller that it uses the configured default region or remove the old region?

BR

Which version of Juju are you using?

Also, I’m assuming that you have a controller running, and it is in a datacenter that wasn’t renamed?

The datacenter is stored in the Juju DB as the region on the cloud and the model. You should be able to change the regions of the cloud using

juju update-cloud <name> --controller

(I haven’t tried this to confirm - I don’t want to rename a DC in our vSphere instance at the moment.) I don’t think we have a way to change the region for a model without updating the database directly, unfortunately.

I’ve made a bug to fix this.

If you try the update-cloud --controller command, does that let you update the region for the datacenter? If it succeeds, does that then allow you to add and remove machines in existing models? From reading the code it seems like it might be but it’s hard to be sure.

If not we can help you update the existing models in the database.

I am using 2.7.5-bionic-amd64.

Thank you! Will try it out next week. Currently I am ill

Doesn’t work. Still pointing to old datacenter

admin @ srv:~ $ juju update-cloud <CLOUD> --controller <CONTROLLER>
Cloud "<CLOUD>" updated on controller "<CONTROLLER>" using client cloud definition.
admin @ srv:~ $ juju ssh kubernetes-worker/1
ERROR opening environment: getting cloud region definition: region "<OLDDC>" not found (expected one of ["<NEWDC>"]) (not found)
admin @ srv:~ $

currently trying to get rid of all credentials and everything what could be pointing towards the old DC

Ok, I’m working out what surgery needs to be done in the database.

Tracking through the twisty-turny stateenvirons code it looks like updating the model’s cloud-region value will fix it.

You can use the script from this post to get into the Juju database. This update needs to be run on the Mongo primary - if you’re in HA and the MongoDB prompt says SECONDARY try the other controller machines with juju-db 1 and juju-db 2.

From the db prompt this query will show the models and their associated cloud-regions (the vSphere datacenter).

db.models.find({}, {"_id":1, "cloud-region":1})

To update the ones with the old datacenter, use updateMany:

db.models.updateMany({"cloud-region": "old-datacenter-name"}, {$set: {"cloud-region": "new-datacenter-name"}})

Afterwards you’ll need to bounce the controller agent(s) to see the new value. (Repeat for each one with the 0s changed to 1, 2 if you’re in HA.)

juju ssh -m controller 0 sudo systemctl restart jujud-machine-0.service

That should sort it out, hopefully!