Juju destroy-model takes too long (sometimes returns timeout)

Hi folks,

While developing K8s charms I create and destroy models regularly, but sometimes juju takes a very long time to perform the action or even fails with timeout.

$ juju destroy-model -y mysql --force --no-wait --destroy-storage && juju switch controller
Destroying model
Waiting for model to be removed, 1 application(s), 3 volume(s), 3 filesystems(s).....
Waiting for model to be removed, 1 application(s)...
Waiting for model to be removed.................................................
................................................................................
................................................................................
................................................................................
......................................................................

While trying to remove the model a watch on juju status returns:

Cada 1,0s: juju status --color                                                                                                                                                                              miguelito: Thu Mar 25 15:45:34 2021

Model  Controller  Cloud/Region        Version  SLA          Timestamp       Notes
mysql  mk8s        microk8s/localhost  2.9-rc7  unsupported  15:45:35-03:00  attempt 6 to destroy model failed (will retry):  model not empty, found 1 volume, 1 filesystem (model not empty)

Model "admin/mysql" is empty.

I would like to understand why this happens. Which would be the best way to troubleshoot this?
I am using:

$  juju version
2.9-rc7-focal-amd64

thanks in advance!

Juju asks k8s to delete the namespace hosting the model and also delete any persistent volume claims. Juju will wait until this completes.
I have seen many times that k8s takes forever to remove these artifacts. You can use kubectl to confirm that the namespace is “terminating” etc to see that the wait is for k8s to complete the cleanup.

1 Like

My experience is that if you remove the machines first with
juju remove-machine X --force

Then this process is much less error prone.

Thanks @wallyworld

I forgot to mention that I am using microk8s version:

$ snap info microk8s  | grep installed
installed:          v1.20.4                    (2074) 218MB classic