Drop the fatal flag now that every failed check is fatal
This commit is contained in:
@@ -49,20 +49,17 @@ func checkMount(m mountSpec) checkResult {
|
||||
if err == unix.ENOENT {
|
||||
if err := unix.Mkdir(m.dir, 0o755); err != nil {
|
||||
res.err = fmt.Errorf("creating %s: %w", m.dir, err)
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
err = unix.Statfs(m.dir, &st)
|
||||
}
|
||||
if err != nil {
|
||||
res.err = err
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
mounted, err := isMountRoot(m.dir)
|
||||
if err != nil {
|
||||
res.err = err
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
if mounted && int64(st.Type) == m.magic {
|
||||
@@ -71,7 +68,6 @@ func checkMount(m mountSpec) checkResult {
|
||||
}
|
||||
if err := unix.Mount(m.fstype, m.dir, m.fstype, m.flags, ""); err != nil {
|
||||
res.err = err
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
res.fixed = true
|
||||
@@ -85,7 +81,7 @@ func mountFilesystems() []checkResult {
|
||||
for _, m := range wantMounts {
|
||||
res := checkMount(m)
|
||||
out = append(out, res)
|
||||
if res.fatal {
|
||||
if res.err != nil {
|
||||
return out
|
||||
}
|
||||
}
|
||||
@@ -118,7 +114,6 @@ func waitForTouchscreen() checkResult {
|
||||
}
|
||||
if time.Since(start) >= touchTimeout {
|
||||
res.err = fmt.Errorf("%w after %s", err, touchTimeout)
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
time.Sleep(touchPoll)
|
||||
@@ -128,7 +123,7 @@ func waitForTouchscreen() checkResult {
|
||||
func bootstrap() []checkResult {
|
||||
out := mountFilesystems()
|
||||
// /dev/input/event* only exists once devtmpfs is mounted above.
|
||||
if out[len(out)-1].fatal {
|
||||
if out[len(out)-1].err != nil {
|
||||
return out
|
||||
}
|
||||
return append(out, waitForTouchscreen())
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -40,7 +40,6 @@ func checkTimestamping(fd int, ifname string) checkResult {
|
||||
var have hwtstampConfig
|
||||
if err := hwtstampCall(unix.SIOCGHWTSTAMP, &have); err != nil {
|
||||
res.err = err
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
if have.txType == hwtstampTxOn && have.rxFilter == hwtstampFilterAll {
|
||||
@@ -54,12 +53,10 @@ func checkTimestamping(fd int, ifname string) checkResult {
|
||||
if err := hwtstampCall(unix.SIOCSHWTSTAMP, &want); err != nil {
|
||||
res.err = err
|
||||
res.state = "could not set"
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
if want.txType != hwtstampTxOn || want.rxFilter != hwtstampFilterAll {
|
||||
res.err = fmt.Errorf("driver applied %s instead", desc(want))
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
res.fixed = true
|
||||
|
||||
Reference in New Issue
Block a user