Skip to content

Commit e272683

Browse files
feat: implement collector and analyser for network namespace connectivity (#1670)
* feat: implement collector and analyser for network namespace connectivity checks if two network namespaces can talk to each other on udp and tcp. its usage is as follows: ```yaml apiVersion: troubleshoot.sh/v1beta2 kind: SupportBundle metadata: name: test spec: hostCollectors: - networkNamespaceConnectivity: collectorName: check-network-connectivity fromCIDR: 10.0.0.0/24 toCIDR: 10.0.1.0/24 hostAnalyzers: - networkNamespaceConnectivity: collectorName: check-network-connectivity outcomes: - pass: message: "Communication between 10.0.0.0/24 and 10.0.1.0/24 is working" - fail: message: "Communication between 10.0.0.0/24 and 10.0.1.0/24 isn't working" ``` if this fails then you may need to enable `forwarding` with: ```bash sysctl -w net.ipv4.ip_forward=1 ``` if it still fails then you may need to configure firewalld to allow the traffic or simply disable it for sake of testing. * chore: rebuild schemas * chore: remove unused property * chore: disable namespaces for other platforms * chore: make sure we timeout temporary servers * feat: analyzer now supports multi-node collection * feat: check both udp and tcp even on failure check both protocols even if one fails. this pr commit also introduces a timeout that can be set by the user. * feat: add templating to the failure outcome allow users to dump the errors found during the analysis. * chore: addressing pr comments * feat: delete interface pair before namespace even though the interface pair is deleted everyttime we delete the namespace on my tests we better delete it before we delete the namespace. this comes out of a review comment where some people seem to still be able to see the interface pair even after the namespace is deleted. i.e. better safe than sorry. * chore: fix typo on comment
1 parent ea900a1 commit e272683

29 files changed

+2219
-50
lines changed

config/crds/troubleshoot.sh_analyzers.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,6 +2557,55 @@ spec:
25572557
required:
25582558
- outcomes
25592559
type: object
2560+
networkNamespaceConnectivity:
2561+
properties:
2562+
annotations:
2563+
additionalProperties:
2564+
type: string
2565+
type: object
2566+
checkName:
2567+
type: string
2568+
collectorName:
2569+
type: string
2570+
exclude:
2571+
type: BoolString
2572+
outcomes:
2573+
items:
2574+
properties:
2575+
fail:
2576+
properties:
2577+
message:
2578+
type: string
2579+
uri:
2580+
type: string
2581+
when:
2582+
type: string
2583+
type: object
2584+
pass:
2585+
properties:
2586+
message:
2587+
type: string
2588+
uri:
2589+
type: string
2590+
when:
2591+
type: string
2592+
type: object
2593+
warn:
2594+
properties:
2595+
message:
2596+
type: string
2597+
uri:
2598+
type: string
2599+
when:
2600+
type: string
2601+
type: object
2602+
type: object
2603+
type: array
2604+
strict:
2605+
type: BoolString
2606+
required:
2607+
- outcomes
2608+
type: object
25602609
subnetAvailable:
25612610
properties:
25622611
annotations:

config/crds/troubleshoot.sh_collectors.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17326,6 +17326,25 @@ spec:
1732617326
exclude:
1732717327
type: BoolString
1732817328
type: object
17329+
networkNamespaceConnectivity:
17330+
properties:
17331+
collectorName:
17332+
type: string
17333+
exclude:
17334+
type: BoolString
17335+
fromCIDR:
17336+
type: string
17337+
port:
17338+
type: integer
17339+
timeout:
17340+
type: string
17341+
toCIDR:
17342+
type: string
17343+
required:
17344+
- fromCIDR
17345+
- port
17346+
- toCIDR
17347+
type: object
1732917348
run:
1733017349
properties:
1733117350
args:

config/crds/troubleshoot.sh_hostcollectors.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,55 @@ spec:
797797
required:
798798
- outcomes
799799
type: object
800+
networkNamespaceConnectivity:
801+
properties:
802+
annotations:
803+
additionalProperties:
804+
type: string
805+
type: object
806+
checkName:
807+
type: string
808+
collectorName:
809+
type: string
810+
exclude:
811+
type: BoolString
812+
outcomes:
813+
items:
814+
properties:
815+
fail:
816+
properties:
817+
message:
818+
type: string
819+
uri:
820+
type: string
821+
when:
822+
type: string
823+
type: object
824+
pass:
825+
properties:
826+
message:
827+
type: string
828+
uri:
829+
type: string
830+
when:
831+
type: string
832+
type: object
833+
warn:
834+
properties:
835+
message:
836+
type: string
837+
uri:
838+
type: string
839+
when:
840+
type: string
841+
type: object
842+
type: object
843+
type: array
844+
strict:
845+
type: BoolString
846+
required:
847+
- outcomes
848+
type: object
800849
subnetAvailable:
801850
properties:
802851
annotations:
@@ -1603,6 +1652,25 @@ spec:
16031652
exclude:
16041653
type: BoolString
16051654
type: object
1655+
networkNamespaceConnectivity:
1656+
properties:
1657+
collectorName:
1658+
type: string
1659+
exclude:
1660+
type: BoolString
1661+
fromCIDR:
1662+
type: string
1663+
port:
1664+
type: integer
1665+
timeout:
1666+
type: string
1667+
toCIDR:
1668+
type: string
1669+
required:
1670+
- fromCIDR
1671+
- port
1672+
- toCIDR
1673+
type: object
16061674
run:
16071675
properties:
16081676
args:

config/crds/troubleshoot.sh_hostpreflights.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,55 @@ spec:
797797
required:
798798
- outcomes
799799
type: object
800+
networkNamespaceConnectivity:
801+
properties:
802+
annotations:
803+
additionalProperties:
804+
type: string
805+
type: object
806+
checkName:
807+
type: string
808+
collectorName:
809+
type: string
810+
exclude:
811+
type: BoolString
812+
outcomes:
813+
items:
814+
properties:
815+
fail:
816+
properties:
817+
message:
818+
type: string
819+
uri:
820+
type: string
821+
when:
822+
type: string
823+
type: object
824+
pass:
825+
properties:
826+
message:
827+
type: string
828+
uri:
829+
type: string
830+
when:
831+
type: string
832+
type: object
833+
warn:
834+
properties:
835+
message:
836+
type: string
837+
uri:
838+
type: string
839+
when:
840+
type: string
841+
type: object
842+
type: object
843+
type: array
844+
strict:
845+
type: BoolString
846+
required:
847+
- outcomes
848+
type: object
800849
subnetAvailable:
801850
properties:
802851
annotations:
@@ -1603,6 +1652,25 @@ spec:
16031652
exclude:
16041653
type: BoolString
16051654
type: object
1655+
networkNamespaceConnectivity:
1656+
properties:
1657+
collectorName:
1658+
type: string
1659+
exclude:
1660+
type: BoolString
1661+
fromCIDR:
1662+
type: string
1663+
port:
1664+
type: integer
1665+
timeout:
1666+
type: string
1667+
toCIDR:
1668+
type: string
1669+
required:
1670+
- fromCIDR
1671+
- port
1672+
- toCIDR
1673+
type: object
16061674
run:
16071675
properties:
16081676
args:

config/crds/troubleshoot.sh_supportbundles.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19444,6 +19444,55 @@ spec:
1944419444
required:
1944519445
- outcomes
1944619446
type: object
19447+
networkNamespaceConnectivity:
19448+
properties:
19449+
annotations:
19450+
additionalProperties:
19451+
type: string
19452+
type: object
19453+
checkName:
19454+
type: string
19455+
collectorName:
19456+
type: string
19457+
exclude:
19458+
type: BoolString
19459+
outcomes:
19460+
items:
19461+
properties:
19462+
fail:
19463+
properties:
19464+
message:
19465+
type: string
19466+
uri:
19467+
type: string
19468+
when:
19469+
type: string
19470+
type: object
19471+
pass:
19472+
properties:
19473+
message:
19474+
type: string
19475+
uri:
19476+
type: string
19477+
when:
19478+
type: string
19479+
type: object
19480+
warn:
19481+
properties:
19482+
message:
19483+
type: string
19484+
uri:
19485+
type: string
19486+
when:
19487+
type: string
19488+
type: object
19489+
type: object
19490+
type: array
19491+
strict:
19492+
type: BoolString
19493+
required:
19494+
- outcomes
19495+
type: object
1944719496
subnetAvailable:
1944819497
properties:
1944919498
annotations:
@@ -20250,6 +20299,25 @@ spec:
2025020299
exclude:
2025120300
type: BoolString
2025220301
type: object
20302+
networkNamespaceConnectivity:
20303+
properties:
20304+
collectorName:
20305+
type: string
20306+
exclude:
20307+
type: BoolString
20308+
fromCIDR:
20309+
type: string
20310+
port:
20311+
type: integer
20312+
timeout:
20313+
type: string
20314+
toCIDR:
20315+
type: string
20316+
required:
20317+
- fromCIDR
20318+
- port
20319+
- toCIDR
20320+
type: object
2025320321
run:
2025420322
properties:
2025520323
args:

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ require (
3838
github.com/spf13/viper v1.19.0
3939
github.com/stretchr/testify v1.9.0
4040
github.com/tj/go-spin v1.1.0
41+
github.com/vishvananda/netlink v1.2.1-beta.2
42+
github.com/vishvananda/netns v0.0.4
4143
github.com/vmware-tanzu/velero v1.14.1
4244
go.opentelemetry.io/otel v1.31.0
4345
go.opentelemetry.io/otel/sdk v1.31.0
@@ -113,6 +115,7 @@ require (
113115
github.com/shopspring/decimal v1.4.0 // indirect
114116
github.com/sirupsen/logrus v1.9.3 // indirect
115117
github.com/sourcegraph/conc v0.3.0 // indirect
118+
github.com/stretchr/objx v0.5.2 // indirect
116119
github.com/sylabs/sif/v2 v2.18.0 // indirect
117120
github.com/tchap/go-patricia/v2 v2.3.1 // indirect
118121
github.com/vladimirvivien/gexe v0.3.0 // indirect

go.sum

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,11 @@ github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
885885
github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
886886
github.com/vbatts/tar-split v0.11.5 h1:3bHCTIheBm1qFTcgh9oPu+nNBtX+XJIupG/vacinCts=
887887
github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk=
888+
github.com/vishvananda/netlink v1.2.1-beta.2 h1:Llsql0lnQEbHj0I1OuKyp8otXp0r3q0mPkuhwHfStVs=
889+
github.com/vishvananda/netlink v1.2.1-beta.2/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
890+
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
891+
github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8=
892+
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
888893
github.com/vladimirvivien/gexe v0.3.0 h1:4xwiOwGrDob5OMR6E92B9olDXYDglXdHhzR1ggYtWJM=
889894
github.com/vladimirvivien/gexe v0.3.0/go.mod h1:fp7cy60ON1xjhtEI/+bfSEIXX35qgmI+iRYlGOqbBFM=
890895
github.com/vmware-tanzu/velero v1.14.1 h1:HYj73scn7ZqtfTanjW/X4W0Hn3w/qcfoRbrHCWM52iI=
@@ -1131,6 +1136,7 @@ golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7w
11311136
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
11321137
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
11331138
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1139+
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
11341140
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
11351141
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
11361142
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -1139,6 +1145,7 @@ golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7w
11391145
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
11401146
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
11411147
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
1148+
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
11421149
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
11431150
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
11441151
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

pkg/analyze/host_analyzer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ func GetHostAnalyzer(analyzer *troubleshootv1beta2.HostAnalyze) (HostAnalyzer, b
6161
return &AnalyzeHostKernelConfigs{analyzer.KernelConfigs}, true
6262
case analyzer.JsonCompare != nil:
6363
return &AnalyzeHostJsonCompare{analyzer.JsonCompare}, true
64+
case analyzer.NetworkNamespaceConnectivity != nil:
65+
return &AnalyzeHostNetworkNamespaceConnectivity{analyzer.NetworkNamespaceConnectivity}, true
6466
default:
6567
return nil, false
6668
}

0 commit comments

Comments
 (0)