Skip to content

Commit f94483e

Browse files
malikrafsanmeta-codesync[bot]
authored andcommitted
Add compatibility checking for flash procedure
Summary: We recently encounter issues where minipack3n cannot be flashed. Turned out there is no flash procedure found for this platform. This is because we only have "acctonbmc" flash procedure. This happens because we sync the configerator and create the mapping based on build_name One way to solve this issue is also to check the compatible mapping of the original build name, and check whether the compatible platform has any flash procedure Another long term solution probably also sync the mapping between `acctonbmc -> ["minipack3n", "minipack3ba", "wedge800"]`. For now, I propose to use this simple solution Test Plan: # unit test {P2141569386} --- # functional test - build flashy locally {P2141574929} - run oobgrader using flashy ``` oobgrader --host fboss329039396.snc1.facebook.com --wait --ui --method fbpkg --flashy-tag 034f55c --force --allow-downgrade ``` https://fburl.com/scuba/openbmc_upgrades/7selm40a Reviewed By: kawmarco Differential Revision: D91321314 fbshipit-source-id: 8dfbab6e05cb0c51f34b541031b6cd3faaf41dd4
1 parent a0bedc5 commit f94483e

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

tools/flashy/flash_procedure/platform_registry.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ package flash_procedure
2121

2222
import (
2323
"fmt"
24+
"log"
2425

2526
"github.com/facebook/openbmc/tools/flashy/lib/flash"
2627
"github.com/facebook/openbmc/tools/flashy/lib/step"
28+
"github.com/facebook/openbmc/tools/flashy/lib/validate"
2729
)
2830

2931
var procedureOverrides = map[string]func(step.StepParams) step.StepExitError{
@@ -42,6 +44,22 @@ func init() {
4244
FlashProcedureMappings[platformName] = overrideFunc
4345
}
4446
}
47+
48+
for platformName, compatiblePlatformName := range validate.CompatibleVersionMapping {
49+
_, exists := FlashProcedureMappings[platformName]
50+
if exists {
51+
// prevent overriding existing mappings (eg: in case any override)
52+
continue
53+
}
54+
55+
_, exists = FlashProcedureMappings[compatiblePlatformName]
56+
if !exists {
57+
log.Printf("WARNING: compatible platform name '%s' not present in flash procedure mapping", compatiblePlatformName)
58+
continue
59+
}
60+
61+
FlashProcedureMappings[platformName] = FlashProcedureMappings[compatiblePlatformName]
62+
}
4563
}
4664

4765
func PlatformExists(platformName string) bool {

tools/flashy/lib/validate/compatibility.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
// matches all possible formats would be tough. Instead, we use this to do
3636
// substitutions before matching in areVersionsCompatible().
3737
// NB: the values of this mapping CANNOT contain a dash!
38-
var compatibleVersionMapping = map[string]string{
38+
var CompatibleVersionMapping = map[string]string{
3939
"fby2-gpv2": "fbgp2",
4040
"fby3pvt": "fby3",
4141
"fby3vboot2": "fby3",
@@ -47,7 +47,7 @@ var compatibleVersionMapping = map[string]string{
4747
}
4848

4949
var normalizeVersion = func(ver string) string {
50-
for k, v := range compatibleVersionMapping {
50+
for k, v := range CompatibleVersionMapping {
5151
ver = strings.Replace(ver, k, v, 1)
5252
}
5353
return ver
@@ -96,7 +96,7 @@ var CheckImageBuildNameCompatibility = func(imageFilePath string) error {
9696
}
9797

9898
// getNormalizedBuildNameFromVersion gets the normalized build name from the version using
99-
// compatibleVersionMapping.
99+
// CompatibleVersionMapping.
100100
// fby2-gpv2-v2019.43.1 -> fbgp2
101101
// yosemite-v1.2 -> yosemite
102102
var getNormalizedBuildNameFromVersion = func(ver string) (string, error) {

tools/flashy/lib/validate/compatibility_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
)
3131

3232
func TestCompatibleVersionMapping(t *testing.T) {
33-
// the values of compatibleVersionMapping cannot have a dash
34-
for key, val := range compatibleVersionMapping {
33+
// the values of CompatibleVersionMapping cannot have a dash
34+
for key, val := range CompatibleVersionMapping {
3535
if strings.ContainsAny(val, "-") {
3636
t.Errorf("Invalid mapping (%v, %v), value %v cannot contain a dash",
3737
key, val, val)
@@ -42,11 +42,11 @@ func TestCompatibleVersionMapping(t *testing.T) {
4242
func TestCheckImageBuildNameCompatibility(t *testing.T) {
4343
getOpenBMCVersionFromIssueFileOrig := utils.GetOpenBMCVersionFromIssueFile
4444
getOpenBMCVersionFromImageFileOrig := GetOpenBMCVersionFromImageFile
45-
compatibleVersionMappingOrig := compatibleVersionMapping
45+
CompatibleVersionMappingOrig := CompatibleVersionMapping
4646
defer func() {
4747
utils.GetOpenBMCVersionFromIssueFile = getOpenBMCVersionFromIssueFileOrig
4848
GetOpenBMCVersionFromImageFile = getOpenBMCVersionFromImageFileOrig
49-
compatibleVersionMapping = compatibleVersionMappingOrig
49+
CompatibleVersionMapping = CompatibleVersionMappingOrig
5050
}()
5151

5252
cases := []struct {
@@ -105,7 +105,7 @@ func TestCheckImageBuildNameCompatibility(t *testing.T) {
105105
},
106106
}
107107

108-
compatibleVersionMapping = map[string]string{"fby2-gpv2": "fbgp2"}
108+
CompatibleVersionMapping = map[string]string{"fby2-gpv2": "fbgp2"}
109109
for _, tc := range cases {
110110
t.Run(tc.name, func(t *testing.T) {
111111
exampleImageFilePath := "/run/upgrade/mock"
@@ -126,9 +126,9 @@ func TestCheckImageBuildNameCompatibility(t *testing.T) {
126126

127127
// also tests normalizeVersion
128128
func TestGetNormalizedBuildNameFromVersion(t *testing.T) {
129-
compatibleVersionMappingOrig := compatibleVersionMapping
129+
CompatibleVersionMappingOrig := CompatibleVersionMapping
130130
defer func() {
131-
compatibleVersionMapping = compatibleVersionMappingOrig
131+
CompatibleVersionMapping = CompatibleVersionMappingOrig
132132
}()
133133

134134
cases := []struct {
@@ -182,7 +182,7 @@ func TestGetNormalizedBuildNameFromVersion(t *testing.T) {
182182
},
183183
}
184184

185-
compatibleVersionMapping = map[string]string{"fby2-gpv2": "fbgp2", "minipack3n": "acctonbmc", "icecube800bc": "celesticabmc"}
185+
CompatibleVersionMapping = map[string]string{"fby2-gpv2": "fbgp2", "minipack3n": "acctonbmc", "icecube800bc": "celesticabmc"}
186186
for _, tc := range cases {
187187
t.Run(tc.name, func(t *testing.T) {
188188
got, err := getNormalizedBuildNameFromVersion(tc.ver)

0 commit comments

Comments
 (0)