Skip to content

Commit 9eb1196

Browse files
authored
Merge pull request #592 from andyzhangx/subnet-check
fix: return error earlier when subnetName is empty
2 parents 7a9303d + 0ce750a commit 9eb1196

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/blob/azure.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ func (d *Driver) updateSubnetServiceEndpoints(ctx context.Context) error {
195195
vnetName := d.cloud.VnetName
196196
subnetName := d.cloud.SubnetName
197197

198-
klog.V(2).Infof("updateSubnetServiceEndpoints on VnetName: %s, SubnetName: %s", vnetName, subnetName)
198+
klog.V(2).Infof("updateSubnetServiceEndpoints on vnetName: %s, subnetName: %s, location: %s", vnetName, subnetName, location)
199+
if subnetName == "" || vnetName == "" || location == "" {
200+
return fmt.Errorf("value of subnetName, vnetName or location is empty")
201+
}
199202

200203
lockKey := resourceGroup + vnetName + subnetName
201204
d.subnetLockMap.LockEntry(lockKey)
@@ -230,8 +233,7 @@ func (d *Driver) updateSubnetServiceEndpoints(ctx context.Context) error {
230233
serviceEndpoints = append(serviceEndpoints, storageServiceEndpoint)
231234
subnet.SubnetPropertiesFormat.ServiceEndpoints = &serviceEndpoints
232235

233-
err = d.cloud.SubnetsClient.CreateOrUpdate(context.Background(), resourceGroup, vnetName, subnetName, subnet)
234-
if err != nil {
236+
if err := d.cloud.SubnetsClient.CreateOrUpdate(ctx, resourceGroup, vnetName, subnetName, subnet); err != nil {
235237
return fmt.Errorf("failed to update the subnet %s under vnet %s: %v", subnetName, vnetName, err)
236238
}
237239
klog.V(2).Infof("serviceEndpoint(%s) is appended in subnet(%s)", storageService, subnetName)

0 commit comments

Comments
 (0)