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?
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.
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.
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: