Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cached pillar errors on state.apply #61189

Merged
merged 1 commit into from
Oct 6, 2022

Conversation

agraul
Copy link
Contributor

@agraul agraul commented Nov 5, 2021

What does this PR do?

On state.apply, only look for errors in the fresh pillar data. Errors in the in-memory pillar can be ignored because the in-memory pillar data is not used anyway.

What issues does this PR fix or reference?

Fixes: #52354
Fixes: #59339
Fixes: #57180

Previous Behavior

When the in-memory pillar (__pillar__) contains _errors, state.apply aborts when it looks for errors in the pillar.

New Behavior

Errors in the in-memory pillar are only looked for if the fresh pillar is empty.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@agraul agraul requested a review from a team as a code owner November 5, 2021 19:43
@agraul agraul requested review from MKLeb and removed request for a team November 5, 2021 19:43
@agraul
Copy link
Contributor Author

agraul commented Nov 5, 2021

Failing test:

def test_get_pillar_errors_CE():
"""
Test _get_pillar_errors function.
CC: External clean, Internal erroneous
:return:
"""

The test, and _get_pillar_errors's docstring focus on an internal vs external pillar. Is that really the case? When running state.apply the two pillars seems to be the in-memory pillar and the freshly generated pillar (through salt.state.State), not internal plus external.

I think the docstring and tests are outdated, but I'm not sure.

@agraul agraul force-pushed the fix-cached-pillar-error-state-apply branch 2 times, most recently from e28b94e to ec8d467 Compare November 19, 2021 13:51
@agraul
Copy link
Contributor Author

agraul commented Nov 19, 2021

I've now changed the doc string and updated the unit tests. Please let me know if this was the correct thing to do, or if external/internal is the correct differentiation. In the state.apply, in-memory vs. fresh pillar data is clearer to me, similar to the docs

@agraul agraul force-pushed the fix-cached-pillar-error-state-apply branch 3 times, most recently from 9ae9f39 to 2f24bec Compare November 23, 2021 18:59
@agraul agraul force-pushed the fix-cached-pillar-error-state-apply branch from 2f24bec to 9784815 Compare December 6, 2021 18:57
@agraul
Copy link
Contributor Author

agraul commented Dec 8, 2021

Hey @saltstack/core-pr-reviewers, all checks are green now. It would be great if one of you could review this pull request 😃 when you have time.

@agraul agraul force-pushed the fix-cached-pillar-error-state-apply branch from e624cf6 to a5cbd79 Compare January 24, 2022 15:53
@agraul agraul requested a review from MKLeb January 24, 2022 15:56
MKLeb
MKLeb previously approved these changes Apr 20, 2022
@MKLeb
Copy link
Contributor

MKLeb commented Apr 21, 2022

re-run all

twangboy
twangboy previously approved these changes May 2, 2022
Ch3LL
Ch3LL previously approved these changes Oct 3, 2022
@Ch3LL Ch3LL added the Sulfur v3006.0 release code name and version label Oct 3, 2022
@Ch3LL
Copy link
Contributor

Ch3LL commented Oct 4, 2022

The failure on photon looks to be related to these changes.

state.apply request new pillar data from the server. This done to always
have the most up-to-date pillar to work with. Previously, checking for
pillar errors looked at both the new pillar and the in-memory pillar.
The latter might contain pillar rendering errors even if the former does
not.

For this reason, only the new pillar should be checked, not both.
@agraul
Copy link
Contributor Author

agraul commented Oct 6, 2022

The failure on photon looks to be related to these changes.

That's correct, the failing test is the new one I'm adding in this PR. In the test I have a file.managed state which copies over a test file. On photon, this test file is written with a different file mode than on any other OS. I'll specify it in the file.managed state, that will make the test deterministic (at least in this regard)

@agraul agraul dismissed stale reviews from Ch3LL, twangboy, and MKLeb via 9718bd2 October 6, 2022 11:29
@agraul agraul force-pushed the fix-cached-pillar-error-state-apply branch from 9411784 to 9718bd2 Compare October 6, 2022 11:29
@github-actions
Copy link

github-actions bot commented Oct 6, 2022

Hi! I'm your friendly PR bot!

You might be wondering what I'm doing commenting here on your PR.

Yes, as a matter of fact, I am...

I'm just here to help us improve the documentation. I can't respond to
questions or anything, but what I can do, I do well!

Okay... so what do you do?

