saltstack / saltstack/salt

[BUG] `salt.version.SaltStackVersion.current_release()` returns previous release, not upcoming release, on master checkout

Open
#62,972 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description

When developing a new feature for Salt on a recent checkout of the master branch, I expect salt.version.SaltStackVersion.current_release() to return the version of Salt that is in development (the upcoming release). Instead, it returns a historic, already released version. At the very least, it should return a version that is greater than or equal to salt.version.__saltstack_version__.

This matters for salt.utils.versions.warn_until(): If SaltStackVersion.current_release() always matches a past release instead of the upcoming release, then the act of creating a new Git tag can change Salt's behavior in severe ways (warnings turned into errors). Due to the lateness in the development cycle of the behavior change, it is unlikely to be thoroughly tested before the new release is published.

This also matters when developing a feature that is gated by Salt version; see https://github.com/saltstack/salt/pull/62932#issuecomment-1292723656 for a specific example.

Steps to Reproduce the behavior

>>> import salt.version
>>> import salt.utils.versions
>>> salt.version__saltstack_version__
<SaltStackVersion name='Phosphorus' major=3005 minor=1 noc=922 sha=g93f871df58>
>>> salt.version.SaltStackVersion.current_release()
<SaltStackVersion name='Phosphorus' major=3005>
>>> salt.utils.versions.warn_until((3006, 0), "testing")
<stdin>:1: DeprecationWarning: testing

Expected behavior

>>> import salt.version
>>> import salt.utils.versions
>>> salt.version__saltstack_version__
<SaltStackVersion name='Phosphorus' major=3005 minor=1 noc=922 sha=g93f871df58>
>>> salt.version.SaltStackVersion.current_release()
<SaltStackVersion major=3006>
>>> salt.utils.versions.warn_until((3006, 0), "testing")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "salt/utils/versions.py", line 144, in warn_until
    raise RuntimeError(
RuntimeError: The warning triggered on filename '<stdin>', line number 1, is supposed to be shown until version 3006.0 is released. Current version is now 3006.0. Please remove the warning.

Additional context

Interestingly, current_release() initially returns the upcoming release:

https://github.com/saltstack/salt/blob/6226b9cb582daf675c7b49e59af16dc5d338d10d/salt/version.py#L199-L205

It is forcibly changed to return the previous release later on:

https://github.com/saltstack/salt/blob/6226b9cb582daf675c7b49e59af16dc5d338d10d/salt/version.py#L649-L654

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in salt/version.py, especially the current_release() logic referenced around lines 199-205 and 649-654. Reproduce the issue with the Python examples in the report and trace why the master checkout is forced to the previous release. Done means current_release() reports the upcoming version and warn_until() no longer treats the warning as active at that version.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.