deploy: check for nameclash first
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Won't Fix
|
Medium
|
Evanson Mwangi |
Bug Description
When you try to deploy a charm with a name that's already taken:
```
$ juju deploy juju-qa-test
Located charm "juju-qa-test" in charm-hub, revision 13
Deploying "juju-qa-test" from charm-hub charm "juju-qa-test", revision 13 in channel stable on bionic
ERROR cannot add application "juju-qa-test": application already exists:
deploy application using an alias name:
juju deploy <application> <alias>
or use remove-application to remove the existing one and try again.
```
Surely we should check if the name is taken **before** doing the (expensive) work of locating/
```
$ juju deploy juju-qa-test
ERROR cannot add application "juju-qa-test": application already exists:
deploy application using an alias name:
juju deploy <application> <alias>
or use remove-application to remove the existing one and try again.
```
Changed in juju: | |
status: | New → Triaged |
importance: | Undecided → Medium |
milestone: | none → 2.9.34 |
Changed in juju: | |
assignee: | nobody → Evanson Mwangi (mr-parish) |
So the issue is that `juju deploy PATH` is defining the path to an object that we will be deploying, but until we grab the charm metadata.yaml, we don't actually know the name of the application. (for example `juju deploy jameinel- ubuntu- lite` today actually deploys an application named 'ubuntu-lite' because that is the 'name: ubuntu-lite' that exists in metadata.yaml
So at a minimum, juju needs to do the resolution to find the name of the application.
In 3.0, we should only be doing a query against charmhub to find the metadata.yaml, and not doing a full charm download.
In one respect it "would be nice" if you couldn't mismatch the official deployed name of the app from the charmhub name.
At least one problem with that is that Charmhub is (by design) a flat namespace. So if there is an "official" mysql charm, and you want to fork it and customize it, you have to then rename it to something like `jbarrett-mysql`. Do you want jbarrett-mysql to show up as `mysql` in the model by default, or as `jbarrett-mysql` always?
(I can certainly see an argument for the latter, but there are already fields around 'charm url' that can tell you what exactly you have deployed.)
Going further, there are also issues like 'charmcraft pack' creates a file named: test_ubuntu- 18.04-amd64_ ubuntu- 20.04-amd64_ ubuntu- 22.04-amd64. charm
juju-qa-
We would certainly then need some sort of obvious name mangling to strip of pieces of that to get the 'official' name.