mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
The IPAM pool analyzer checks that utilization of the pod IP subnet is
less than 85%. For example, if using 10.32.0.0/12, this analyzer will
warn if 3,482 IPs are currently allocated to pods.
The pending allocation analyzer checks that the IPAM status in the
report has no items for the PendingAllocates field. This indicates the
IPAM service is not ready according to the code in the weave status
template
e3712152d2/prog/weaver/http.go (L186).
The weave connections analyzer checks that all connections to remote
peers are in the established state. The state will be "pending" if UDP
is blocked between nodes and will be "failed" if the weave pod on the
remote node is in a crash loop. To force a pending state for testing,
run the commands `iptables -A INPUT -p udp --dport 6784 -j REJECT` and
`iptables -A INPUT -p udp --dport 6783 -j REJECT` on a peer.
The weave connections analyzer also checks that all connections are
using the fastdp protocol. A commopn issue seen in the field on
CentOS/RHEL 7 is that some sides of a connection are using fastdp and
other sides have fallen back to sleeve. Set the WEAVE_NO_FASTDP env var
on the weave daemonset to "true" to test this analyzer.
188 lines
3.5 KiB
Go
188 lines
3.5 KiB
Go
package analyzer
|
|
|
|
import (
|
|
"testing"
|
|
|
|
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestWeaveReport(t *testing.T) {
|
|
var tests = []struct {
|
|
name string
|
|
report string
|
|
expect []*AnalyzeResult
|
|
}{
|
|
{
|
|
name: "sufficient IPs",
|
|
expect: []*AnalyzeResult{
|
|
{
|
|
Title: "Weave Report",
|
|
IsPass: true,
|
|
Message: "No issues detected in weave report",
|
|
},
|
|
},
|
|
report: `
|
|
{
|
|
"Router": {
|
|
"NickName": "areed-aka-k8ms"
|
|
},
|
|
"IPAM": {
|
|
"RangeNumIPs": 4096,
|
|
"ActiveIPs": 21,
|
|
"PendingAllocates": null
|
|
}
|
|
}`,
|
|
},
|
|
{
|
|
name: "insufficient IPs",
|
|
expect: []*AnalyzeResult{
|
|
{
|
|
Title: "Available Pod IPs",
|
|
IsWarn: true,
|
|
Message: "3900 of 4096 total available IPs have been assigned",
|
|
},
|
|
},
|
|
report: `
|
|
{
|
|
"Router": {
|
|
"NickName": "areed-aka-k8ms"
|
|
},
|
|
"IPAM": {
|
|
"RangeNumIPs": 4096,
|
|
"ActiveIPs": 3900,
|
|
"PendingAllocates": null
|
|
}
|
|
}`,
|
|
},
|
|
{
|
|
name: "IPs pending allocation",
|
|
expect: []*AnalyzeResult{
|
|
{
|
|
Title: "Pending IP Allocation",
|
|
IsWarn: true,
|
|
Message: "Waiting for IPs to become available",
|
|
},
|
|
},
|
|
report: `
|
|
{
|
|
"Router": {
|
|
"NickName": "areed-aka-k8ms"
|
|
},
|
|
"IPAM": {
|
|
"RangeNumIPs": 4096,
|
|
"ActiveIPs": 21,
|
|
"PendingAllocates": ["10.32.1.15"]
|
|
}
|
|
}`,
|
|
},
|
|
{
|
|
name: "remote connections established",
|
|
expect: []*AnalyzeResult{
|
|
{
|
|
Title: "Weave Report",
|
|
IsPass: true,
|
|
Message: "No issues detected in weave report",
|
|
},
|
|
},
|
|
report: `
|
|
{
|
|
"Router": {
|
|
"NickName": "areed-aka-k8ms",
|
|
"Connections": [
|
|
{
|
|
"State": "failed",
|
|
"Info": "cannot connect to ourself, retry: never",
|
|
"Attrs": {
|
|
"name": "fastdp"
|
|
}
|
|
},
|
|
{
|
|
"State": "established",
|
|
"Info": "encrypted fastdp 1a:5b:a9:53:2b:11(areed-aka-kkz0)",
|
|
"Attrs": {
|
|
"name": "fastdp"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}`,
|
|
},
|
|
{
|
|
name: "pending connection",
|
|
expect: []*AnalyzeResult{
|
|
{
|
|
Title: "Weave Inter-Node Connections",
|
|
IsWarn: true,
|
|
Message: "Connection from areed-aka-k8ms to areed-aka-kkz0 is pending",
|
|
},
|
|
},
|
|
report: `
|
|
{
|
|
"Router": {
|
|
"NickName": "areed-aka-k8ms",
|
|
"Connections": [
|
|
{
|
|
"State": "pending",
|
|
"Info": "encrypted fastdp 1a:5b:a9:53:2b:11(areed-aka-kkz0)",
|
|
"Attrs": {
|
|
"name": "fastdp"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}`,
|
|
},
|
|
{
|
|
name: "sleeve connection",
|
|
expect: []*AnalyzeResult{
|
|
{
|
|
Title: "Weave Inter-Node Connections",
|
|
IsWarn: true,
|
|
Message: `Connection from areed-aka-k8ms to areed-aka-kkz0 protocol is "sleeve", not fastdp`,
|
|
},
|
|
},
|
|
report: `
|
|
{
|
|
"Router": {
|
|
"NickName": "areed-aka-k8ms",
|
|
"Connections": [
|
|
{
|
|
"State": "established",
|
|
"Info": "encrypted sleeve 1a:5b:a9:53:2b:11(areed-aka-kkz0)",
|
|
"Attrs": {
|
|
"name": "sleeve"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}`,
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
var findFiles = func(glob string) (map[string][]byte, error) {
|
|
return map[string][]byte{
|
|
"report1": []byte(test.report),
|
|
}, nil
|
|
}
|
|
analyzer := &troubleshootv1beta2.WeaveReportAnalyze{}
|
|
results, err := analyzeWeaveReport(analyzer, findFiles)
|
|
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, test.expect, results)
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestParseWeaveConnectionInfoHostname(t *testing.T) {
|
|
info := "encrypted fastdp 1a:5b:a9:53:2b:11(areed-aka-kkz0)"
|
|
got := parseWeaveConnectionInfoHostname(info)
|
|
|
|
expect := "areed-aka-kkz0"
|
|
|
|
assert.Equal(t, expect, got)
|
|
|
|
}
|