@@ -484,13 +484,13 @@ func TestReconcileSecurityGroupFromAnyDestinationAddressPrefixToLoadBalancerIP(t
484
484
az := getTestCloud ()
485
485
svc1 := getTestService ("serviceea" , v1 .ProtocolTCP , nil , 80 )
486
486
svc1 .Spec .LoadBalancerIP = "192.168.0.0"
487
- sg := getTestSecurityGroup (az )
487
+ getTestSecurityGroup (az )
488
488
// Simulate a pre-Kubernetes 1.8 NSG, where we do not specify the destination address prefix
489
- sg , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr ("" ), true )
489
+ _ , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr ("" ), true )
490
490
if err != nil {
491
491
t .Errorf ("Unexpected error: %q" , err )
492
492
}
493
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
493
+ sg , err : = az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
494
494
if err != nil {
495
495
t .Errorf ("Unexpected error: %q" , err )
496
496
}
@@ -501,7 +501,7 @@ func TestReconcileSecurityGroupDynamicLoadBalancerIP(t *testing.T) {
501
501
az := getTestCloud ()
502
502
svc1 := getTestService ("servicea" , v1 .ProtocolTCP , nil , 80 )
503
503
svc1 .Spec .LoadBalancerIP = ""
504
- sg := getTestSecurityGroup (az )
504
+ getTestSecurityGroup (az )
505
505
dynamicallyAssignedIP := "192.168.0.0"
506
506
sg , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (dynamicallyAssignedIP ), true )
507
507
if err != nil {
@@ -603,12 +603,12 @@ func TestReconcileLoadBalancerRemoveService(t *testing.T) {
603
603
clusterResources := getClusterResources (az , 1 , 1 )
604
604
svc := getTestService ("servicea" , v1 .ProtocolTCP , nil , 80 , 443 )
605
605
606
- lb , err := az .reconcileLoadBalancer (testClusterName , & svc , clusterResources .nodes , true /* wantLb */ )
606
+ _ , err := az .reconcileLoadBalancer (testClusterName , & svc , clusterResources .nodes , true /* wantLb */ )
607
607
if err != nil {
608
608
t .Errorf ("Unexpected error: %q" , err )
609
609
}
610
610
611
- lb , err = az .reconcileLoadBalancer (testClusterName , & svc , clusterResources .nodes , false /* wantLb */ )
611
+ lb , err : = az .reconcileLoadBalancer (testClusterName , & svc , clusterResources .nodes , false /* wantLb */ )
612
612
if err != nil {
613
613
t .Errorf ("Unexpected error: %q" , err )
614
614
}
@@ -653,13 +653,13 @@ func TestReconcileLoadBalancerRemovesPort(t *testing.T) {
653
653
clusterResources := getClusterResources (az , 1 , 1 )
654
654
655
655
svc := getTestService ("servicea" , v1 .ProtocolTCP , nil , 80 , 443 )
656
- lb , err := az .reconcileLoadBalancer (testClusterName , & svc , clusterResources .nodes , true /* wantLb */ )
656
+ _ , err := az .reconcileLoadBalancer (testClusterName , & svc , clusterResources .nodes , true /* wantLb */ )
657
657
if err != nil {
658
658
t .Errorf ("Unexpected error: %q" , err )
659
659
}
660
660
661
661
svcUpdated := getTestService ("servicea" , v1 .ProtocolTCP , nil , 80 )
662
- lb , err = az .reconcileLoadBalancer (testClusterName , & svcUpdated , clusterResources .nodes , true /* wantLb */ )
662
+ lb , err : = az .reconcileLoadBalancer (testClusterName , & svcUpdated , clusterResources .nodes , true /* wantLb */ )
663
663
if err != nil {
664
664
t .Errorf ("Unexpected error: %q" , err )
665
665
}
@@ -674,12 +674,12 @@ func TestReconcileLoadBalancerMultipleServices(t *testing.T) {
674
674
svc1 := getTestService ("servicea" , v1 .ProtocolTCP , nil , 80 , 443 )
675
675
svc2 := getTestService ("serviceb" , v1 .ProtocolTCP , nil , 80 )
676
676
677
- updatedLoadBalancer , err := az .reconcileLoadBalancer (testClusterName , & svc1 , clusterResources .nodes , true /* wantLb */ )
677
+ _ , err := az .reconcileLoadBalancer (testClusterName , & svc1 , clusterResources .nodes , true /* wantLb */ )
678
678
if err != nil {
679
679
t .Errorf ("Unexpected error: %q" , err )
680
680
}
681
681
682
- updatedLoadBalancer , err = az .reconcileLoadBalancer (testClusterName , & svc2 , clusterResources .nodes , true /* wantLb */ )
682
+ updatedLoadBalancer , err : = az .reconcileLoadBalancer (testClusterName , & svc2 , clusterResources .nodes , true /* wantLb */ )
683
683
if err != nil {
684
684
t .Errorf ("Unexpected error: %q" , err )
685
685
}
@@ -822,7 +822,7 @@ func TestReconcileSecurityGroupRemoveServiceRemovesPort(t *testing.T) {
822
822
svc := getTestService ("servicea" , v1 .ProtocolTCP , nil , 80 , 443 )
823
823
clusterResources := getClusterResources (az , 1 , 1 )
824
824
825
- sg := getTestSecurityGroup (az , svc )
825
+ getTestSecurityGroup (az , svc )
826
826
svcUpdated := getTestService ("servicea" , v1 .ProtocolTCP , nil , 80 )
827
827
lb , _ := az .reconcileLoadBalancer (testClusterName , & svc , clusterResources .nodes , true )
828
828
lbStatus , _ := az .getServiceLoadBalancerStatus (& svc , lb )
@@ -844,7 +844,7 @@ func TestReconcileSecurityWithSourceRanges(t *testing.T) {
844
844
}
845
845
clusterResources := getClusterResources (az , 1 , 1 )
846
846
847
- sg := getTestSecurityGroup (az , svc )
847
+ getTestSecurityGroup (az , svc )
848
848
lb , _ := az .reconcileLoadBalancer (testClusterName , & svc , clusterResources .nodes , true )
849
849
lbStatus , _ := az .getServiceLoadBalancerStatus (& svc , lb )
850
850
@@ -1109,9 +1109,7 @@ func getClusterResources(az *Cloud, vmCount int, availabilitySetCount int) (clus
1109
1109
1110
1110
vmCtx , vmCancel := getContextWithCancel ()
1111
1111
defer vmCancel ()
1112
- _ , err := az .VirtualMachinesClient .CreateOrUpdate (vmCtx , az .Config .ResourceGroup , vmName , newVM , "" )
1113
- if err != nil {
1114
- }
1112
+ az .VirtualMachinesClient .CreateOrUpdate (vmCtx , az .Config .ResourceGroup , vmName , newVM , "" )
1115
1113
// add to kubernetes
1116
1114
newNode := & v1.Node {
1117
1115
ObjectMeta : metav1.ObjectMeta {
@@ -1809,7 +1807,7 @@ func TestIfServiceSpecifiesSharedRuleAndRuleDoesNotExistItIsCreated(t *testing.T
1809
1807
svc .Spec .LoadBalancerIP = "192.168.77.88"
1810
1808
svc .Annotations [ServiceAnnotationSharedSecurityRule ] = "true"
1811
1809
1812
- sg := getTestSecurityGroup (az )
1810
+ getTestSecurityGroup (az )
1813
1811
1814
1812
sg , err := az .reconcileSecurityGroup (testClusterName , & svc , to .StringPtr (svc .Spec .LoadBalancerIP ), true )
1815
1813
if err != nil {
@@ -1908,14 +1906,14 @@ func TestIfServicesSpecifySharedRuleButDifferentPortsThenSeparateRulesAreCreated
1908
1906
expectedRuleName1 := "shared-TCP-4444-Internet"
1909
1907
expectedRuleName2 := "shared-TCP-8888-Internet"
1910
1908
1911
- sg := getTestSecurityGroup (az )
1909
+ getTestSecurityGroup (az )
1912
1910
1913
- sg , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
1911
+ _ , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
1914
1912
if err != nil {
1915
1913
t .Errorf ("Unexpected error adding svc1: %q" , err )
1916
1914
}
1917
1915
1918
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
1916
+ sg , err : = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
1919
1917
if err != nil {
1920
1918
t .Errorf ("Unexpected error adding svc2: %q" , err )
1921
1919
}
@@ -1977,14 +1975,14 @@ func TestIfServicesSpecifySharedRuleButDifferentProtocolsThenSeparateRulesAreCre
1977
1975
expectedRuleName1 := "shared-TCP-4444-Internet"
1978
1976
expectedRuleName2 := "shared-UDP-4444-Internet"
1979
1977
1980
- sg := getTestSecurityGroup (az )
1978
+ getTestSecurityGroup (az )
1981
1979
1982
- sg , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
1980
+ _ , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
1983
1981
if err != nil {
1984
1982
t .Errorf ("Unexpected error adding svc1: %q" , err )
1985
1983
}
1986
1984
1987
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
1985
+ sg , err : = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
1988
1986
if err != nil {
1989
1987
t .Errorf ("Unexpected error adding svc2: %q" , err )
1990
1988
}
@@ -2046,14 +2044,14 @@ func TestIfServicesSpecifySharedRuleButDifferentSourceAddressesThenSeparateRules
2046
2044
expectedRuleName1 := "shared-TCP-80-192.168.12.0_24"
2047
2045
expectedRuleName2 := "shared-TCP-80-192.168.34.0_24"
2048
2046
2049
- sg := getTestSecurityGroup (az )
2047
+ getTestSecurityGroup (az )
2050
2048
2051
- sg , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
2049
+ _ , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
2052
2050
if err != nil {
2053
2051
t .Errorf ("Unexpected error adding svc1: %q" , err )
2054
2052
}
2055
2053
2056
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
2054
+ sg , err : = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
2057
2055
if err != nil {
2058
2056
t .Errorf ("Unexpected error adding svc2: %q" , err )
2059
2057
}
@@ -2119,19 +2117,19 @@ func TestIfServicesSpecifySharedRuleButSomeAreOnDifferentPortsThenRulesAreSepara
2119
2117
expectedRuleName13 := "shared-TCP-4444-Internet"
2120
2118
expectedRuleName2 := "shared-TCP-8888-Internet"
2121
2119
2122
- sg := getTestSecurityGroup (az )
2120
+ getTestSecurityGroup (az )
2123
2121
2124
- sg , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
2122
+ _ , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
2125
2123
if err != nil {
2126
2124
t .Errorf ("Unexpected error adding svc1: %q" , err )
2127
2125
}
2128
2126
2129
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
2127
+ _ , err = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
2130
2128
if err != nil {
2131
2129
t .Errorf ("Unexpected error adding svc2: %q" , err )
2132
2130
}
2133
2131
2134
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc3 , to .StringPtr (svc3 .Spec .LoadBalancerIP ), true )
2132
+ sg , err : = az .reconcileSecurityGroup (testClusterName , & svc3 , to .StringPtr (svc3 .Spec .LoadBalancerIP ), true )
2135
2133
if err != nil {
2136
2134
t .Errorf ("Unexpected error adding svc3: %q" , err )
2137
2135
}
@@ -2214,14 +2212,14 @@ func TestIfServiceSpecifiesSharedRuleAndServiceIsDeletedThenTheServicesPortAndAd
2214
2212
2215
2213
expectedRuleName := "shared-TCP-80-Internet"
2216
2214
2217
- sg := getTestSecurityGroup (az )
2215
+ getTestSecurityGroup (az )
2218
2216
2219
- sg , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
2217
+ _ , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
2220
2218
if err != nil {
2221
2219
t .Errorf ("Unexpected error adding svc1: %q" , err )
2222
2220
}
2223
2221
2224
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
2222
+ sg , err : = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
2225
2223
if err != nil {
2226
2224
t .Errorf ("Unexpected error adding svc2: %q" , err )
2227
2225
}
@@ -2274,19 +2272,19 @@ func TestIfSomeServicesShareARuleAndOneIsDeletedItIsRemovedFromTheRightRule(t *t
2274
2272
expectedRuleName13 := "shared-TCP-4444-Internet"
2275
2273
expectedRuleName2 := "shared-TCP-8888-Internet"
2276
2274
2277
- sg := getTestSecurityGroup (az )
2275
+ getTestSecurityGroup (az )
2278
2276
2279
- sg , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
2277
+ _ , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
2280
2278
if err != nil {
2281
2279
t .Errorf ("Unexpected error adding svc1: %q" , err )
2282
2280
}
2283
2281
2284
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
2282
+ _ , err = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
2285
2283
if err != nil {
2286
2284
t .Errorf ("Unexpected error adding svc2: %q" , err )
2287
2285
}
2288
2286
2289
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc3 , to .StringPtr (svc3 .Spec .LoadBalancerIP ), true )
2287
+ sg , err : = az .reconcileSecurityGroup (testClusterName , & svc3 , to .StringPtr (svc3 .Spec .LoadBalancerIP ), true )
2290
2288
if err != nil {
2291
2289
t .Errorf ("Unexpected error adding svc3: %q" , err )
2292
2290
}
@@ -2381,26 +2379,26 @@ func TestIfServiceSpecifiesSharedRuleAndLastServiceIsDeletedThenRuleIsDeleted(t
2381
2379
expectedRuleName13 := "shared-TCP-4444-Internet"
2382
2380
expectedRuleName2 := "shared-TCP-8888-Internet"
2383
2381
2384
- sg := getTestSecurityGroup (az )
2382
+ getTestSecurityGroup (az )
2385
2383
2386
- sg , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
2384
+ _ , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
2387
2385
if err != nil {
2388
2386
t .Errorf ("Unexpected error adding svc1: %q" , err )
2389
2387
}
2390
2388
2391
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
2389
+ _ , err = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
2392
2390
if err != nil {
2393
2391
t .Errorf ("Unexpected error adding svc2: %q" , err )
2394
2392
}
2395
2393
2396
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc3 , to .StringPtr (svc3 .Spec .LoadBalancerIP ), true )
2394
+ sg , err : = az .reconcileSecurityGroup (testClusterName , & svc3 , to .StringPtr (svc3 .Spec .LoadBalancerIP ), true )
2397
2395
if err != nil {
2398
2396
t .Errorf ("Unexpected error adding svc3: %q" , err )
2399
2397
}
2400
2398
2401
2399
validateSecurityGroup (t , sg , svc1 , svc2 , svc3 )
2402
2400
2403
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), false )
2401
+ _ , err = az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), false )
2404
2402
if err != nil {
2405
2403
t .Errorf ("Unexpected error removing svc1: %q" , err )
2406
2404
}
@@ -2471,29 +2469,29 @@ func TestCanCombineSharedAndPrivateRulesInSameGroup(t *testing.T) {
2471
2469
expectedRuleName4 := az .getSecurityRuleName (& svc4 , v1.ServicePort {Port : 4444 , Protocol : v1 .ProtocolTCP }, "Internet" )
2472
2470
expectedRuleName5 := az .getSecurityRuleName (& svc5 , v1.ServicePort {Port : 8888 , Protocol : v1 .ProtocolTCP }, "Internet" )
2473
2471
2474
- sg := getTestSecurityGroup (az )
2472
+ getTestSecurityGroup (az )
2475
2473
2476
- sg , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
2474
+ _ , err := az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), true )
2477
2475
if err != nil {
2478
2476
t .Errorf ("Unexpected error adding svc1: %q" , err )
2479
2477
}
2480
2478
2481
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
2479
+ _ , err = az .reconcileSecurityGroup (testClusterName , & svc2 , to .StringPtr (svc2 .Spec .LoadBalancerIP ), true )
2482
2480
if err != nil {
2483
2481
t .Errorf ("Unexpected error adding svc2: %q" , err )
2484
2482
}
2485
2483
2486
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc3 , to .StringPtr (svc3 .Spec .LoadBalancerIP ), true )
2484
+ _ , err = az .reconcileSecurityGroup (testClusterName , & svc3 , to .StringPtr (svc3 .Spec .LoadBalancerIP ), true )
2487
2485
if err != nil {
2488
2486
t .Errorf ("Unexpected error adding svc3: %q" , err )
2489
2487
}
2490
2488
2491
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc4 , to .StringPtr (svc4 .Spec .LoadBalancerIP ), true )
2489
+ _ , err = az .reconcileSecurityGroup (testClusterName , & svc4 , to .StringPtr (svc4 .Spec .LoadBalancerIP ), true )
2492
2490
if err != nil {
2493
2491
t .Errorf ("Unexpected error adding svc4: %q" , err )
2494
2492
}
2495
2493
2496
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc5 , to .StringPtr (svc5 .Spec .LoadBalancerIP ), true )
2494
+ sg , err : = az .reconcileSecurityGroup (testClusterName , & svc5 , to .StringPtr (svc5 .Spec .LoadBalancerIP ), true )
2497
2495
if err != nil {
2498
2496
t .Errorf ("Unexpected error adding svc4: %q" , err )
2499
2497
}
@@ -2584,7 +2582,7 @@ func TestCanCombineSharedAndPrivateRulesInSameGroup(t *testing.T) {
2584
2582
}
2585
2583
}
2586
2584
2587
- sg , err = az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), false )
2585
+ _ , err = az .reconcileSecurityGroup (testClusterName , & svc1 , to .StringPtr (svc1 .Spec .LoadBalancerIP ), false )
2588
2586
if err != nil {
2589
2587
t .Errorf ("Unexpected error removing svc1: %q" , err )
2590
2588
}
0 commit comments