I detect modules that are missing docstrings or "CLI Example" on existing docstrings!
When I was created we had a lot of these. The documentation for these
modules need some love and attention to make Salt better for our users.

So what does that have to do with my PR?

I noticed that in this PR there are some files changed that have some of these
issues. So I'm leaving this comment to let you know your options.

Okay, what are they?

Well, my favorite, is that since you were making changes here I'm hoping that
you would be the most familiar with this module and be able to add some other
examples or fix any of the reported issues.

If I can, then what?

Well, you can either add them to this PR or add them to another PR. Either way is fine!

Well... what if I can't, or don't want to?

That's also fine! We appreciate all contributions to the Salt Project. If you
can't add those other examples, either because you're too busy, or unfamiliar,
or you just aren't interested, we still appreciate the contributions that
you've made already.

Whatever approach you decide to take, just drop a comment here letting us know!

Detected Issues (click me)
Check Known Missing Docstrings...........................................Failed
- hook id: invoke
- exit code: 1

/home/runner/.cache/pre-commit/repolfxap482/py_env-python3/lib/python3.9/site-packages/distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
The function 'get_pauses' on 'salt/modules/state.py' does not have a 'CLI Example:' in its docstring
The function 'apply
' on 'salt/modules/state.py' does not have a 'CLI Example:' in its docstring
The function 'test' on 'salt/modules/state.py' does not have a 'CLI Example:' in its docstring
Found 3 errors


Thanks again!

1 similar comment
@github-actions
Copy link

github-actions bot commented Oct 6, 2022

Hi! I'm your friendly PR bot!

You might be wondering what I'm doing commenting here on your PR.

Yes, as a matter of fact, I am...

I'm just here to help us improve the documentation. I can't respond to
questions or anything, but what I can do, I do well!

Okay... so what do you do?

I detect modules that are missing docstrings or "CLI Example" on existing docstrings!
When I was created we had a lot of these. The documentation for these
modules need some love and attention to make Salt better for our users.

So what does that have to do with my PR?

I noticed that in this PR there are some files changed that have some of these
issues. So I'm leaving this comment to let you know your options.

Okay, what are they?

Well, my favorite, is that since you were making changes here I'm hoping that
you would be the most familiar with this module and be able to add some other
examples or fix any of the reported issues.

If I can, then what?

Well, you can either add them to this PR or add them to another PR. Either way is fine!

Well... what if I can't, or don't want to?

That's also fine! We appreciate all contributions to the Salt Project. If you
can't add those other examples, either because you're too busy, or unfamiliar,
or you just aren't interested, we still appreciate the contributions that
you've made already.

Whatever approach you decide to take, just drop a comment here letting us know!

Detected Issues (click me)
Check Known Missing Docstrings...........................................Failed
- hook id: invoke
- exit code: 1

/home/runner/.cache/pre-commit/repolfxap482/py_env-python3/lib/python3.9/site-packages/distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
The function 'get_pauses' on 'salt/modules/state.py' does not have a 'CLI Example:' in its docstring
The function 'apply
' on 'salt/modules/state.py' does not have a 'CLI Example:' in its docstring
The function 'test' on 'salt/modules/state.py' does not have a 'CLI Example:' in its docstring
Found 3 errors


Thanks again!

@agraul
Copy link
Contributor Author

agraul commented Oct 6, 2022

Is the debian failure a known issue? I'd be surprised if my change caused any runtime performance regression, it reduces the number of dict.get calls.

For completeness, this is the failing test

        ...
        duration = 4                     <============================= duration defined here
        if salt.utils.platform.spawning_platform():
            duration = 30
            # mac needs some more time to do its makeup
            if salt.utils.platform.is_darwin():
                duration += 15
    
        with pytest.helpers.temp_file("retry.sls", sls_contents, state_tree):
            ret = state.sls(
                "retry", __pub_jid="1"
            )  # Because these run in parallel we need a fake JID
    
            for state_return in ret:
                assert state_return.result is True
>               assert state_return.full_return["duration"] < duration 
E               assert 10.765 < 4

@MKLeb
Copy link
Contributor

MKLeb commented Oct 6, 2022

@agraul Yes, I've seen that fail sporadically before. Going to re-run the failed tests here, as they seem to be unrelated.

@Ch3LL Ch3LL merged commit dcfe24f into saltstack:master Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-failing-test Sulfur v3006.0 release code name and version
Projects
None yet
4 participants