Skip to content

[action] [PR:26383] [dut_basic_facts]: resolve real release (YYYYMM) from build_version on unstamped images#26445

Merged
mssonicbld merged 1 commit into
sonic-net:202605from
mssonicbld:cherry/202605/26383
Jul 23, 2026
Merged

[action] [PR:26383] [dut_basic_facts]: resolve real release (YYYYMM) from build_version on unstamped images#26445
mssonicbld merged 1 commit into
sonic-net:202605from
mssonicbld:cherry/202605/26383

Conversation

@mssonicbld

Copy link
Copy Markdown
Collaborator

Description of PR

Summary:
On images without /etc/sonic/sonic_release (all VS/KVM and self-built images), the release fact produced by ansible/library/dut_basic_facts.py is guessed from build_version. The old fallback only recognized 201811, 201911, and master, so every other release (202012202605) collapsed to "unknown" — even though build_version starts with the release token (e.g. 202605.1166406-...).

Because the release fact is what the conditional_mark plugin evaluates, release-based skips such as release in ['202605', ...] silently never matched on VS, so tests intended to be skipped there ran anyway. This surfaced while triaging the CI failure on #26270. This PR fixes the fallback so release resolves to the real YYYYMM release on unstamped/VS images.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
  • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202205
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Approach

What is the motivation for this PR?

Make release-based conditional_mark conditions work correctly on VS/KVM (and any self-built) images. Today they can never match because release resolves to "unknown" on those images, which makes release-gated skips a silent no-op on VS.

How did you do it?

Extracted the release resolution into a pure, dependency-free helper ansible/module_utils/sonic_release_utils.py::guess_release_from_build_version(): an already-stamped release (real HW) is returned unchanged; otherwise a leading YYYYMM token is extracted via re.match(r'(20\d{4})', ...) (202605.1166406-... -> 202605; old date-stamped 20181130.31 -> 201811); master in build_version -> master; anything else -> unknown. ansible/library/dut_basic_facts.py now imports and calls the helper (mirroring the existing parse_utils import guard), replacing the hard-coded 201811/201911/master ladder.

How did you verify/test it?

Added ansible/module_utils/test_sonic_release_utils.py — 62 parametrized cases covering all modern releases, old date-stamped images, master, precedence of an already-stamped release, unparseable -> unknown, build-number-not-confused, and a regression guard that 202605 no longer collapses to unknown: python3 -m pytest --noconftest ansible/module_utils/test_sonic_release_utils.py -> 62 passed. flake8 --max-line-length=120 clean; py_compile OK.

Any platform specific information?

Only affects the release fact derivation for images lacking /etc/sonic/sonic_release (VS/KVM, self-built). Real-HW images that stamp release are unchanged. Old-release exclusion lists are unaffected; the intended effect is that current-release skips now correctly fire on VS.

Supported testbed topology if it's a new test case?

N/A (framework fix).

Documentation

No.

…n unstamped images (sonic-net#26383)

### Description of PR
Summary:
On images without `/etc/sonic/sonic_release` (all VS/KVM and self-built
images), the `release` fact produced by
`ansible/library/dut_basic_facts.py` is guessed from `build_version`.
The old fallback only recognized `201811`, `201911`, and `master`, so
every other release (`202012` … `202605`) collapsed to `"unknown"` —
even though `build_version` starts with the release token (e.g.
`202605.1166406-...`).

Because the `release` fact is what the `conditional_mark` plugin
evaluates, release-based skips such as `release in ['202605', ...]`
silently never matched on VS, so tests intended to be skipped there ran
anyway. This surfaced while triaging the CI failure on
sonic-net#26270. This PR fixes the
fallback so `release` resolves to the real `YYYYMM` release on
unstamped/VS images.

### Type of change
- [ ] Bug fix
- [x] Testbed and Framework(new/improvement)
- [ ] New Test case
    - [ ] Skipped for non-supported platforms
- [ ] Test case improvement

### Back port request
- [ ] 202205
- [ ] 202305
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505
- [ ] 202511

### Approach
#### What is the motivation for this PR?
Make `release`-based `conditional_mark` conditions work correctly on
VS/KVM (and any self-built) images. Today they can never match because
`release` resolves to `"unknown"` on those images, which makes
release-gated skips a silent no-op on VS.

#### How did you do it?
Extracted the release resolution into a pure, dependency-free helper
`ansible/module_utils/sonic_release_utils.py::guess_release_from_build_version()`:
an already-stamped `release` (real HW) is returned unchanged; otherwise
a leading `YYYYMM` token is extracted via `re.match(r'(20\d{4})', ...)`
(`202605.1166406-...` -> `202605`; old date-stamped `20181130.31` ->
`201811`); `master` in `build_version` -> `master`; anything else ->
`unknown`. `ansible/library/dut_basic_facts.py` now imports and calls
the helper (mirroring the existing `parse_utils` import guard),
replacing the hard-coded 201811/201911/master ladder.

#### How did you verify/test it?
Added `ansible/module_utils/test_sonic_release_utils.py` — 62
parametrized cases covering all modern releases, old date-stamped
images, `master`, precedence of an already-stamped release, unparseable
-> `unknown`, build-number-not-confused, and a regression guard that
`202605` no longer collapses to `unknown`: `python3 -m pytest
--noconftest ansible/module_utils/test_sonic_release_utils.py` -> 62
passed. `flake8 --max-line-length=120` clean; `py_compile` OK.

#### Any platform specific information?
Only affects the `release` fact derivation for images lacking
`/etc/sonic/sonic_release` (VS/KVM, self-built). Real-HW images that
stamp `release` are unchanged. Old-release exclusion lists are
unaffected; the intended effect is that current-release skips now
correctly fire on VS.

#### Supported testbed topology if it's a new test case?
N/A (framework fix).

### Documentation
No.

Signed-off-by: Deepak Singhal <deepsinghal@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: mssonicbld <sonicbld@microsoft.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator Author

Original PR: #26383

@mssonicbld

Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions
github-actions Bot requested review from r12f, wangxin and xwjiang-ms July 22, 2026 02:44
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@deepak-singhal0408

Copy link
Copy Markdown
Contributor

/azp run Azure.sonic-mgmt

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@mssonicbld
mssonicbld merged commit a5c12c6 into sonic-net:202605 Jul 23, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants