Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make publicips reconcile/delete async #1745

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1dd9f21
wip: make publicips reconcile async
karuppiah7890 Sep 30, 2021
e397f7b
wip: implement create or update async and implement public ip spec pa…
karuppiah7890 Oct 1, 2021
b82eb8f
move public ip spec to publicips package
karuppiah7890 Oct 1, 2021
aaae998
wip: add tests and implementation for Parameters method and add some …
karuppiah7890 Oct 2, 2021
08a914d
rename publicip_spec_test.go to spec_test.go
karuppiah7890 Oct 2, 2021
36d966b
wip: add todo about zones
karuppiah7890 Oct 2, 2021
d42eb7d
add todo for parallelizing tests in publicips spec test
karuppiah7890 Oct 2, 2021
a609795
add location, cluster name and additional tags field to public ip spe…
karuppiah7890 Oct 2, 2021
3fe5d0b
use the location, cluster name and additional tags from ip spec to co…
karuppiah7890 Oct 2, 2021
a6824a3
add zones field to public ip spec and use zones field to construct th…
karuppiah7890 Oct 2, 2021
396b443
remove todo for CreateOrUpdateAsync test
karuppiah7890 Oct 2, 2021
a5c7b31
add test for machine scope AdditionalTags method
karuppiah7890 Oct 2, 2021
85683ac
implement publicips client IsDone method
karuppiah7890 Oct 2, 2021
72d68f0
add test for cluster scope PublicIPSpecs method and fix an issue and …
karuppiah7890 Oct 2, 2021
4034ccc
add test for cluster scope FailureDomains method and remove some TODOs
karuppiah7890 Oct 2, 2021
339b8c5
add timeout to publicip service Reconcile method
karuppiah7890 Oct 2, 2021
8c26b22
add timeout to publicip service Delete method
karuppiah7890 Oct 2, 2021
e7ec334
wip: make public ips delete async
karuppiah7890 Oct 2, 2021
b1da4f0
add some todos
karuppiah7890 Oct 2, 2021
946c81b
update a todo
karuppiah7890 Oct 3, 2021
a49109e
add continue after error in getting ip management state to avoid logg…
karuppiah7890 Oct 3, 2021
aff734a
remove finished TODOs
karuppiah7890 Oct 3, 2021
ac72d84
update TODOs
karuppiah7890 Oct 3, 2021
f69ed77
implement the DeleteAsync method of the public ips client
karuppiah7890 Oct 3, 2021
c12e916
delete the unused Delete method of the public ips client
karuppiah7890 Oct 3, 2021
f81d496
use pointer receiver for public ip spec methods
karuppiah7890 Oct 3, 2021
87876ee
rename ip to ipSpec in publicips reconcile method
karuppiah7890 Oct 3, 2021
59ae8e8
change the signature of PublicIPSpecs method to return []azure.Resour…
karuppiah7890 Oct 3, 2021
abdd6d2
fix publicips_test.go tests
karuppiah7890 Oct 3, 2021
815ddce
fix public ip specs tests for cluster scope and machine scope PublicI…
karuppiah7890 Oct 3, 2021
ca50e87
fix lint issues
karuppiah7890 Oct 4, 2021
a807225
update publicips client mock
karuppiah7890 Oct 4, 2021
8d1aa48
add todo regarding api call to check if public ip is managed or not
karuppiah7890 Oct 5, 2021
b9c51d4
make the tests parallel
karuppiah7890 Oct 15, 2021
5ef7626
remove todo comment from isIPManaged method
karuppiah7890 Nov 30, 2021
57da368
fix compilation errors
karuppiah7890 Nov 30, 2021
42f4a81
fix test failures
karuppiah7890 Nov 30, 2021
7dc3fda
add extra tests for error precedence in public ip deletion method
karuppiah7890 Nov 30, 2021
74cbb90
go format azure/scope/cluster.go and azure/scope/machine.go files
karuppiah7890 Nov 30, 2021
2c6fa2d
fix order of import in publicips_mock.go
karuppiah7890 Nov 30, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 47 additions & 21 deletions azure/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-azure/azure"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/groups"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/publicips"
"sigs.k8s.io/cluster-api-provider-azure/azure/services/vnetpeerings"
"sigs.k8s.io/cluster-api-provider-azure/util/futures"
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
Expand Down Expand Up @@ -122,21 +123,26 @@ func (s *ClusterScope) Authorizer() autorest.Authorizer {
}

