diff --git a/cmd/preflight/cli/stdout_results.go b/cmd/preflight/cli/stdout_results.go index 028c3a83..66b1f59b 100644 --- a/cmd/preflight/cli/stdout_results.go +++ b/cmd/preflight/cli/stdout_results.go @@ -19,6 +19,7 @@ func showStdoutResults(format string, preflightName string, analyzeResults []*an } func showStdoutResultsHuman(preflightName string, analyzeResults []*analyzerunner.AnalyzeResult) error { + fmt.Println("") var failed bool for _, analyzeResult := range analyzeResults { testResultfailed := outputResult(analyzeResult) diff --git a/examples/preflight/host-block-devices.yaml b/examples/preflight/host/block-devices.yaml similarity index 100% rename from examples/preflight/host-block-devices.yaml rename to examples/preflight/host/block-devices.yaml diff --git a/examples/preflight/host-cpu.yaml b/examples/preflight/host/cpu.yaml similarity index 100% rename from examples/preflight/host-cpu.yaml rename to examples/preflight/host/cpu.yaml diff --git a/examples/preflight/host-disk-usage.yaml b/examples/preflight/host/disk-usage.yaml similarity index 100% rename from examples/preflight/host-disk-usage.yaml rename to examples/preflight/host/disk-usage.yaml diff --git a/examples/preflight/host-http-load-balancer.yaml b/examples/preflight/host/http-load-balancer.yaml similarity index 100% rename from examples/preflight/host-http-load-balancer.yaml rename to examples/preflight/host/http-load-balancer.yaml diff --git a/examples/preflight/host-http.yaml b/examples/preflight/host/http.yaml similarity index 100% rename from examples/preflight/host-http.yaml rename to examples/preflight/host/http.yaml diff --git a/examples/preflight/host-ipv4-interfaces.yaml b/examples/preflight/host/ipv4-interfaces.yaml similarity index 100% rename from examples/preflight/host-ipv4-interfaces.yaml rename to examples/preflight/host/ipv4-interfaces.yaml diff --git a/examples/preflight/host-memory.yaml b/examples/preflight/host/memory.yaml similarity index 100% rename from examples/preflight/host-memory.yaml rename to examples/preflight/host/memory.yaml diff --git a/examples/preflight/host-ntp.yaml b/examples/preflight/host/ntp.yaml similarity index 100% rename from examples/preflight/host-ntp.yaml rename to examples/preflight/host/ntp.yaml diff --git a/examples/preflight/host/sample.yaml b/examples/preflight/host/sample.yaml new file mode 100644 index 00000000..98696f5c --- /dev/null +++ b/examples/preflight/host/sample.yaml @@ -0,0 +1,191 @@ +apiVersion: troubleshoot.sh/v1beta2 +kind: HostPreflight +metadata: + name: example +spec: + collectors: + - blockDevices: {} + - cpu: {} + - diskUsage: + collectorName: ephemeral + path: /var/lib/kubelet + - httpLoadBalancer: + collectorName: httploadbalancer + port: 80 + address: http://app.corporate.internal + timeout: 10s + - http: + collectorName: registry + get: + url: https://registry.replicated.com + - ipv4Interfaces: {} + - memory: {} + - time: {} + - tcpConnect: + collectorName: weave host 1 + address: 10.128.0.2:6783 + timeout: 2s + - tcpLoadBalancer: + collectorName: LB1 + address: 10.128.0.20:6443 + port: 6443 + timeout: 5000ms + - tcpPortStatus: + collectorName: k8s + port: 6443 + analyzers: + - blockDevices: + outcomes: + - pass: + when: ".* == 1" + message: One available block device + - pass: + when: ".* > 1" + message: Multiple available block devices + - fail: + message: No available block devices + - cpu: + outcomes: + - fail: + when: "< 4" + message: This server has less than 4 CPU cores, and we require 8, but recommend 16 + - warn: + when: "< 16" + message: This server has at least 4 CPU cores, but we recommend 16 or more + - pass: + message: This server has sufficient CPU cores + - diskUsage: + collectorName: ephemeral + outcomes: + - fail: + when: "total < 20Gi" + message: /var/lib/kubelet has less than 20Gi of total space + - fail: + when: "available < 10Gi" + message: /var/lib/kubelet has less than 10Gi of disk space available + - fail: + when: "used/total > 70%" + message: /var/lib/kubelet is more than 70% full + - pass: + message: /var/lib/kubelet has sufficient disk space available + - httpLoadBalancer: + collectorName: httploadbalancer + outcomes: + - fail: + when: "connection-refused" + message: Connection to port 80 via load balancer was refused. + - fail: + when: "address-in-use" + message: Another process was already listening on port 80. + - fail: + when: "connection-timeout" + message: Timed out connecting to port 80 via load balancer. Check your firewall. + - fail: + when: "bind-permission-denied" + message: Bind permission denied. Try running as root. + - fail: + when: "error" + message: Failed to connect to port 80 via load balancer. + - pass: + when: "connected" + message: Successfully connected to port 80 via load balancer. + - http: + collectorName: registry + outcomes: + - fail: + when: "error" + message: Error connecting to registry + - pass: + when: "statusCode == 404" + message: Connected to registry + - fail: + message: "Unexpected response" + - ipv4Interfaces: + outcomes: + - fail: + when: "count == 0" + message: No IPv4 interfaces detected + - warn: + when: "count >= 2" + message: Multiple IPv4 interfaces detected + - pass: + when: "count == 1" + message: IPv4 interface detected + - memory: + outcomes: + - fail: + when: "< 8Gi" + message: At least 8Gi of memory is required + - warn: + when: "< 32Gi" + message: At least 32Gi of memory is recommended + - pass: + message: The system has as sufficient memory + - time: + outcomes: + - fail: + when: "ntp == unsynchronized+inactive" + message: System clock not synchronized + - warn: + when: "ntp == unsynchronized+active" + message: System clock not yet synchronized + - warn: + when: "ntp == synchronized+inactive" + message: NTP not active + - pass: + when: "ntp == synchronized+active" + message: System clock is synchronized + - tcpConnect: + collectorName: weave host 1 + outcomes: + - fail: + when: "connection-refused" + message: Connection to weave on host 1 was refused + - fail: + when: "connection-timeout" + message: Timed out connecting to weave on host 1 + - fail: + when: "error" + message: Unexpected error connecting to weave on host 1 + - pass: + when: "connected" + message: Successfully connected to weave on host 1 + - tcpLoadBalancer: + collectorName: LB1 + outcomes: + - fail: + when: "connection-timeout" + message: The TCP Load Balancer is not forwarding traffic to this server. + - fail: + when: "address-in-use" + message: The local port is not available to validate the Load Balancer configuration. + - pass: + when: "connected" + message: The specified TCP Load Balancer appears to be properly forwarding traffic to this server. + - tcpPortStatus: + collectorName: k8s + outcomes: + - fail: + when: "connection-refused" + message: Connection to port 7443 was refused. + - fail: + when: "address-in-use" + message: Another process was already listening on port 7443. + - fail: + when: "connection-timeout" + message: Timed out connecting to port 7443. Check your firewall. + - fail: + when: "error" + message: Unexpected port status + - pass: + when: "connected" + message: Port 7443 is open + - warn: + message: Unexpected port status + - time: + outcomes: + - pass: + when: "timezone == UTC" + message: Timezone is UTC + - fail: + message: Timezone is not UTC diff --git a/examples/preflight/host-tcp-connect.yaml b/examples/preflight/host/tcp-connect.yaml similarity index 100% rename from examples/preflight/host-tcp-connect.yaml rename to examples/preflight/host/tcp-connect.yaml diff --git a/examples/preflight/host-tcp-load-balancer.yaml b/examples/preflight/host/tcp-load-balancer.yaml similarity index 100% rename from examples/preflight/host-tcp-load-balancer.yaml rename to examples/preflight/host/tcp-load-balancer.yaml diff --git a/examples/preflight/host-port.yaml b/examples/preflight/host/tcp-port.yaml similarity index 100% rename from examples/preflight/host-port.yaml rename to examples/preflight/host/tcp-port.yaml diff --git a/examples/preflight/host-timezone.yaml b/examples/preflight/host/timezone.yaml similarity index 100% rename from examples/preflight/host-timezone.yaml rename to examples/preflight/host/timezone.yaml diff --git a/examples/preflight/sample-host-preflight.yaml b/examples/preflight/sample-host-preflight.yaml deleted file mode 100644 index 659a3533..00000000 --- a/examples/preflight/sample-host-preflight.yaml +++ /dev/null @@ -1,51 +0,0 @@ -apiVersion: troubleshoot.sh/v1beta2 -kind: HostPreflight -metadata: - name: example -spec: - collectors: - - tcpLoadBalancer: - collectorName: LB1 - address: 10.1.1.1 - port: 6443 - timeout: 5000ms - - diskUsage: - collectorName: ephemeral - path: /var/lib/kubelet - analyzers: - - cpu: - outcomes: - - fail: - when: "< 4" - message: This server has less than 4 CPU cores, and we require 8, but recommend 16 - - warn: - when: "< 16" - message: This server has at least 4 CPU cores, but we recommend 16 or more - - pass: - message: This server has sufficient CPU cores - - tcpLoadBalancer: - collectorName: LB1 - outcomes: - - fail: - when: "connection-timeout" - message: The TCP Load Balancer is not forwarding traffic to this server. - - fail: - when: "address-in-use" - message: The local port is not available to validate the Load Balancer configuration. - - pass: - when: "connected" - message: The specified TCP Load Balancer appears to be properly forwarding traffic to this server. - - diskUsage: - collectorName: ephemeral - outcomes: - - fail: - when: "total < 20Gi" - message: /var/lib/kubelet has less than 20Gi of total space - - fail: - when: "available < 10Gi" - message: /var/lib/kubelet has less than 10Gi of disk space available - - fail: - when: "used/total > 70%" - message: /var/lib/kubelet is more than 70% full - - pass: - message: /var/lib/kubelet has sufficient disk space available diff --git a/pkg/collect/host_network.go b/pkg/collect/host_network.go index 2bb9b84b..8abd1702 100644 --- a/pkg/collect/host_network.go +++ b/pkg/collect/host_network.go @@ -133,7 +133,6 @@ func verifyConnectionToServer(conn net.Conn, requestToken []byte, responseToken _, err := conn.Write(requestToken) if err != nil { - fmt.Printf("Client failed to write: %v", err) return false } @@ -145,7 +144,6 @@ func verifyConnectionToServer(conn net.Conn, requestToken []byte, responseToken buf := make([]byte, 1024) _, err = conn.Read(buf) if err != nil { - fmt.Printf("Client failed to read: %v", err) return false }