Skip to content

Commit

Permalink
Consider all Networks on Router clean up
Browse files Browse the repository at this point in the history
When performing a cluster destroy we should
look for all cluster tagged Networks that might be
connected to the router, regardless if it was created
by CAPO. This commit updates the filtering for the
look up of Networks and ensure to skip the Subnet
when no Gateway is set.
  • Loading branch information
MaysaMacedo committed Sep 6, 2021
1 parent 5273a15 commit 37df748
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pkg/destroy/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,9 @@ func getRouterInterfaces(conn *gophercloud.ServiceClient, allNetworks []networks
logger.Debug(err)
return routerPorts, nil
}
if subnet.GatewayIP == "" {
continue
}
portListOpts := ports.ListOpts{
FixedIPs: []ports.FixedIPOpts{
{
Expand Down Expand Up @@ -630,14 +633,9 @@ func clearRouterInterfaces(opts *clientconfig.ClientOpts, filter Filter, logger
return false, nil
}

// Find the machines Network by the master machines Ports.
// Any worker nodes ports, including the ones used for additionalNetworks,
// are tagged with cluster-api-provider-openstack and should be excluded
// to ensure only the primary Network ports are filtered.
tags := filterTags(filter)
networkListOpts := networks.ListOpts{
Tags: strings.Join(tags, ","),
NotTags: "cluster-api-provider-openstack",
Tags: strings.Join(tags, ","),
}

allNetworksPages, err := networks.List(conn, networkListOpts).AllPages()
Expand Down

0 comments on commit 37df748

Please sign in to comment.