// PublicIPSpecs returns the public IP specs.
func (s *ClusterScope) PublicIPSpecs() []azure.PublicIPSpec {
var publicIPSpecs []azure.PublicIPSpec
func (s *ClusterScope) PublicIPSpecs() []azure.ResourceSpecGetter {
var publicIPSpecs []azure.ResourceSpecGetter

// Public IP specs for control plane lb
var controlPlaneOutboundIPSpecs []azure.PublicIPSpec
var controlPlaneOutboundIPSpecs []azure.ResourceSpecGetter
if s.IsAPIServerPrivate() {
// Public IP specs for control plane outbound lb
if s.ControlPlaneOutboundLB() != nil {
controlPlaneOutboundIPSpecs = s.getOutboundLBPublicIPSpecs(s.ControlPlaneOutboundLB(), azure.GenerateControlPlaneOutboundIPName)
}
} else {
controlPlaneOutboundIPSpecs = []azure.PublicIPSpec{{
Name: s.APIServerPublicIP().Name,
DNSName: s.APIServerPublicIP().DNSName,
IsIPv6: false, // currently azure requires a ipv4 lb rule to enable ipv6
controlPlaneOutboundIPSpecs = []azure.ResourceSpecGetter{&publicips.PublicIPSpec{
Name: s.APIServerPublicIP().Name,
DNSName: s.APIServerPublicIP().DNSName,
IsIPv6: false, // currently azure requires a ipv4 lb rule to enable ipv6
ResourceGroup: s.ResourceGroup(),
Location: s.Location(),
ClusterName: s.ClusterName(),
AdditionalTags: s.AdditionalTags(),
Zones: s.FailureDomains(),
}}
}
publicIPSpecs = append(publicIPSpecs, controlPlaneOutboundIPSpecs...)
Expand All @@ -148,22 +154,32 @@ func (s *ClusterScope) PublicIPSpecs() []azure.PublicIPSpec {
}

// Public IP specs for node nat gateways
var nodeNatGatewayIPSpecs []azure.PublicIPSpec
var nodeNatGatewayIPSpecs []azure.ResourceSpecGetter
for _, subnet := range s.NodeSubnets() {
if subnet.IsNatGatewayEnabled() {
nodeNatGatewayIPSpecs = append(nodeNatGatewayIPSpecs, azure.PublicIPSpec{
Name: subnet.NatGateway.NatGatewayIP.Name,
DNSName: subnet.NatGateway.NatGatewayIP.DNSName,
nodeNatGatewayIPSpecs = append(nodeNatGatewayIPSpecs, &publicips.PublicIPSpec{
Name: subnet.NatGateway.NatGatewayIP.Name,
DNSName: subnet.NatGateway.NatGatewayIP.DNSName,
ResourceGroup: s.ResourceGroup(),
Location: s.Location(),
ClusterName: s.ClusterName(),
AdditionalTags: s.AdditionalTags(),
Zones: s.FailureDomains(),
})
}
publicIPSpecs = append(publicIPSpecs, nodeNatGatewayIPSpecs...)
}
publicIPSpecs = append(publicIPSpecs, nodeNatGatewayIPSpecs...)

if s.AzureCluster.Spec.BastionSpec.AzureBastion != nil {
// public IP for Azure Bastion.
azureBastionPublicIP := azure.PublicIPSpec{
Name: s.AzureCluster.Spec.BastionSpec.AzureBastion.PublicIP.Name,
DNSName: s.AzureCluster.Spec.BastionSpec.AzureBastion.PublicIP.DNSName,
azureBastionPublicIP := &publicips.PublicIPSpec{
Name: s.AzureCluster.Spec.BastionSpec.AzureBastion.PublicIP.Name,
DNSName: s.AzureCluster.Spec.BastionSpec.AzureBastion.PublicIP.DNSName,
ResourceGroup: s.ResourceGroup(),
Location: s.Location(),
ClusterName: s.ClusterName(),
AdditionalTags: s.AdditionalTags(),
Zones: s.FailureDomains(),
}
publicIPSpecs = append(publicIPSpecs, azureBastionPublicIP)
}
Expand Down Expand Up @@ -730,19 +746,29 @@ func (s *ClusterScope) SetDNSName() {
}

// getOutboundLBPublicIPSpecs returns the public ip specs for a LoadBalancerSpec based on the number of frontend ips configured.
func (s *ClusterScope) getOutboundLBPublicIPSpecs(outboundLB *infrav1.LoadBalancerSpec, generateOutboundIPName func(string) string) []azure.PublicIPSpec {
var outboundIPSpecs []azure.PublicIPSpec
func (s *ClusterScope) getOutboundLBPublicIPSpecs(outboundLB *infrav1.LoadBalancerSpec, generateOutboundIPName func(string) string) []azure.ResourceSpecGetter {
var outboundIPSpecs []azure.ResourceSpecGetter
loadBalancerNodeOutboundIPs := outboundLB.FrontendIPsCount
if loadBalancerNodeOutboundIPs == nil || *loadBalancerNodeOutboundIPs == 0 {
// do nothing
} else if *loadBalancerNodeOutboundIPs == 1 {
outboundIPSpecs = append(outboundIPSpecs, azure.PublicIPSpec{
Name: generateOutboundIPName(s.ClusterName()),
outboundIPSpecs = append(outboundIPSpecs, &publicips.PublicIPSpec{
Name: generateOutboundIPName(s.ClusterName()),
ResourceGroup: s.ResourceGroup(),
Location: s.Location(),
ClusterName: s.ClusterName(),
AdditionalTags: s.AdditionalTags(),
Zones: s.FailureDomains(),
})
} else {
for i := 0; i < int(*loadBalancerNodeOutboundIPs); i++ {
outboundIPSpecs = append(outboundIPSpecs, azure.PublicIPSpec{
Name: azure.WithIndex(generateOutboundIPName(s.ClusterName()), i+1),
outboundIPSpecs = append(outboundIPSpecs, &publicips.PublicIPSpec{
Name: azure.WithIndex(generateOutboundIPName(s.ClusterName()), i+1),
ResourceGroup: s.ResourceGroup(),
Location: s.Location(),
ClusterName: s.ClusterName(),
AdditionalTags: s.AdditionalTags(),
Zones: s.FailureDomains(),
})
}
}
Expand Down
Loading