@@ -98,6 +98,7 @@ func (suite *ServiceSuite) SetupTest() {
9898 false ,
9999 false ,
100100 false ,
101+ false ,
101102 )
102103 suite .NoError (err , "should initialize service source" )
103104}
@@ -181,6 +182,7 @@ func testServiceSourceNewServiceSource(t *testing.T) {
181182 false ,
182183 false ,
183184 false ,
185+ false ,
184186 )
185187
186188 if ti .expectError {
@@ -1165,6 +1167,7 @@ func testServiceSourceEndpoints(t *testing.T) {
11651167 tc .resolveLoadBalancerHostname ,
11661168 false ,
11671169 false ,
1170+ false ,
11681171 )
11691172
11701173 require .NoError (t , err )
@@ -1381,6 +1384,7 @@ func testMultipleServicesEndpoints(t *testing.T) {
13811384 false ,
13821385 false ,
13831386 false ,
1387+ false ,
13841388 )
13851389 require .NoError (t , err )
13861390
@@ -1686,6 +1690,7 @@ func TestClusterIpServices(t *testing.T) {
16861690 false ,
16871691 false ,
16881692 false ,
1693+ false ,
16891694 )
16901695 require .NoError (t , err )
16911696
@@ -1718,6 +1723,7 @@ func TestServiceSourceNodePortServices(t *testing.T) {
17181723 fqdnTemplate string
17191724 ignoreHostnameAnnotation bool
17201725 exposeInternalIPv6 bool
1726+ ignoreUnscheduledNodes bool
17211727 labels map [string ]string
17221728 annotations map [string ]string
17231729 lbs []string
@@ -2383,6 +2389,55 @@ func TestServiceSourceNodePortServices(t *testing.T) {
23832389 },
23842390 }},
23852391 },
2392+ {
2393+ title : "NodePort services ignore unschedulable node" ,
2394+ ignoreUnscheduledNodes : true ,
2395+ svcNamespace : "testing" ,
2396+ svcName : "foo" ,
2397+ svcType : v1 .ServiceTypeNodePort ,
2398+ svcTrafficPolicy : v1 .ServiceExternalTrafficPolicyTypeCluster ,
2399+ labels : map [string ]string {},
2400+ annotations : map [string ]string {
2401+ annotations .HostnameKey : "foo.example.org." ,
2402+ annotations .AccessKey : "public" ,
2403+ },
2404+ expected : []* endpoint.Endpoint {
2405+ {DNSName : "_foo._tcp.foo.example.org" , Targets : endpoint.Targets {"0 50 30192 foo.example.org." }, RecordType : endpoint .RecordTypeSRV },
2406+ {DNSName : "foo.example.org" , Targets : endpoint.Targets {"54.10.11.2" }, RecordType : endpoint .RecordTypeA },
2407+ {DNSName : "foo.example.org" , Targets : endpoint.Targets {"2001:DB8::3" }, RecordType : endpoint .RecordTypeAAAA },
2408+ },
2409+ nodes : []* v1.Node {{
2410+ ObjectMeta : metav1.ObjectMeta {
2411+ Name : "node1" ,
2412+ },
2413+ Spec : v1.NodeSpec {
2414+ Unschedulable : true ,
2415+ },
2416+ Status : v1.NodeStatus {
2417+ Addresses : []v1.NodeAddress {
2418+ {Type : v1 .NodeExternalIP , Address : "54.10.11.1" },
2419+ {Type : v1 .NodeInternalIP , Address : "10.0.1.1" },
2420+ {Type : v1 .NodeExternalIP , Address : "2001:DB8::1" },
2421+ {Type : v1 .NodeInternalIP , Address : "2001:DB8::2" },
2422+ },
2423+ },
2424+ }, {
2425+ ObjectMeta : metav1.ObjectMeta {
2426+ Name : "node2" ,
2427+ },
2428+ Spec : v1.NodeSpec {
2429+ Unschedulable : false ,
2430+ },
2431+ Status : v1.NodeStatus {
2432+ Addresses : []v1.NodeAddress {
2433+ {Type : v1 .NodeExternalIP , Address : "54.10.11.2" },
2434+ {Type : v1 .NodeInternalIP , Address : "10.0.1.2" },
2435+ {Type : v1 .NodeExternalIP , Address : "2001:DB8::3" },
2436+ {Type : v1 .NodeInternalIP , Address : "2001:DB8::4" },
2437+ },
2438+ },
2439+ }},
2440+ },
23862441 } {
23872442
23882443 t .Run (tc .title , func (t * testing.T ) {
@@ -2463,6 +2518,7 @@ func TestServiceSourceNodePortServices(t *testing.T) {
24632518 false ,
24642519 false ,
24652520 tc .exposeInternalIPv6 ,
2521+ tc .ignoreUnscheduledNodes ,
24662522 )
24672523 require .NoError (t , err )
24682524
@@ -3371,6 +3427,7 @@ func TestHeadlessServices(t *testing.T) {
33713427 false ,
33723428 false ,
33733429 tc .exposeInternalIPv6 ,
3430+ false ,
33743431 )
33753432 require .NoError (t , err )
33763433
@@ -3507,6 +3564,7 @@ func TestMultipleServicesPointingToSameLoadBalancer(t *testing.T) {
35073564 false ,
35083565 false ,
35093566 false ,
3567+ true ,
35103568 )
35113569 require .NoError (t , err )
35123570 assert .NotNil (t , src )
@@ -3873,6 +3931,7 @@ func TestMultipleHeadlessServicesPointingToPodsOnTheSameNode(t *testing.T) {
38733931 false ,
38743932 false ,
38753933 false ,
3934+ true ,
38763935 )
38773936 require .NoError (t , err )
38783937 assert .NotNil (t , src )
@@ -4331,6 +4390,7 @@ func TestHeadlessServicesHostIP(t *testing.T) {
43314390 false ,
43324391 false ,
43334392 false ,
4393+ true ,
43344394 )
43354395 require .NoError (t , err )
43364396
@@ -4541,6 +4601,7 @@ func TestExternalServices(t *testing.T) {
45414601 false ,
45424602 false ,
45434603 false ,
4604+ true ,
45444605 )
45454606 require .NoError (t , err )
45464607
@@ -4603,6 +4664,7 @@ func BenchmarkServiceEndpoints(b *testing.B) {
46034664 false ,
46044665 false ,
46054666 false ,
4667+ true ,
46064668 )
46074669 require .NoError (b , err )
46084670
@@ -4702,6 +4764,7 @@ func TestNewServiceSourceInformersEnabled(t *testing.T) {
47024764 false ,
47034765 false ,
47044766 false ,
4767+ false ,
47054768 )
47064769 require .NoError (t , err )
47074770 svcSrc , ok := svc .(* serviceSource )
@@ -4733,6 +4796,7 @@ func TestNewServiceSourceWithServiceTypeFilters_Unsupported(t *testing.T) {
47334796 false ,
47344797 false ,
47354798 false ,
4799+ false ,
47364800 )
47374801 require .Errorf (t , err , "unsupported service type filter: \" UnknownType\" . Supported types are: [\" ClusterIP\" \" NodePort\" \" LoadBalancer\" \" ExternalName\" ]" )
47384802 require .Nil (t , svc , "ServiceSource should be nil when an unsupported service type is provided" )
@@ -4912,6 +4976,7 @@ func TestEndpointSlicesIndexer(t *testing.T) {
49124976 false ,
49134977 false ,
49144978 false ,
4979+ true ,
49154980 )
49164981 require .NoError (t , err )
49174982 ss , ok := src .(* serviceSource )
@@ -4999,6 +5064,7 @@ func TestPodTransformerInServiceSource(t *testing.T) {
49995064 false ,
50005065 false ,
50015066 false ,
5067+ false ,
50025068 )
50035069 require .NoError (t , err )
50045070 ss , ok := src .(* serviceSource )
0 commit comments