1212# - lb_announcer_node -- the speaker node of the most recent announce;
1313# - lb_capture_decision -- capture when probes failed, skip when one
1414# succeeded, unknown when none ran or none could.
15+ # - lb_probe_blocker -- the reasons a probe cannot be attempted at all,
16+ # decided from the Service row alone.
1517# - pod_filter_affected -- retain scheduled NotReady pods even without IPs,
1618# and only from whole rows.
1719# - pod_first_ready -- pick the healthy-pod baseline for one node out
@@ -227,10 +229,10 @@ EOF
227229
228230@test " lb_filter_services keeps only LoadBalancer rows that have an ingress IP" {
229231 rows=" $( printf ' %s\n' \
230- ' tenant|app|LoadBalancer|192.0.2.50|80|31000|Cluster' \
231- ' kube-system|kube-dns|ClusterIP||53||Cluster' \
232- ' tenant|pending|LoadBalancer||443|31443|Local' \
233- ' tenant|db|LoadBalancer|192.0.2.51|5432|31543|Local' ) "
232+ ' tenant|app|LoadBalancer|192.0.2.50|80|TCP| 31000|Cluster' \
233+ ' kube-system|kube-dns|ClusterIP||53|UDP| |Cluster' \
234+ ' tenant|pending|LoadBalancer||443|TCP| 31443|Local' \
235+ ' tenant|db|LoadBalancer|192.0.2.51|5432|TCP| 31543|Local' ) "
234236
235237 out=" $( printf ' %s\n' " $rows " | lb_filter_services) "
236238
@@ -249,10 +251,10 @@ EOF
249251 # behind still satisfies a filter that only looks at values: what remains of
250252 # `192.0.2.53` here is `192.0.2.5`, an address the cluster never had, and the
251253 # row carrying it would be probed and written up as a Service. The jsonpath
252- # emits a fixed seven fields per Service, so a shorter row is a fragment by
254+ # emits a fixed eight fields per Service, so a shorter row is a fragment by
253255 # construction rather than by guess.
254256 rows=" $( printf ' %s\n' \
255- ' tenant|app|LoadBalancer|192.0.2.50|80|31000|Cluster' \
257+ ' tenant|app|LoadBalancer|192.0.2.50|80|TCP| 31000|Cluster' \
256258 ' tenant|db|LoadBalancer|192.0.2.5' ) "
257259
258260 out=" $( printf ' %s\n' " $rows " | lb_filter_services) "
740742#!/bin/sh
741743case "$*" in
742744 *'get svc'*)
743- echo 'tenant|web|LoadBalancer|192.0.2.10|80|30080|Cluster'
745+ echo 'tenant|web|LoadBalancer|192.0.2.10|80|TCP| 30080|Cluster'
744746 exit 1 ;;
745747esac
746748exit 0
772774for a in "$@"; do
773775 case $a in
774776 pods) exit 0 ;;
775- svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|30080|Cluster'; exit 0 ;;
777+ svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|TCP| 30080|Cluster'; exit 0 ;;
776778 # Complete rows AND a bound's status: the read answered in part.
777779 endpointslices) echo '10.0.0.1|node-a|tenant-test|wedged|true'; exit 124 ;;
778780 esac
@@ -1315,7 +1317,7 @@ STUB
13151317for a in "$@"; do
13161318 case $a in
13171319 pods) echo 'tenant-test|wedged|10.0.0.1|node-a|False|Running||eol'; exit 0 ;;
1318- svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|30080|Cluster'; exit 0 ;;
1320+ svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|TCP| 30080|Cluster'; exit 0 ;;
13191321 endpointslices) echo '10.0.0.1|node-a|tenant-test|wedged|true'; exit 0 ;;
13201322 esac
13211323done
@@ -1365,7 +1367,7 @@ STUB
13651367for a in "$@"; do
13661368 case $a in
13671369 pods) echo 'tenant-test|wedged|10.0.0.1|node-a|False|Running||eol'; exit 0 ;;
1368- svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|30080|Cluster'; exit 0 ;;
1370+ svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|TCP| 30080|Cluster'; exit 0 ;;
13691371 endpointslices) echo '10.0.0.1|node-a|tenant-test|wedged|true'; exit 0 ;;
13701372 esac
13711373done
@@ -1460,7 +1462,7 @@ STUB
14601462for a in "$@"; do
14611463 case $a in
14621464 pods) exit 0 ;;
1463- svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|30080|Cluster'; exit 0 ;;
1465+ svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|TCP| 30080|Cluster'; exit 0 ;;
14641466 endpointslices) echo '10.0.0.1|node-a|tenant-test|wedged|true'; exit 0 ;;
14651467 esac
14661468done
@@ -1501,7 +1503,7 @@ STUB
15011503for a in "$@"; do
15021504 case $a in
15031505 pods) exit 0 ;;
1504- svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|30080|Cluster'; exit 0 ;;
1506+ svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|TCP| 30080|Cluster'; exit 0 ;;
15051507 endpointslices) echo 'Error from server (Forbidden): endpointslices is forbidden' >&2; exit 1 ;;
15061508 esac
15071509done
@@ -1535,7 +1537,7 @@ STUB
15351537for a in "$@"; do
15361538 case $a in
15371539 pods) exit 0 ;;
1538- svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|30080|Cluster'; exit 0 ;;
1540+ svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|TCP| 30080|Cluster'; exit 0 ;;
15391541 esac
15401542done
15411543# The endpointslice reads fall through to here: an empty list, answered.
@@ -1575,7 +1577,7 @@ STUB
15751577for a in "$@"; do
15761578 case $a in
15771579 pods) exit 0 ;;
1578- svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|30080|Cluster'; exit 0 ;;
1580+ svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|TCP| 30080|Cluster'; exit 0 ;;
15791581 endpointslices) echo '10.0.0.1|node-a|tenant-test|wedged|true'; exit 0 ;;
15801582 esac
15811583done
@@ -1631,7 +1633,7 @@ STUB
16311633for a in "$@"; do
16321634 case $a in
16331635 pods) exit 0 ;;
1634- svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|30080|Cluster'; exit 0 ;;
1636+ svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|TCP| 30080|Cluster'; exit 0 ;;
16351637 # No ready endpoint: the Service is enumerated, its backend is not.
16361638 endpointslices) exit 0 ;;
16371639 # The announcer, so the probe has somewhere to run from and the capture is
@@ -1686,7 +1688,7 @@ STUB
16861688for a in "$@"; do
16871689 case $a in
16881690 pods) exit 0 ;;
1689- svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|30080|Cluster'; exit 0 ;;
1691+ svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|TCP| 30080|Cluster'; exit 0 ;;
16901692 endpointslices) echo '10.0.0.1|node-a|tenant-test|wedged|true'; exit 0 ;;
16911693 esac
16921694done
@@ -1719,7 +1721,7 @@ STUB
17191721for a in "$@"; do
17201722 case $a in
17211723 pods) exit 0 ;;
1722- svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|30080|Cluster'; exit 0 ;;
1724+ svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|TCP| 30080|Cluster'; exit 0 ;;
17231725 endpointslices) echo '10.0.0.1|node-a|tenant-test|wedged|true'; exit 0 ;;
17241726 esac
17251727done
@@ -1767,7 +1769,7 @@ STUB
17671769for a in "$@"; do
17681770 case $a in
17691771 pods) exit 0 ;;
1770- svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|30080|Cluster'; exit 0 ;;
1772+ svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|TCP| 30080|Cluster'; exit 0 ;;
17711773 endpointslices) echo '10.0.0.1|node-a|tenant-test|wedged|true'; exit 0 ;;
17721774 esac
17731775done
@@ -1806,7 +1808,7 @@ STUB
18061808for a in "$@"; do
18071809 case $a in
18081810 pods) exit 0 ;;
1809- svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|30080|Cluster'; exit 0 ;;
1811+ svc) echo 'tenant|web|LoadBalancer|192.0.2.10|80|TCP| 30080|Cluster'; exit 0 ;;
18101812 esac
18111813done
18121814# Everything else answers empty: no endpointslices, so no endpoint node, and no
@@ -1836,7 +1838,7 @@ STUB
18361838for a in "$@"; do
18371839 case $a in
18381840 pods) exit 0 ;;
1839- svc) echo 'tenant|web|LoadBalancer|192.0.2.10||30080|Cluster'; exit 0 ;;
1841+ svc) echo 'tenant|web|LoadBalancer|192.0.2.10||TCP| 30080|Cluster'; exit 0 ;;
18401842 endpointslices) echo '10.0.0.1|node-a|tenant-test|wedged|true'; exit 0 ;;
18411843 esac
18421844done
@@ -1858,6 +1860,58 @@ STUB
18581860 rm -rf " $d "
18591861}
18601862
1863+ @test " lb_probe_blocker names each reason a probe cannot be attempted" {
1864+ [ -z " $( lb_probe_blocker node-a 443 TCP) " ]
1865+ # An absent protocol is the shape a cut read leaves; the Service object always
1866+ # carries one, so it must not become a fourth verdict of its own.
1867+ [ -z " $( lb_probe_blocker node-a 443 ' ' ) " ]
1868+ case " $( lb_probe_blocker ' ' 443 TCP) " in * " nowhere to probe from" * ) ;; * ) false ;; esac
1869+ case " $( lb_probe_blocker node-a 0 TCP) " in * " no port to probe" * ) ;; * ) false ;; esac
1870+ case " $( lb_probe_blocker node-a 500 UDP) " in * " TCP connect" * ) ;; * ) false ;; esac
1871+ case " $( lb_probe_blocker node-a 132 SCTP) " in * " TCP connect" * ) ;; * ) false ;; esac
1872+ }
1873+
1874+ @test " a UDP LoadBalancer is recorded as unprobed rather than unreachable" {
1875+ # The probe is a TCP connect, so against a UDP Service it fails for a reason
1876+ # that says nothing about the datapath. site-router's tunnel LB is 500/4500
1877+ # UDP and took the heavy capture on every failed run, with the conntrack dump
1878+ # in the artifact showing the probe as `tcp SYN_SENT dport=500 [UNREPLIED]`.
1879+ d=$( mktemp -d)
1880+ mkdir -p " $d /bin"
1881+ cat > " $d /bin/kubectl" << 'STUB '
1882+ #!/bin/sh
1883+ for a in "$@"; do
1884+ case $a in
1885+ pods) exit 0 ;;
1886+ svc) echo 'tenant|tunnel|LoadBalancer|192.0.2.10|500|UDP|30500|Local'; exit 0 ;;
1887+ endpointslices) echo '10.0.0.1|node-a|tenant-test|gw|true'; exit 0 ;;
1888+ esac
1889+ done
1890+ case "$*" in
1891+ *'app=kube-ovn-cni'*) echo 'cni-abc'; exit 0 ;;
1892+ esac
1893+ exit 0
1894+ STUB
1895+ chmod +x " $d /bin/kubectl"
1896+ PATH=" $d /bin:$PATH " timeout 60 " $SCRIPT " " $d /out" > " $d /log" 2>&1 || true
1897+ [ -f " $d /out/lb-tenant-tunnel.txt" ]
1898+ if grep -qi ' unreachable' " $d /out/lb-tenant-tunnel.txt" ; then
1899+ echo " a UDP LB was written up as unreachable on the strength of a TCP probe:"
1900+ cat " $d /out/lb-tenant-tunnel.txt"
1901+ exit 1
1902+ fi
1903+ if grep -q -- ' -- reachable, skipped' " $d /out/lb-tenant-tunnel.txt" ; then
1904+ echo " a UDP LB was recorded as reachable without a probe behind it:"
1905+ cat " $d /out/lb-tenant-tunnel.txt"
1906+ exit 1
1907+ fi
1908+ grep -q ' TCP connect' " $d /out/lb-tenant-tunnel.txt"
1909+ # The protocol belongs in the header too: a reader who sees "unprobed" has to
1910+ # be able to tell an unprobed UDP service from a broken lookup.
1911+ grep -q ' port=500/UDP' " $d /out/lb-tenant-tunnel.txt"
1912+ rm -rf " $d "
1913+ }
1914+
18611915@test " lb_capture_decision keeps failures visible when one probe could not run" {
18621916 # An unrun probe adds no reason to doubt the ones that failed, so the mix must
18631917 # not read as reachable. Collapsing it toward skip is what stamps the artifact
0 commit comments