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.ENOENT {
|
||||||
if err := unix.Mkdir(m.dir, 0o755); err != nil {
|
if err := unix.Mkdir(m.dir, 0o755); err != nil {
|
||||||
res.err = fmt.Errorf("creating %s: %w", m.dir, err)
|
res.err = fmt.Errorf("creating %s: %w", m.dir, err)
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
err = unix.Statfs(m.dir, &st)
|
err = unix.Statfs(m.dir, &st)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
mounted, err := isMountRoot(m.dir)
|
mounted, err := isMountRoot(m.dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
if mounted && int64(st.Type) == m.magic {
|
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 {
|
if err := unix.Mount(m.fstype, m.dir, m.fstype, m.flags, ""); err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
res.fixed = true
|
res.fixed = true
|
||||||
@@ -85,7 +81,7 @@ func mountFilesystems() []checkResult {
|
|||||||
for _, m := range wantMounts {
|
for _, m := range wantMounts {
|
||||||
res := checkMount(m)
|
res := checkMount(m)
|
||||||
out = append(out, res)
|
out = append(out, res)
|
||||||
if res.fatal {
|
if res.err != nil {
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,7 +114,6 @@ func waitForTouchscreen() checkResult {
|
|||||||
}
|
}
|
||||||
if time.Since(start) >= touchTimeout {
|
if time.Since(start) >= touchTimeout {
|
||||||
res.err = fmt.Errorf("%w after %s", err, touchTimeout)
|
res.err = fmt.Errorf("%w after %s", err, touchTimeout)
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
time.Sleep(touchPoll)
|
time.Sleep(touchPoll)
|
||||||
@@ -128,7 +123,7 @@ func waitForTouchscreen() checkResult {
|
|||||||
func bootstrap() []checkResult {
|
func bootstrap() []checkResult {
|
||||||
out := mountFilesystems()
|
out := mountFilesystems()
|
||||||
// /dev/input/event* only exists once devtmpfs is mounted above.
|
// /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 out
|
||||||
}
|
}
|
||||||
return append(out, waitForTouchscreen())
|
return append(out, waitForTouchscreen())
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ func clearFlowRules(fd int, ifname string) checkResult {
|
|||||||
locs, _, err := allRuleLocations(fd, ifname)
|
locs, _, err := allRuleLocations(fd, ifname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
n := 0
|
n := 0
|
||||||
@@ -136,7 +135,6 @@ func clearFlowRules(fd int, ifname string) checkResult {
|
|||||||
}
|
}
|
||||||
if err := deleteRule(fd, ifname, loc); err != nil {
|
if err := deleteRule(fd, ifname, loc); err != nil {
|
||||||
res.err = fmt.Errorf("deleting rule %d: %w", loc, err)
|
res.err = fmt.Errorf("deleting rule %d: %w", loc, err)
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
n++
|
n++
|
||||||
@@ -151,25 +149,21 @@ func checkFlowRules(fd int, ifname string, ethertypes []uint16) checkResult {
|
|||||||
rings, err := rxRings(fd, ifname)
|
rings, err := rxRings(fd, ifname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
if uint64(len(ethertypes)) > rings {
|
if uint64(len(ethertypes)) > rings {
|
||||||
res.err = fmt.Errorf("%d streams needs %d rx rings, only %d available",
|
res.err = fmt.Errorf("%d streams needs %d rx rings, only %d available",
|
||||||
len(ethertypes), len(ethertypes), rings)
|
len(ethertypes), len(ethertypes), rings)
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
locs, capacity, err := allRuleLocations(fd, ifname)
|
locs, capacity, err := allRuleLocations(fd, ifname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
if capacity < uint32(len(ethertypes)) {
|
if capacity < uint32(len(ethertypes)) {
|
||||||
res.err = fmt.Errorf("filter capacity %d is below %d streams", capacity, len(ethertypes))
|
res.err = fmt.Errorf("filter capacity %d is below %d streams", capacity, len(ethertypes))
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
taken := make(map[uint32]bool, len(locs))
|
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 {
|
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",
|
res.err = fmt.Errorf("steering ethertype 0x%04x to queue %d at location %d: %w",
|
||||||
et, i, next, err)
|
et, i, next, err)
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
taken[next] = true
|
taken[next] = true
|
||||||
@@ -258,7 +251,6 @@ type checkResult struct {
|
|||||||
item string
|
item string
|
||||||
state string
|
state string
|
||||||
fixed bool
|
fixed bool
|
||||||
fatal bool
|
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,18 +277,18 @@ func (r checkResult) detail() string {
|
|||||||
|
|
||||||
func reportChecks(title string, results []checkResult) error {
|
func reportChecks(title string, results []checkResult) error {
|
||||||
var rows [][]string
|
var rows [][]string
|
||||||
var fatal []string
|
var failed []string
|
||||||
for _, r := range results {
|
for _, r := range results {
|
||||||
rows = append(rows, []string{r.item, r.status(), r.detail()})
|
rows = append(rows, []string{r.item, r.status(), r.detail()})
|
||||||
if r.fatal {
|
if r.err != nil {
|
||||||
fatal = append(fatal, r.item)
|
failed = append(failed, r.item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println(renderBox(title,
|
fmt.Println(renderBox(title,
|
||||||
[]string{"CHECK", "STATUS", "DETAIL"},
|
[]string{"CHECK", "STATUS", "DETAIL"},
|
||||||
[]bool{false, false, false}, rows))
|
[]bool{false, false, false}, rows))
|
||||||
if len(fatal) > 0 {
|
if len(failed) > 0 {
|
||||||
return fmt.Errorf("cannot test with %s in this state", strings.Join(fatal, ", "))
|
return fmt.Errorf("cannot test with %s in this state", strings.Join(failed, ", "))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -462,7 +454,6 @@ func checkGovernor(want string) checkResult {
|
|||||||
paths, err := filepath.Glob("/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor")
|
paths, err := filepath.Glob("/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor")
|
||||||
if err != nil || len(paths) == 0 {
|
if err != nil || len(paths) == 0 {
|
||||||
res.err = fmt.Errorf("no cpufreq governors found")
|
res.err = fmt.Errorf("no cpufreq governors found")
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
var wrong []string
|
var wrong []string
|
||||||
@@ -471,7 +462,6 @@ func checkGovernor(want string) checkResult {
|
|||||||
b, err := os.ReadFile(p)
|
b, err := os.ReadFile(p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
got := strings.TrimSpace(string(b))
|
got := strings.TrimSpace(string(b))
|
||||||
@@ -492,7 +482,6 @@ func checkGovernor(want string) checkResult {
|
|||||||
if err := os.WriteFile(p, []byte(want), 0o644); err != nil {
|
if err := os.WriteFile(p, []byte(want), 0o644); err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.state = fmt.Sprintf("could not set %s", p)
|
res.state = fmt.Sprintf("could not set %s", p)
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -509,7 +498,6 @@ func checkLinkUp(fd int, ifname string) checkResult {
|
|||||||
uintptr(unix.SIOCGIFFLAGS), uintptr(unsafe.Pointer(&ifr)))
|
uintptr(unix.SIOCGIFFLAGS), uintptr(unsafe.Pointer(&ifr)))
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
res.err = errno
|
res.err = errno
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
if ifr.flags&unix.IFF_UP != 0 {
|
if ifr.flags&unix.IFF_UP != 0 {
|
||||||
@@ -522,7 +510,6 @@ func checkLinkUp(fd int, ifname string) checkResult {
|
|||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
res.err = errno
|
res.err = errno
|
||||||
res.state = "could not set IFF_UP"
|
res.state = "could not set IFF_UP"
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
res.fixed = true
|
res.fixed = true
|
||||||
@@ -535,7 +522,6 @@ func checkCoalesce(fd int, ifname string, rxUsecs, txUsecs uint32) checkResult {
|
|||||||
ec, err := getCoalesce(fd, ifname)
|
ec, err := getCoalesce(fd, ifname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
desc := func(e ethtoolCoalesce) string {
|
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 {
|
if err := ethtoolCall(fd, ifname, unsafe.Pointer(&ec)); err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.state = "could not set"
|
res.state = "could not set"
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
res.fixed = true
|
res.fixed = true
|
||||||
@@ -569,7 +554,6 @@ func checkRings(fd int, ifname string, rxWant, txWant uint32) checkResult {
|
|||||||
rp, err := getRings(fd, ifname)
|
rp, err := getRings(fd, ifname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
rx := min(rxWant, rp.rxMaxPending)
|
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 {
|
if err := ethtoolCall(fd, ifname, unsafe.Pointer(&rp)); err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.state = "could not set"
|
res.state = "could not set"
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
res.fixed = true
|
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 {
|
func withIoctlSocket(fn func(fd int) []checkResult) []checkResult {
|
||||||
fd, err := unix.Socket(unix.AF_INET, unix.SOCK_DGRAM, 0)
|
fd, err := unix.Socket(unix.AF_INET, unix.SOCK_DGRAM, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []checkResult{{item: "ioctl socket", err: err, fatal: true}}
|
return []checkResult{{item: "ioctl socket", err: err}}
|
||||||
}
|
}
|
||||||
defer unix.Close(fd)
|
defer unix.Close(fd)
|
||||||
return fn(fd)
|
return fn(fd)
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ func checkTimestamping(fd int, ifname string) checkResult {
|
|||||||
var have hwtstampConfig
|
var have hwtstampConfig
|
||||||
if err := hwtstampCall(unix.SIOCGHWTSTAMP, &have); err != nil {
|
if err := hwtstampCall(unix.SIOCGHWTSTAMP, &have); err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
if have.txType == hwtstampTxOn && have.rxFilter == hwtstampFilterAll {
|
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 {
|
if err := hwtstampCall(unix.SIOCSHWTSTAMP, &want); err != nil {
|
||||||
res.err = err
|
res.err = err
|
||||||
res.state = "could not set"
|
res.state = "could not set"
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
if want.txType != hwtstampTxOn || want.rxFilter != hwtstampFilterAll {
|
if want.txType != hwtstampTxOn || want.rxFilter != hwtstampFilterAll {
|
||||||
res.err = fmt.Errorf("driver applied %s instead", desc(want))
|
res.err = fmt.Errorf("driver applied %s instead", desc(want))
|
||||||
res.fatal = true
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
res.fixed = true
|
res.fixed = true
|
||||||
|
|||||||
Reference in New Issue
Block a user