Drop the fatal flag now that every failed check is fatal

This commit is contained in:
flamingcow
2026-08-04 13:33:08 -07:00
parent 39c27166dc
commit f5a6420cfa
3 changed files with 8 additions and 33 deletions
+6 -23
View File
@@ -126,7 +126,6 @@ func clearFlowRules(fd int, ifname string) checkResult {
locs, _, err := allRuleLocations(fd, ifname)
if err != nil {
res.err = err
res.fatal = true
return res
}
n := 0
@@ -136,7 +135,6 @@ func clearFlowRules(fd int, ifname string) checkResult {
}
if err := deleteRule(fd, ifname, loc); err != nil {
res.err = fmt.Errorf("deleting rule %d: %w", loc, err)
res.fatal = true
return res
}
n++
@@ -151,25 +149,21 @@ func checkFlowRules(fd int, ifname string, ethertypes []uint16) checkResult {
rings, err := rxRings(fd, ifname)
if err != nil {
res.err = err
res.fatal = true
return res
}
if uint64(len(ethertypes)) > rings {
res.err = fmt.Errorf("%d streams needs %d rx rings, only %d available",
len(ethertypes), len(ethertypes), rings)
res.fatal = true
return res
}
locs, capacity, err := allRuleLocations(fd, ifname)
if err != nil {
res.err = err
res.fatal = true
return res
}
if capacity < uint32(len(ethertypes)) {
res.err = fmt.Errorf("filter capacity %d is below %d streams", capacity, len(ethertypes))
res.fatal = true
return res
}
taken := make(map[uint32]bool, len(locs))
@@ -185,7 +179,6 @@ func checkFlowRules(fd int, ifname string, ethertypes []uint16) checkResult {
if err := insertEtherRule(fd, ifname, et, uint64(i), next); err != nil {
res.err = fmt.Errorf("steering ethertype 0x%04x to queue %d at location %d: %w",
et, i, next, err)
res.fatal = true
return res
}
taken[next] = true
@@ -258,7 +251,6 @@ type checkResult struct {
item string
state string
fixed bool
fatal bool
err error
}
@@ -285,18 +277,18 @@ func (r checkResult) detail() string {
func reportChecks(title string, results []checkResult) error {
var rows [][]string
var fatal []string
var failed []string
for _, r := range results {
rows = append(rows, []string{r.item, r.status(), r.detail()})
if r.fatal {
fatal = append(fatal, r.item)
if r.err != nil {
failed = append(failed, r.item)
}
}
fmt.Println(renderBox(title,
[]string{"CHECK", "STATUS", "DETAIL"},
[]bool{false, false, false}, rows))
if len(fatal) > 0 {
return fmt.Errorf("cannot test with %s in this state", strings.Join(fatal, ", "))
if len(failed) > 0 {
return fmt.Errorf("cannot test with %s in this state", strings.Join(failed, ", "))
}
return nil
}
@@ -462,7 +454,6 @@ func checkGovernor(want string) checkResult {
paths, err := filepath.Glob("/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor")
if err != nil || len(paths) == 0 {
res.err = fmt.Errorf("no cpufreq governors found")
res.fatal = true
return res
}
var wrong []string
@@ -471,7 +462,6 @@ func checkGovernor(want string) checkResult {
b, err := os.ReadFile(p)
if err != nil {
res.err = err
res.fatal = true
return res
}
got := strings.TrimSpace(string(b))
@@ -492,7 +482,6 @@ func checkGovernor(want string) checkResult {
if err := os.WriteFile(p, []byte(want), 0o644); err != nil {
res.err = err
res.state = fmt.Sprintf("could not set %s", p)
res.fatal = true
return res
}
}
@@ -509,7 +498,6 @@ func checkLinkUp(fd int, ifname string) checkResult {
uintptr(unix.SIOCGIFFLAGS), uintptr(unsafe.Pointer(&ifr)))
if errno != 0 {
res.err = errno
res.fatal = true
return res
}
if ifr.flags&unix.IFF_UP != 0 {
@@ -522,7 +510,6 @@ func checkLinkUp(fd int, ifname string) checkResult {
if errno != 0 {
res.err = errno
res.state = "could not set IFF_UP"
res.fatal = true
return res
}
res.fixed = true
@@ -535,7 +522,6 @@ func checkCoalesce(fd int, ifname string, rxUsecs, txUsecs uint32) checkResult {
ec, err := getCoalesce(fd, ifname)
if err != nil {
res.err = err
res.fatal = true
return res
}
desc := func(e ethtoolCoalesce) string {
@@ -556,7 +542,6 @@ func checkCoalesce(fd int, ifname string, rxUsecs, txUsecs uint32) checkResult {
if err := ethtoolCall(fd, ifname, unsafe.Pointer(&ec)); err != nil {
res.err = err
res.state = "could not set"
res.fatal = true
return res
}
res.fixed = true
@@ -569,7 +554,6 @@ func checkRings(fd int, ifname string, rxWant, txWant uint32) checkResult {
rp, err := getRings(fd, ifname)
if err != nil {
res.err = err
res.fatal = true
return res
}
rx := min(rxWant, rp.rxMaxPending)
@@ -585,7 +569,6 @@ func checkRings(fd int, ifname string, rxWant, txWant uint32) checkResult {
if err := ethtoolCall(fd, ifname, unsafe.Pointer(&rp)); err != nil {
res.err = err
res.state = "could not set"
res.fatal = true
return res
}
res.fixed = true
@@ -596,7 +579,7 @@ func checkRings(fd int, ifname string, rxWant, txWant uint32) checkResult {
func withIoctlSocket(fn func(fd int) []checkResult) []checkResult {
fd, err := unix.Socket(unix.AF_INET, unix.SOCK_DGRAM, 0)
if err != nil {
return []checkResult{{item: "ioctl socket", err: err, fatal: true}}
return []checkResult{{item: "ioctl socket", err: err}}
}
defer unix.Close(fd)
return fn(fd)