@@ -13,14 +13,23 @@ import (
1313)
1414
1515func (az * Cloud ) existsServiceGateway (ctx context.Context , serviceGatewayName string ) (bool , error ) {
16- _ , err := az .GetServiceGateway (ctx , serviceGatewayName )
16+ sgw , err := az .GetServiceGateway (ctx , serviceGatewayName )
1717 if err != nil {
1818 if strings .Contains (err .Error (), consts .ResourceNotFoundMessageCode ) {
1919 return false , nil
2020 }
2121 klog .Infof ("ExistsServiceGateway: error checking existence of Service Gateway %s in resource group %s: %v" , serviceGatewayName , az .ResourceGroup , err )
2222 return false , err
2323 }
24+
25+ if sgw == nil || sgw .Properties == nil || sgw .Properties .RouteTargetAddress == nil ||
26+ sgw .Properties .RouteTargetAddress .PrivateIPAllocationMethod == nil ||
27+ * sgw .Properties .RouteTargetAddress .PrivateIPAllocationMethod != armnetwork .IPAllocationMethodDynamic ||
28+ sgw .Properties .RouteTargetAddress .Subnet == nil {
29+ klog .Infof ("ExistsServiceGateway: Service Gateway %s in resource group %s is not properly configured" , serviceGatewayName , az .ResourceGroup )
30+ return false , nil
31+ }
32+
2433 return true , nil
2534}
2635
@@ -39,6 +48,18 @@ func (az *Cloud) createServiceGateway(ctx context.Context, serviceGatewayName st
3948 az .ResourceGroup ,
4049 az .VnetName ,
4150 ))},
51+ RouteTargetAddress : & armnetwork.RouteTargetAddressPropertiesFormat {
52+ PrivateIPAllocationMethod : to .Ptr (armnetwork .IPAllocationMethodDynamic ),
53+ Subnet : & armnetwork.Subnet {
54+ ID : to .Ptr (fmt .Sprintf (
55+ "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworks/%s/subnets/%s" ,
56+ az .SubscriptionID ,
57+ az .ResourceGroup ,
58+ az .VnetName ,
59+ az .SubnetName ,
60+ )),
61+ },
62+ },
4263 },
4364 }
4465 // logObject(serviceGateway)
0 commit comments