Skip to content

Uniquify requisite_in'd states checks. - #68409

Open
gpernot-celeste wants to merge 1 commit into
saltstack:3008.xfrom
gpernot-celeste:3006.x
Open

gpernot-celeste wants to merge 1 commit into
saltstack:3008.xfrom
gpernot-celeste:3006.x

Conversation

@gpernot-celeste

Copy link
Copy Markdown
Contributor

Fixes #68408

Introduce _add_to_extend for small factorization.

The logic here is to prevent to append dependencies that are already in extend[name][rstate][ind][rkey] :

for key in extend[name][rstate][ind][rkey]:
  if key.get(state) == id_:
    break

@gpernot-celeste
gpernot-celeste requested a review from a team as a code owner October 17, 2025 19:10
@welcome

welcome Bot commented Oct 17, 2025

Copy link
Copy Markdown

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here's some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We're glad you've joined our community and look forward to doing awesome things with you!

@bdrx312 bdrx312 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR; please add tests.

Comment thread salt/state.py Resolved
Comment thread salt/state.py Resolved
Comment thread salt/state.py Resolved
@gpernot-celeste

Copy link
Copy Markdown
Contributor Author

@bdrx312 Thanks for your review !

I added simplified code and unit tests.

@gpernot-celeste
gpernot-celeste marked this pull request as draft October 20, 2025 01:26
@bdrx312

bdrx312 commented Oct 20, 2025

Copy link
Copy Markdown
Contributor

Thanks for the PR. Nice changes.

@gpernot-celeste

Copy link
Copy Markdown
Contributor Author

Thanks for the PR. Nice changes.

Thanks :)

It was buggy, but i now believe that the code is correct.

Should I rebase/squash on 3006.x ?

Comment thread salt/state.py Resolved
Comment thread salt/state.py Resolved
Comment thread salt/state.py Resolved
@gpernot-celeste
gpernot-celeste marked this pull request as ready for review October 24, 2025 13:34

@dwoz dwoz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This needs a changelog.
  • I'm super concerned that this could fix a bug and introduce others.

@gpernot-celeste

Copy link
Copy Markdown
Contributor Author

@dwoz changelog added.

I tried my best with unit tests to avoid introducing bugs.

Moreover, unit tests on check_requisite() should trigger regressions, if any.

@twangboy

Copy link
Copy Markdown
Contributor

Perhaps a functional or integration test, to provide a more thorough test.

@twangboy

twangboy commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

Please rebase and fix conflicts

@twangboy twangboy modified the milestones: Sulfur v3006.18, 3006.20 Jan 13, 2026
Introduce ``State._add_to_extend`` and route both call sites in
``State.requisite_in`` through it. The helper dedups
``{req_state_mod_name: req_id}`` entries so a target state's requisite
list no longer accumulates duplicate references when the same
``*_in`` is declared multiple times (issue saltstack#68408).

Tests cover ``_add_to_extend`` in isolation plus both call sites of
``requisite_in`` (dict-form and list-form) for ``require_in``,
``watch_in``, ``onfail_in`` and ``onchanges_in``, including a
negative control to make sure distinct sources are NOT collapsed.

Rebased onto current 3006.x; ``HashableOrderedDict([(...)])``
positional-init usage in the test cases was switched to a small
helper because the class no longer accepts an items iterable on
3006.x.

Co-authored-by: guillaume pernot <[email protected]>
@twangboy

twangboy commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

We are not longer accepting bugfixes on the 3006.x branch. Please rebase this against the 3008.x branch.

@dwoz
dwoz changed the base branch from 3006.x to 3008.x October 22, 2026 00:14
@dwoz

dwoz commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@gpernot-celeste 3006.x has entered security only. Please rebase these changes on 3008.x

@twangboy twangboy modified the milestones: Argon v3008.5, Argon v3008.7 Oct 30, 2026

This branch was previously deployed

1 inactive deployment
ci — f0268ab1 Deployed Jun 17, 2026 by dwoz via Build Onedir Packages / Windows (x86) #23766
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: state.requisite_in() evaluates same states too many times

4 participants