Removing a Cloud from juju generates an error message, but also removes it

Removing a local Cloud from client and controller removes it, but also outputs an error message. As a user, I expect it to work successfully or fail gracefully not an in between state.

“microk8s” cloud is there:

$ juju list-clouds      
Only clouds with registered credentials are shown.
There are more clouds, use --all to see them.

Clouds available on the controller:
Cloud   Regions  Default  Type
my-k8s  0                 k8s  

Clouds available on the client:
Cloud      Regions  Default    Type  Credentials  Source    Description
localhost  1        localhost  lxd   0            built-in  LXD Container Hypervisor
microk8s   1        localhost  k8s   0            local     A Kubernetes Cluster
minikube   0                   k8s   0            local     A Kubernetes Cluster
my-k8s     0                   k8s   1            local     A Kubernetes Cluster
mycluster  1        localhost  k8s   0            local     A Kubernetes Cluster

Removing it:

$ juju remove-cloud microk8s
This operation can be applied to both a copy on this client and to the one on a controller.
Do you want to remove cloud microk8s from:
    1. client only (--client)
    2. controller "my-k8s" only (--controller my-k8s)
    3. both (--client --controller my-k8s)
Enter your choice, or type Q|q to quit: 3
Removed details of cloud "microk8s" from the client
ERROR cloud "microk8s" not found

Outputs a successful message AND an error:

$ juju list-clouds          
Only clouds with registered credentials are shown.
There are more clouds, use --all to see them.

Clouds available on the controller:
Cloud   Regions  Default  Type
my-k8s  0                 k8s  

Clouds available on the client:
Cloud      Regions  Default    Type  Credentials  Source    Description
localhost  1        localhost  lxd   0            built-in  LXD Container Hypervisor
my-k8s     0                   k8s   1            local     A Kubernetes Cluster
mycluster  1        localhost  k8s   0            local     A Kubernetes Cluster

Output status is also an error:

$ echo $?
1

Hi @jonatasbaldin. Thank you for the clearly documented feedback!

I believe the reason for the double message is that the cloud is registered with the client, but not the controller that you’re currently talking to. So when you remove it, the client succeeds, but the controller says that it can’t find the cloud.

Our messaging around this should probably be clearer.

(Also, there might be a bug where we auto-remove the cloud from the controller, and then don’t behave appropriately.)

This should probably be filed as a bug on launchpad (https://bugs.launchpad.net/juju)

Hey there!

Opened a ticket on launchpad, thanks :slight_smile: