Skip to content

Commit

Permalink
Allow for unexpcted version names in checks & remediations
Browse files Browse the repository at this point in the history
Summary:
Upgrading from a wiped bletchley fails, due to image version name validation in flashy checks and remediations
```
2024-03-13 02:41:18.275510 - Unsafe to reboot error: "Unable to parse version info: No match for regex 'bletchley-v(?P<year>[0-9]+).(?P<week>[0-9]+)' for input 'bletchley-9e5605ae7d-dirty'".
```
We should allow for Flashy to upgrade from versions without a `vYYYY.WW.N` version tag, such as the OSS image build or locally built versions, and only proceed to the year check if it's an actual date tagged version

Test Plan:
Test upgrade from same device:
```
$ oobgrader --host macbmc5r0034p0049-oob.02.pci1.facebook.com --fbpkg-name openbmc.image.bletchley:weeklybuild --flashy-tag e44d3bf --wait

Host                                        Workflow ID                           Progress    Status                   Result
------------------------------------------  ------------------------------------  ----------  -----------------------  ----------------------
macbmc5r0034p0049-oob.02.pci1.facebook.com  44c2f034-d1ae-4bc3-b692-40c17113f1ac  finished    WorkflowStatus.FINISHED  FinishStatus.SUCCEEDED
```
Test upgrade on wedge100 to ensure normal behaviour
```
$ oobgrader --host fboss8382003.snc1 --primary-only --wait --force --flashy-tag e44d3bf --allow-downgrade

Host                   Workflow ID                           Progress    Status                   Result
---------------------  ------------------------------------  ----------  -----------------------  ----------------------
fboss8382003-oob.snc1  647a8025-e0c2-4977-8208-dbede581f229  finished    WorkflowStatus.FINISHED  FinishStatus.SUCCEEDED
```
 ---
Unit tests:
```
~/local/openbmc/tools/flashy (flashy-reg)]$ ./scripts/run_unit_tests.sh

141/141 unit tests passed
```

Reviewed By: doranand

Differential Revision: D54872760

fbshipit-source-id: 0952d175e12fb9c9e958db9563267e40cadaab1f
  • Loading branch information
cjcon90 authored and facebook-github-bot committed Mar 25, 2024
1 parent 8607473 commit 37fefba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
package remediations_bletchley

import (
"log"
"strings"
"strconv"

"github.com/facebook/openbmc/tools/flashy/lib/step"
Expand All @@ -41,8 +43,13 @@ func checkVersion(stepParams step.StepParams) step.StepExitError {
const re = `bletchley-v(?P<year>[0-9]+).(?P<week>[0-9]+)`
versionMap, err := utils.GetRegexSubexpMap(re, version)
if err != nil {
errMsg := errors.Errorf("Unable to parse version info: %v", err)
return step.ExitUnsafeToReboot{Err: errMsg}
if strings.HasPrefix(version, "bletchley-") {
log.Printf("Upgrading from dirty version. Skipping year check")
return nil
} else {
errMsg := errors.Errorf("Unable to parse version info: %v", err)
return step.ExitUnsafeToReboot{Err: errMsg}
}
}

year, err := strconv.Atoi(versionMap["year"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ func TestCheckVersion(t *testing.T) {
err: nil,
want: nil,
},
{
name: "bitbaked",
version: "bletchley-123abc",
err: nil,
want: nil,
},
{
name: "dirty",
version: "bletchley-123abc-dirty",
err: nil,
want: nil,
},
{
name: "garbage",
version: "garbage",
Expand Down

0 comments on commit 37fefba

Please sign in to comment.