Skip to content

Commit a46ce9b

Browse files
authored
Merge pull request #18156 from hakman/azure-task-deps
azure: Fix task dependencies during cluster update
2 parents c005e86 + 32a01b8 commit a46ce9b

5 files changed

Lines changed: 23 additions & 3 deletions

File tree

pkg/model/azuremodel/api_loadbalancer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func (b *APILoadBalancerModelBuilder) Build(c *fi.CloudupModelBuilderContext) er
7676
Tags: map[string]*string{},
7777
}
7878
c.AddTask(p)
79+
lb.PublicIPAddress = p
7980
default:
8081
return fmt.Errorf("unknown load balancer Type: %q", lbSpec.Type)
8182
}

pkg/model/azuremodel/network.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ func (b *NetworkModelBuilder) Build(c *fi.CloudupModelBuilderContext) error {
5151
Name: fi.PtrTo(b.NameForVirtualNetwork()),
5252
Lifecycle: b.Lifecycle,
5353
ResourceGroup: b.LinkToResourceGroup(),
54-
Tags: map[string]*string{},
54+
ApplicationSecurityGroups: []*azuretasks.ApplicationSecurityGroup{
55+
b.LinkToApplicationSecurityGroupControlPlane(),
56+
b.LinkToApplicationSecurityGroupNodes(),
57+
},
58+
Tags: map[string]*string{},
5559
}
5660
sshAccessIPv4 := ipv4CIDRs(b.Cluster.Spec.SSHAccess)
5761
if len(sshAccessIPv4) > 0 {

upup/pkg/fi/cloudup/azuretasks/loadbalancer.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ type LoadBalancer struct {
4242
// External is set to true when the loadbalancer is used for external traffic
4343
External *bool
4444

45+
// PublicIPAddress is the public IP address for external load balancers.
46+
PublicIPAddress *PublicIPAddress
47+
4548
Tags map[string]*string
4649

4750
// WellKnownServices indicates which services are supported by this resource.
@@ -135,6 +138,11 @@ func (lb *LoadBalancer) Find(c *fi.CloudupContext) (*LoadBalancer, error) {
135138
Name: subnet.Name,
136139
}
137140
}
141+
if feConfig.Properties.PublicIPAddress != nil {
142+
actual.PublicIPAddress = &PublicIPAddress{
143+
ID: feConfig.Properties.PublicIPAddress.ID,
144+
}
145+
}
138146

139147
return actual, nil
140148
}
@@ -178,7 +186,7 @@ func (*LoadBalancer) RenderAzure(t *azure.AzureAPITarget, a, e, changes *LoadBal
178186
feConfigProperties := &network.FrontendIPConfigurationPropertiesFormat{}
179187
if *e.External {
180188
feConfigProperties.PublicIPAddress = &network.PublicIPAddress{
181-
ID: to.Ptr(fmt.Sprintf("/%s/publicIPAddresses/%s", idPrefix, *e.Name)),
189+
ID: e.PublicIPAddress.ID,
182190
}
183191
} else {
184192
feConfigProperties.PrivateIPAllocationMethod = to.Ptr(network.IPAllocationMethodDynamic)

upup/pkg/fi/cloudup/azuretasks/loadbalancer_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ func newTestLoadBalancer() *LoadBalancer {
4444
Name: to.Ptr("vnet"),
4545
},
4646
},
47-
External: to.Ptr(true),
47+
External: to.Ptr(true),
48+
PublicIPAddress: &PublicIPAddress{
49+
ID: to.Ptr("/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/publicIPAddresses/loadbalancer"),
50+
},
4851
WellKnownServices: []wellknownservices.WellKnownService{wellknownservices.KubeAPIServer},
4952
Tags: map[string]*string{
5053
testTagKey: to.Ptr(testTagValue),

upup/pkg/fi/cloudup/azuretasks/networksecuritygroup.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ type NetworkSecurityGroup struct {
3838

3939
SecurityRules []*NetworkSecurityRule
4040

41+
// ApplicationSecurityGroups are the ASGs referenced by security rules.
42+
// This field is used for dependency ordering and is not rendered to the cloud.
43+
ApplicationSecurityGroups []*ApplicationSecurityGroup
44+
4145
Tags map[string]*string
4246
}
4347

0 commit comments

Comments
 (0)