Commit aba49a9
fix(NSC): harden Network Services Controller against panics, races, and sync errors
This combines five defensive fixes in the Network Services Controller:
1. shuffle(): check rand.Int error before dereferencing result
- rand.Int returns (nil, err) on failure, but the result was
dereferenced before the error check, causing a nil panic
2. NodePort healthcheck: add RWMutex to protect shared maps
- UpdateServicesInfo writes serviceInfoMap/endpointsInfoMap from
the sync goroutine while HTTP handlers read concurrently
3. setupIpvsFirewall: use continue instead of return in dual-stack loop
- return nil after clearing one IP family's chain skipped the
second family entirely on dual-stack nodes
4. setupMangleTableRule/cleanupMangleTableRule: add nil check for ParseIP
- net.ParseIP result was used without nil check, causing panic
on malformed IP strings from service annotations
5. synctypeIpvs: track errors across both sync steps for heartbeat
- err from syncIpvsServices was overwritten by syncHairpinIptablesRules,
masking IPVS failures from the health check system1 parent 01f8216 commit aba49a9
File tree
2 files changed
+21
-3
lines changed- pkg/controllers/proxy
2 files changed
+21
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
383 | 383 | | |
384 | 384 | | |
385 | 385 | | |
| 386 | + | |
386 | 387 | | |
387 | 388 | | |
388 | 389 | | |
| 390 | + | |
389 | 391 | | |
390 | 392 | | |
391 | 393 | | |
392 | 394 | | |
| 395 | + | |
393 | 396 | | |
394 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
395 | 401 | | |
396 | 402 | | |
397 | 403 | | |
| |||
482 | 488 | | |
483 | 489 | | |
484 | 490 | | |
485 | | - | |
| 491 | + | |
486 | 492 | | |
487 | | - | |
| 493 | + | |
488 | 494 | | |
489 | 495 | | |
490 | 496 | | |
| |||
981 | 987 | | |
982 | 988 | | |
983 | 989 | | |
984 | | - | |
985 | 990 | | |
986 | 991 | | |
| 992 | + | |
987 | 993 | | |
| 994 | + | |
988 | 995 | | |
989 | 996 | | |
990 | 997 | | |
| |||
1561 | 1568 | | |
1562 | 1569 | | |
1563 | 1570 | | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
1564 | 1574 | | |
1565 | 1575 | | |
1566 | 1576 | | |
| |||
1669 | 1679 | | |
1670 | 1680 | | |
1671 | 1681 | | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
1672 | 1685 | | |
1673 | 1686 | | |
1674 | 1687 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| |||
141 | 144 | | |
142 | 145 | | |
143 | 146 | | |
| 147 | + | |
144 | 148 | | |
| 149 | + | |
145 | 150 | | |
146 | 151 | | |
147 | 152 | | |
| |||
0 commit comments