Skip to content

Commit

Permalink
Migration: Set default arch values for boot sets with no arch field
Browse files Browse the repository at this point in the history
  • Loading branch information
mharding-hpe committed Oct 1, 2024
1 parent 3242926 commit f0556a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Marked PATCH session status endpoint to be ignored by the CLI.
- Eliminate redundancies in API spec by defining `V2SessionNameOrEmpty` schema.
- Refactor `validate_boot_sets` function into multiple functions to make it easier to understand.
- During migration to this BOS version, for boot sets with no `arch` field, add the field with its
default value.

### Fixed
- When validating boot sets, check all boot sets for severe errors before returning only warnings
Expand Down
6 changes: 5 additions & 1 deletion src/bos/server/migrations/sanitize.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import string

from bos.common.tenant_utils import get_tenant_aware_key
from bos.server.controllers.v2.boot_set import HARDWARE_SPECIFIER_FIELDS
from bos.server.controllers.v2.boot_set import DEFAULT_ARCH, HARDWARE_SPECIFIER_FIELDS
from bos.server.schema import validator

from .db import TEMP_DB, delete_component, delete_session, delete_template
Expand Down Expand Up @@ -196,6 +196,10 @@ def sanitize_bootset(bsname: str, bsdata: dict) -> str|None:
# be stored inside the boot set under the current API spec
bsdata.pop("name", None)

# If the arch field is not present, set it to its default value
if "arch" not in bsdata:
bsdata["arch"] = DEFAULT_ARCH

# Remove any fields that are no longer in the spec
bad_fields = [ field for field in bsdata if field not in validator.boot_set_fields ]
for field in bad_fields:
Expand Down

0 comments on commit f0556a8

Please sign in to comment.