@@ -858,7 +858,7 @@ func (l *loadbalancers) getFrontendVPCCreateOptions(ctx context.Context, service
858858 frontendIPv6Range , hasIPv6Range := service .GetAnnotations ()[annotations .NodeBalancerFrontendIPv6Range ]
859859 _ , hasVPCName := service .GetAnnotations ()[annotations .NodeBalancerFrontendVPCName ]
860860 _ , hasSubnetName := service .GetAnnotations ()[annotations .NodeBalancerFrontendSubnetName ]
861- _ , hasSubnetID := service .GetAnnotations ()[annotations .NodeBalancerFrontendSubnetID ]
861+ frontendSubnetID , hasSubnetID := service .GetAnnotations ()[annotations .NodeBalancerFrontendSubnetID ]
862862
863863 // If no frontend VPC annotations are present, do not configure a frontend VPC.
864864 if ! hasIPv4Range && ! hasIPv6Range && ! hasVPCName && ! hasSubnetName && ! hasSubnetID {
@@ -875,18 +875,18 @@ func (l *loadbalancers) getFrontendVPCCreateOptions(ctx context.Context, service
875875 var subnetID int
876876 var err error
877877
878- if hasSubnetID {
879- frontendSubnetID := service . GetAnnotations ()[ annotations . NodeBalancerFrontendSubnetID ]
878+ switch {
879+ case hasSubnetID :
880880 subnetID , err = strconv .Atoi (frontendSubnetID )
881881 if err != nil {
882882 return nil , fmt .Errorf ("invalid frontend subnet ID: %w" , err )
883883 }
884- } else if hasVPCName || hasSubnetName {
884+ case hasVPCName || hasSubnetName :
885885 subnetID , err = l .getFrontendSubnetIDForSVC (ctx , service )
886886 if err != nil {
887887 return nil , err
888888 }
889- } else {
889+ default :
890890 // Ranges are optional but still require a subnet to target.
891891 return nil , fmt .Errorf ("frontend VPC configuration requires either subnet-id or both vpc-name and subnet-name annotations" )
892892 }
@@ -919,17 +919,9 @@ func (l *loadbalancers) getFrontendSubnetIDForSVC(ctx context.Context, service *
919919 specifiedVPCName , vpcOk := service .GetAnnotations ()[annotations .NodeBalancerFrontendVPCName ]
920920 specifiedSubnetName , subnetOk := service .GetAnnotations ()[annotations .NodeBalancerFrontendSubnetName ]
921921
922- // If no VPCName or SubnetName is specified, return error
923- if ! vpcOk && ! subnetOk {
924- return 0 , fmt .Errorf ("frontend VPC configuration requires either vpc-name, subnet-name, or subnet-id annotations" )
925- }
926-
927- // Require both VPC name and subnet name when using name-based resolution
928- if ! vpcOk {
929- return 0 , fmt .Errorf ("frontend VPC configuration with subnet-name requires vpc-name annotation" )
930- }
931- if ! subnetOk {
932- return 0 , fmt .Errorf ("frontend VPC configuration with vpc-name requires subnet-name annotation" )
922+ // If no VPCName or SubnetName is specified and no subnet-id is provided, return error
923+ if ! vpcOk || ! subnetOk {
924+ return 0 , fmt .Errorf ("frontend VPC configuration requires either subnet-id annotation or both vpc-name and subnet-name annotations" )
933925 }
934926
935927 vpcID , err := services .GetVPCID (ctx , l .client , specifiedVPCName )
@@ -1436,9 +1428,7 @@ func makeLoadBalancerStatus(service *v1.Service, nb *linodego.NodeBalancer) *v1.
14361428 }
14371429 }
14381430
1439- // Debug info log: Is a frontend VPC NodeBalancer?
1440- isFrontendVPC := nb .FrontendAddressType != nil && * nb .FrontendAddressType == "vpc"
1441- if isFrontendVPC {
1431+ if nb .FrontendAddressType != nil && * nb .FrontendAddressType == "vpc" {
14421432 klog .V (4 ).Infof ("NodeBalancer (%d) is using frontend VPC address type" , nb .ID )
14431433 }
14441434
0 commit comments