Skip to content

Commit 5a9cd87

Browse files
Merge pull request #9603 from patrickdillon/ocpbugs-54232-vnet-rg
OCPBUGS-54232: Azure Move BYO VNET SG creation to InfraReady
2 parents d0738a8 + 21daed5 commit 5a9cd87

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

pkg/infrastructure/azure/azure.go

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ type Provider struct {
5555
Tags map[string]*string
5656
}
5757

58-
var _ clusterapi.PreProvider = (*Provider)(nil)
5958
var _ clusterapi.InfraReadyProvider = (*Provider)(nil)
6059
var _ clusterapi.PostProvider = (*Provider)(nil)
6160
var _ clusterapi.IgnitionProvider = (*Provider)(nil)
@@ -83,8 +82,8 @@ func (p Provider) ProvisionTimeout() time.Duration {
8382
// in the status and should use the API load balancer when gathering bootstrap log bundles.
8483
func (*Provider) PublicGatherEndpoint() clusterapi.GatherEndpoint { return clusterapi.APILoadBalancer }
8584

86-
// PreProvision is called before provisioning using CAPI controllers has begun.
87-
func (p *Provider) PreProvision(ctx context.Context, in clusterapi.PreProvisionInput) error {
85+
// InfraReady is called once the installer infrastructure is ready.
86+
func (p *Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput) error {
8887
session, err := in.InstallConfig.Azure.Session()
8988
if err != nil {
9089
return fmt.Errorf("failed to get session: %w", err)
@@ -127,7 +126,7 @@ func (p *Provider) PreProvision(ctx context.Context, in clusterapi.PreProvisionI
127126
securityGroupName,
128127
armnetwork.SecurityGroup{
129128
Location: to.Ptr(platform.Region),
130-
Tags: tags,
129+
Tags: p.Tags,
131130
},
132131
nil)
133132
if err != nil {
@@ -140,21 +139,6 @@ func (p *Provider) PreProvision(ctx context.Context, in clusterapi.PreProvisionI
140139
logrus.Infof("nsg=%s", *nsg.ID)
141140
}
142141

143-
return nil
144-
}
145-
146-
// InfraReady is called once the installer infrastructure is ready.
147-
func (p *Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput) error {
148-
session, err := in.InstallConfig.Azure.Session()
149-
if err != nil {
150-
return fmt.Errorf("failed to get session: %w", err)
151-
}
152-
153-
installConfig := in.InstallConfig.Config
154-
platform := installConfig.Platform.Azure
155-
subscriptionID := session.Credentials.SubscriptionID
156-
cloudConfiguration := session.CloudConfig
157-
158142
var architecture armcompute.Architecture
159143
if installConfig.ControlPlane.Architecture == types.ArchitectureARM64 {
160144
architecture = armcompute.ArchitectureArm64
@@ -199,14 +183,6 @@ func (p *Provider) InfraReady(ctx context.Context, in clusterapi.InfraReadyInput
199183
return fmt.Errorf("image length is not aligned on a 512 byte boundary")
200184
}
201185

202-
userTags := platform.UserTags
203-
tags := make(map[string]*string, len(userTags)+1)
204-
tags[fmt.Sprintf("kubernetes.io_cluster.%s", in.InfraID)] = ptr.To("owned")
205-
for k, v := range userTags {
206-
tags[k] = ptr.To(v)
207-
}
208-
209-
tokenCredential := session.TokenCreds
210186
storageURL := fmt.Sprintf("https://%s.blob.%s", storageAccountName, session.Environment.StorageEndpointSuffix)
211187
blobURL := fmt.Sprintf("%s/%s/%s", storageURL, containerName, blobName)
212188

0 commit comments

Comments
 (0)