cannot destroy / kill a Kubernetes juju controller
Description
Currently, we cannot destroy a Kubernetes Controller because the kubernetesEnvironProvider cannot be cast to a CloudEnvironProvider (the Open method has a different return type), causing certain operations like juju destroy-controller to fail. Example:
juju destroy-controller --no-prompt --destroy-storage --force --no-wait sunbeam-controller --verbose --debug
06:36:49 INFO juju.cmd supercommand.go:56 running juju [3.6.5 33b026f4ab2a4fe371764b9c41993d3e1e90ddef gc go1.24.1]
06:36:49 DEBUG juju.cmd supercommand.go:57 args: []string{"/snap/juju/30723/bin/juju", "destroy-controller", "--no-prompt", "--destroy-storage", "--force", "--no-wait", "sunbeam-controller", "--verbose", "--debug"}
06:36:49 INFO juju.juju api.go:90 connecting to API addresses: [172.16.1.201:17070]
06:36:49 DEBUG juju.api apiclient.go:1080 successfully dialed "wss://172.16.1.201:17070/api"
06:36:49 INFO juju.api apiclient.go:601 connection established to "wss://172.16.1.201:17070/api"
06:36:49 INFO juju.juju api.go:90 connecting to API addresses: [172.16.1.201:17070]
06:36:49 DEBUG juju.api apiclient.go:1080 successfully dialed "wss://172.16.1.201:17070/api"
06:36:49 INFO juju.api apiclient.go:601 connection established to "wss://172.16.1.201:17070/api"
06:36:49 DEBUG juju.api monitor.go:35 RPC connection died
06:36:49 DEBUG juju.api monitor.go:35 RPC connection died
ERROR getting controller environ: cloud environ provider provider.kubernetesEnvironProvider not valid
06:36:49 DEBUG cmd supercommand.go:571 error stack:
github.com/juju/juju/environs.Open:30: cloud environ provider provider.kubernetesEnvironProvider not valid
github.com/juju/juju/cmd/juju/controller.(*destroyCommand).Run:261: getting controller environ
Juju version
3.6.5
Cloud
Kubernetes
Expected behaviour
We should be able to kill / destroy a Kubernetes controller.
Reproduce / Test
- Bootstrap a controller on Kubernetes.
- Destroy it.
Notes & References
Test checking this claim: https://github.com/juju/juju/pull/19794
This bug has now been triaged. JUJU-7956
I think we're trying to kill the controller through the API, which is causing issues.
See:
https://github.com/juju/juju/blob/a93170f7ea42bb3e0774bc315ed5a6328631d8a3/cmd/juju/controller/destroy.go#L615-L620
Then ends up calling:
https://github.com/juju/juju/blob/a93170f7ea42bb3e0774bc315ed5a6328631d8a3/cmd/juju/controller/destroy.go#L699-L703
Which ultimately calls:
https://github.com/juju/juju/blob/a93170f7ea42bb3e0774bc315ed5a6328631d8a3/environs/open.go#L29-L31
The problem is this isn't correct for CAAS.
It would be interesting why we don't have anything in the local storage though?