Skip to content

Commit 6dd6665

Browse files
doranandfacebook-github-bot
authored andcommitted
S368275: don't mess with the watchdog on darwin
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
1 parent 8fae05a commit 6dd6665

File tree

2 files changed

+72
-5
lines changed

2 files changed

+72
-5
lines changed

tools/flashy/lib/utils/system.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,19 @@ var IsLFOpenBMC = func() (bool) {
365365
return strings.Contains(string(osReleaseBuf), magic)
366366
}
367367

368+
// IsBMCLite check whether the system is running BMC-lite
369+
// For S368275. Make this beautiful later.
370+
var IsBMCLite = func() (bool) {
371+
const magic = "fbdarwin"
372+
373+
issueBuf, err := fileutils.ReadFile(etcIssueFilePath)
374+
if err != nil {
375+
return false
376+
}
377+
378+
return strings.Contains(string(issueBuf), magic)
379+
}
380+
368381
// CheckOtherFlasherRunning return an error if any other flashers are running.
369382
// It takes in the baseNames of all flashy's steps (e.g. 00_truncate_logs)
370383
// to make sure no other instance of flashy is running.
@@ -519,11 +532,17 @@ func tryPetWatchdog() bool {
519532
// are no concurrent instances of wdtcli, the watchdog timeout will be
520533
// extended and the watchdog petted.
521534
var PetWatchdog = func() {
522-
// LF-OpenBMC relies on systemd to pet the watchdog, so there is nothing
523-
// to do here.
524-
if IsLFOpenBMC() {
525-
return
526-
}
535+
// LF-OpenBMC relies on systemd to pet the watchdog, so there is nothing
536+
// to do here.
537+
if IsLFOpenBMC() {
538+
log.Printf("Watchdog not petted; LF OpenBMC")
539+
return
540+
}
541+
542+
if IsBMCLite() {
543+
log.Printf("Watchdog not petted; BMC Lite")
544+
return
545+
}
527546

528547
for i := 0; i < 10; i++ {
529548
if tryPetWatchdog() {

tools/flashy/lib/utils/system_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,54 @@ func TestIsLFOpenBMC(t *testing.T) {
724724
}
725725
}
726726

727+
func TestIsBMCLite(t *testing.T) {
728+
// mock and defer restore ReadFile
729+
readFileOrig := fileutils.ReadFile
730+
defer func() {
731+
fileutils.ReadFile = readFileOrig
732+
}()
733+
cases := []struct {
734+
name string
735+
readFileContents string
736+
readFileError error
737+
want bool
738+
}{
739+
{
740+
name: "Is BMC Lite",
741+
readFileContents: `OpenBMC Release fbdarwin-v2022.27.1`,
742+
readFileError: nil,
743+
want: true,
744+
},
745+
{
746+
name: "Not BMC Lite",
747+
readFileContents: `foobar`,
748+
readFileError: nil,
749+
want: false,
750+
},
751+
{
752+
name: "/etc/issue file read error",
753+
readFileContents: "",
754+
readFileError: errors.Errorf("file read error"),
755+
want: false,
756+
},
757+
}
758+
for _, tc := range cases {
759+
t.Run(tc.name, func(t *testing.T) {
760+
fileutils.ReadFile = func(filename string) ([]byte, error) {
761+
if filename != "/etc/issue" {
762+
t.Errorf("filename: want '%v' got '%v'",
763+
"/etc/issue", filename)
764+
}
765+
return []byte(tc.readFileContents), tc.readFileError
766+
}
767+
768+
got := IsBMCLite()
769+
if tc.want != got {
770+
t.Errorf("want '%v' got '%v'", tc.want, got)
771+
}
772+
})
773+
}
774+
}
727775

728776
func TestCheckOtherFlasherRunning(t *testing.T) {
729777
// mock and defer restore

0 commit comments

Comments
 (0)