[Azure] Juju does not clean up the compute resources after the controller destroy

Bug #1973641 reported by Vladimir Grevtsev
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Canonical Juju
Triaged
High
Unassigned

Bug Description

= Problem description
Juju (v2.9.29) can create, but can't cleanup its own VM/VNET resources upon controller removal.

= Steps to reproduce

ubuntu@aws:~$ juju bootstrap azure/westeurope --config resource-group-name=JujuController --config=logging-config="<root>=DEBUG" --no-default-model azure-controller

Creating Juju controller "azure-controller" on azure/westeurope
Looking for packaged Juju agent version 2.9.29 for amd64
Located Juju agent version 2.9.29-ubuntu-amd64 at https://jujuagents.blob.core.windows.net/juju-agents/agents/agent/2.9.29/juju-2.9.29-linux-amd64.tgz
Launching controller instance(s) on azure/westeurope...
 - machine-0 (arch=amd64 mem=3.5G cores=1)
Installing Juju agent on bootstrap instance
Fetching Juju Dashboard 0.8.1
Waiting for address
Attempting to connect to 52.232.109.238:22
Attempting to connect to 192.168.16.4:22
Connected to 52.232.109.238
Running machine configuration script...
Bootstrap agent now started
Contacting Juju controller at 192.168.16.4 to verify accessibility...

Bootstrap complete, controller "azure-controller" is now available
Controller machines are in the "controller" model

Now you can run
 juju add-model <model-name>
to create a new model to deploy workloads.

# check the resources are in-place
ubuntu@aws:~$ az resource list --resource-group JujuController -o table
Name ResourceGroup Location Type Status
--------------------- --------------- ---------- --------------------------------------- --------
juju-controller JujuController westeurope Microsoft.Compute/availabilitySets
machine-0 JujuController westeurope Microsoft.Compute/virtualMachines
machine-0-primary JujuController westeurope Microsoft.Network/networkInterfaces
juju-internal-nsg JujuController westeurope Microsoft.Network/networkSecurityGroups
machine-0-public-ip JujuController westeurope Microsoft.Network/publicIPAddresses
juju-internal-network JujuController westeurope Microsoft.Network/virtualNetworks

ubuntu@aws:~$ juju destroy-controller azure-controller
WARNING! This command will destroy the "azure-controller" controller.
This includes all machines, applications, data and other resources.

Continue? (y/N):y
Destroying controller
Waiting for hosted model resources to be reclaimed
All hosted models reclaimed, cleaning up controller machines

# but resources are still there!
ubuntu@aws:~$ sleep 300; az resource list --resource-group JujuController -o table
Name ResourceGroup Location Type Status
--------------------- --------------- ---------- --------------------------------------- --------
juju-controller JujuController westeurope Microsoft.Compute/availabilitySets
machine-0 JujuController westeurope Microsoft.Compute/virtualMachines
machine-0-primary JujuController westeurope Microsoft.Network/networkInterfaces
juju-internal-nsg JujuController westeurope Microsoft.Network/networkSecurityGroups
machine-0-public-ip JujuController westeurope Microsoft.Network/publicIPAddresses
juju-internal-network JujuController westeurope Microsoft.Network/virtualNetworks

Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 1973641] [NEW] [Azure] Juju does not clean up the compute resources after the controller destroy
Download full text (4.3 KiB)

I'm pretty sure Ian can give more detail here. I thought that if you force
the ResourceGroup, then Juju intentionally doesn't clean them up. Because
you're likely sharing that group with other resources consumed by other
applications (that was how others have used it in the past).
If you *don't* supply `--resource-group` then juju should create a UUID
based resource group and tear it down when the controller is torn down.

On Mon, May 16, 2022 at 4:40 PM Vladimir Grevtsev <
<email address hidden>> wrote:

> Public bug reported:
>
> = Problem description
> Juju (v2.9.29) can create, but can't cleanup its own VM/VNET resources
> upon controller removal.
>
> = Steps to reproduce
>
> ubuntu@aws:~$ juju bootstrap azure/westeurope --config resource-group-
> name=JujuController --config=logging-config="<root>=DEBUG" --no-default-
> model azure-controller
>
> Creating Juju controller "azure-controller" on azure/westeurope
> Looking for packaged Juju agent version 2.9.29 for amd64
> Located Juju agent version 2.9.29-ubuntu-amd64 at
> https://jujuagents.blob.core.windows.net/juju-agents/agents/agent/2.9.29/juju-2.9.29-linux-amd64.tgz
> Launching controller instance(s) on azure/westeurope...
> - machine-0 (arch=amd64 mem=3.5G cores=1)
> Installing Juju agent on bootstrap instance
> Fetching Juju Dashboard 0.8.1
> Waiting for address
> Attempting to connect to 52.232.109.238:22
> Attempting to connect to 192.168.16.4:22
> Connected to 52.232.109.238
> Running machine configuration script...
> Bootstrap agent now started
> Contacting Juju controller at 192.168.16.4 to verify accessibility...
>
> Bootstrap complete, controller "azure-controller" is now available
> Controller machines are in the "controller" model
>
> Now you can run
> juju add-model <model-name>
> to create a new model to deploy workloads.
>
> # check the resources are in-place
> ubuntu@aws:~$ az resource list --resource-group JujuController -o table
> Name ResourceGroup Location Type
> Status
> --------------------- --------------- ----------
> --------------------------------------- --------
> juju-controller JujuController westeurope
> Microsoft.Compute/availabilitySets
> machine-0 JujuController westeurope
> Microsoft.Compute/virtualMachines
> machine-0-primary JujuController westeurope
> Microsoft.Network/networkInterfaces
> juju-internal-nsg JujuController westeurope
> Microsoft.Network/networkSecurityGroups
> machine-0-public-ip JujuController westeurope
> Microsoft.Network/publicIPAddresses
> juju-internal-network JujuController westeurope
> Microsoft.Network/virtualNetworks
>
> ubuntu@aws:~$ juju destroy-controller azure-controller
> WARNING! This command will destroy the "azure-controller" controller.
> This includes all machines, applications, data and other resources.
>
> Continue? (y/N):y
> Destroying controller
> Waiting for hosted model resources to be reclaimed
> All hosted models reclaimed, cleaning up controller machines
>
> # but resources are still there!
> ubuntu@aws:~$ sleep 300; az resource list --resource-group JujuController
> -o table
> Name ...

Read more...

Revision history for this message
Ian Booth (wallyworld) wrote :

This is currently a known limitation with BYO resource groups and destroy controller

https://discourse.charmhub.io/t/juju-2-9-new-azure-features-disk-encryption-byo-vnets-public-ip-constraint/4030

Juju must not delete the resource group, just remove the relevant contents applicable to just the model(s) being removed. We'll need to look into what's needed to remove the current limitation. Until then, you need to manually remove any remaining resources.

Changed in juju:
milestone: none → 2.9-next
tags: added: azure-provider
Changed in juju:
importance: Undecided → High
status: New → Triaged
Revision history for this message
Vladimir Grevtsev (vlgrevtsev) wrote (last edit ):

Hi Ian,

Can we have this at least documented in the docs (not in some Discourse post) as a known limitation for the time being?

Ian Booth (wallyworld)
Changed in juju:
milestone: 2.9-next → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.