@@ -167,6 +167,10 @@ func (d *Driver) getServicePrincipalToken(env azure.Environment, resource string
167
167
}
168
168
169
169
func (d * Driver ) updateSubnetServiceEndpoints (ctx context.Context ) error {
170
+ if d .cloud .SubnetsClient == nil {
171
+ return fmt .Errorf ("SubnetsClient is nil" )
172
+ }
173
+
170
174
resourceGroup := d .cloud .ResourceGroup
171
175
if len (d .cloud .VnetResourceGroup ) > 0 {
172
176
resourceGroup = d .cloud .VnetResourceGroup
@@ -175,9 +179,11 @@ func (d *Driver) updateSubnetServiceEndpoints(ctx context.Context) error {
175
179
vnetName := d .cloud .VnetName
176
180
subnetName := d .cloud .SubnetName
177
181
178
- if d .cloud .SubnetsClient == nil {
179
- return fmt .Errorf ("SubnetsClient is nil" )
180
- }
182
+ klog .V (2 ).Infof ("updateSubnetServiceEndpoints on VnetName: %s, SubnetName: %s" , vnetName , subnetName )
183
+
184
+ lockKey := resourceGroup + vnetName + subnetName
185
+ d .subnetLockMap .LockEntry (lockKey )
186
+ defer d .subnetLockMap .UnlockEntry (lockKey )
181
187
182
188
subnet , err := d .cloud .SubnetsClient .Get (ctx , resourceGroup , vnetName , subnetName , "" )
183
189
if err != nil {
@@ -208,15 +214,11 @@ func (d *Driver) updateSubnetServiceEndpoints(ctx context.Context) error {
208
214
serviceEndpoints = append (serviceEndpoints , storageServiceEndpoint )
209
215
subnet .SubnetPropertiesFormat .ServiceEndpoints = & serviceEndpoints
210
216
211
- lockKey := resourceGroup + vnetName + subnetName
212
- d .subnetLockMap .LockEntry (lockKey )
213
- defer d .subnetLockMap .UnlockEntry (lockKey )
214
-
215
217
err = d .cloud .SubnetsClient .CreateOrUpdate (context .Background (), resourceGroup , vnetName , subnetName , subnet )
216
218
if err != nil {
217
219
return fmt .Errorf ("failed to update the subnet %s under vnet %s: %v" , subnetName , vnetName , err )
218
220
}
219
- klog .V (4 ).Infof ("serviceEndpoint(%s) is appended in subnet(%s)" , storageService , subnetName )
221
+ klog .V (2 ).Infof ("serviceEndpoint(%s) is appended in subnet(%s)" , storageService , subnetName )
220
222
}
221
223
222
224
return nil
0 commit comments