Skip to content

Commit

Permalink
S368275: don't mess with the watchdog on darwin
Browse files Browse the repository at this point in the history
Summary:
Messing with a stopped watchdog starts it.

Can do something nicer later.

Test Plan:
```
0 ~/local/openbmc/tools/flashy $ go test ./...
?       github.com/facebook/openbmc/tools/flashy/flash_procedure        [no test files]
?       github.com/facebook/openbmc/tools/flashy/lib/logger     [no test files]
?       github.com/facebook/openbmc/tools/flashy/tests  [no test files]
?       github.com/facebook/openbmc/tools/flashy/utilities      [no test files]
ok      github.com/facebook/openbmc/tools/flashy        3.350s
ok      github.com/facebook/openbmc/tools/flashy/checks_and_remediations/bletchley      0.008s
ok      github.com/facebook/openbmc/tools/flashy/checks_and_remediations/common 0.296s
ok      github.com/facebook/openbmc/tools/flashy/checks_and_remediations/galaxy100      0.008s
ok      github.com/facebook/openbmc/tools/flashy/checks_and_remediations/wedge100       0.012s
ok      github.com/facebook/openbmc/tools/flashy/checks_and_remediations/yamp   0.009s
ok      github.com/facebook/openbmc/tools/flashy/install        0.009s
ok      github.com/facebook/openbmc/tools/flashy/lib/fileutils  0.014s
ok      github.com/facebook/openbmc/tools/flashy/lib/flash      0.011s
ok      github.com/facebook/openbmc/tools/flashy/lib/flash/flashcp      0.011s
ok      github.com/facebook/openbmc/tools/flashy/lib/flash/flashutils   0.008s
ok      github.com/facebook/openbmc/tools/flashy/lib/flash/flashutils/devices   0.009s
ok      github.com/facebook/openbmc/tools/flashy/lib/step       0.012s
ok      github.com/facebook/openbmc/tools/flashy/lib/utils      0.455s
ok      github.com/facebook/openbmc/tools/flashy/lib/validate   0.009s
ok      github.com/facebook/openbmc/tools/flashy/lib/validate/image     0.014s
ok      github.com/facebook/openbmc/tools/flashy/lib/validate/partition 0.037s
0 ~/local/openbmc/tools/flashy $ ./build.sh && ./build_dev.sh
0 ~/local/openbmc/tools/flashy $
```

```
$ oobgrader --host rsw029-oob.p076.f01.rva3.tfbnw.net --primary-only --wait --flashy-tag 734df50 --force --allow-downgrade
```
-> https://fburl.com/scuba/openbmc_upgrades/7e89e86b

Console messages during upgrade (no mention of watchdog):

```
[ 2783.001706] 11_drop_caches (6255): drop_caches: 3
[ 2873.352788] reboot: Restarting system

U-Boot 2019.04 fbdarwin-v2022.27.1 (Jul 06 2022 - 20:26:37 +0000)
```

Reviewed By: kawmarco

Differential Revision: D49734788

fbshipit-source-id: 1c2ce62b9d94f7fe8eb66a1969b0a2fc1d0c19a9
  • Loading branch information
doranand authored and facebook-github-bot committed Sep 28, 2023
1 parent 8fae05a commit 6dd6665
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 5 deletions.
29 changes: 24 additions & 5 deletions tools/flashy/lib/utils/system.go
Expand Up @@ -365,6 +365,19 @@ var IsLFOpenBMC = func() (bool) {
return strings.Contains(string(osReleaseBuf), magic)
}

// IsBMCLite check whether the system is running BMC-lite
// For S368275. Make this beautiful later.
var IsBMCLite = func() (bool) {
const magic = "fbdarwin"

issueBuf, err := fileutils.ReadFile(etcIssueFilePath)
if err != nil {
return false
}

return strings.Contains(string(issueBuf), magic)
}

// CheckOtherFlasherRunning return an error if any other flashers are running.
// It takes in the baseNames of all flashy's steps (e.g. 00_truncate_logs)
// to make sure no other instance of flashy is running.
Expand Down Expand Up @@ -519,11 +532,17 @@ func tryPetWatchdog() bool {
// are no concurrent instances of wdtcli, the watchdog timeout will be
// extended and the watchdog petted.
var PetWatchdog = func() {
// LF-OpenBMC relies on systemd to pet the watchdog, so there is nothing
// to do here.
if IsLFOpenBMC() {
return
}
// LF-OpenBMC relies on systemd to pet the watchdog, so there is nothing
// to do here.
if IsLFOpenBMC() {
log.Printf("Watchdog not petted; LF OpenBMC")
return
}

if IsBMCLite() {
log.Printf("Watchdog not petted; BMC Lite")
return
}

for i := 0; i < 10; i++ {
if tryPetWatchdog() {
Expand Down
48 changes: 48 additions & 0 deletions tools/flashy/lib/utils/system_test.go
Expand Up @@ -724,6 +724,54 @@ func TestIsLFOpenBMC(t *testing.T) {
}
}

func TestIsBMCLite(t *testing.T) {
// mock and defer restore ReadFile
readFileOrig := fileutils.ReadFile
defer func() {
fileutils.ReadFile = readFileOrig
}()
cases := []struct {
name string
readFileContents string
readFileError error
want bool
}{
{
name: "Is BMC Lite",
readFileContents: `OpenBMC Release fbdarwin-v2022.27.1`,
readFileError: nil,
want: true,
},
{
name: "Not BMC Lite",
readFileContents: `foobar`,
readFileError: nil,
want: false,
},
{
name: "/etc/issue file read error",
readFileContents: "",
readFileError: errors.Errorf("file read error"),
want: false,
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
fileutils.ReadFile = func(filename string) ([]byte, error) {
if filename != "/etc/issue" {
t.Errorf("filename: want '%v' got '%v'",
"/etc/issue", filename)
}
return []byte(tc.readFileContents), tc.readFileError
}

got := IsBMCLite()
if tc.want != got {
t.Errorf("want '%v' got '%v'", tc.want, got)
}
})
}
}

func TestCheckOtherFlasherRunning(t *testing.T) {
// mock and defer restore
Expand Down

0 comments on commit 6dd6665

Please sign in to comment.