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

Add onchange configuration for script engine #62868

Merged
merged 9 commits into from
Dec 8, 2022

Conversation

lkubb
Copy link
Contributor

@lkubb lkubb commented Oct 12, 2022

What does this PR do?

Adds configuration for the script engine to only fire an event if the event tag-specific data changes compared to the last run (see the linked issue).

What issues does this PR fix or reference?

Fixes: #62867

Previous Behavior

Fires an event every time the script is run.

New Behavior

Can be configured to watch for changes between runs.

Merge requirements satisfied?

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

Commits signed with GPG?

Yes

@lkubb lkubb requested a review from a team as a code owner October 12, 2022 10:25
@lkubb lkubb requested review from waynew and removed request for a team October 12, 2022 10:25
@lkubb lkubb force-pushed the script-engine-onchange branch 2 times, most recently from d40d5a6 to ede9794 Compare October 12, 2022 10:32
@lkubb lkubb force-pushed the script-engine-onchange branch from ede9794 to 448b5f5 Compare October 12, 2022 10:35
Copy link
Contributor

@Ch3LL Ch3LL left a comment

Choose a reason for hiding this comment

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

I would prefer to not use this function if we don't need to. I understand why you are doing that and ping @waynew for any ideas here.

salt/engines/script.py Outdated Show resolved Hide resolved
salt/engines/script.py Show resolved Hide resolved
salt/engines/script.py Outdated Show resolved Hide resolved
Ch3LL
Ch3LL previously approved these changes Oct 18, 2022
@Ch3LL
Copy link
Contributor

Ch3LL commented Oct 18, 2022

Looks good to me. @waynew can you also review please

@Ch3LL Ch3LL requested a review from waynew October 18, 2022 19:11
@Ch3LL Ch3LL added the Sulfur v3006.0 release code name and version label Oct 18, 2022
Copy link
Contributor

@waynew waynew left a comment

Choose a reason for hiding this comment

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

Well, I thought that was just a comment but apparently GitHub decided posting on the comment page should open up a review 🤦

salt/engines/script.py Outdated Show resolved Hide resolved
@waynew
Copy link
Contributor

waynew commented Oct 18, 2022

@lkubb so on today's Test Clinic I went ahead and added a fixture and a couple of tests. #62910 is my PR that adds the fixture, and you can find the tests I started on over here: https://github.com/saltstack/salt/compare/master...waynew:salt:engine-scripts-tests?expand=1

I think the timer approach is probably a reasonable way to go for this.

MKLeb
MKLeb previously approved these changes Oct 19, 2022
twangboy
twangboy previously approved these changes Oct 24, 2022
@garethgreenaway
Copy link
Contributor

@lkubb Making sure you saw the comments from @waynew above.

@lkubb
Copy link
Contributor Author

lkubb commented Oct 27, 2022

@garethgreenaway I saw them, just waiting for his timeout fixture PR to be merged to revert my last commit and base off it.

@lkubb lkubb mentioned this pull request Dec 6, 2022
1 task
@lkubb lkubb dismissed stale reviews from twangboy, MKLeb, and Ch3LL via 637c404 December 8, 2022 07:42
@lkubb lkubb force-pushed the script-engine-onchange branch from 4354a49 to 637c404 Compare December 8, 2022 07:42
lkubb added 2 commits December 8, 2022 08:43
* Sometimes, the timeout fails
* Ensure that there are enough values in side_effect for small
  variations
@lkubb lkubb requested a review from Ch3LL December 8, 2022 11:34
@Ch3LL
Copy link
Contributor

Ch3LL commented Dec 8, 2022

I noticed more commits. Is this ready for review/merge now? or are you still waiting on #62910 ?

@lkubb
Copy link
Contributor Author

lkubb commented Dec 8, 2022

I would consider this ready for review/merging now since I implemented a basic version of the timeout fixture @waynew proposed myself and reverted all the testing-related refactoring of the script engine.

I'm not 100% certain the timeout fixture can be relied on though, in my testing it sometimes did not trigger. This PR contains a workaround for that issue specific to the script engine.

@Ch3LL
Copy link
Contributor

Ch3LL commented Dec 8, 2022

thanks, just want @waynew to re-review here

@Ch3LL Ch3LL requested a review from waynew December 8, 2022 20:37
@garethgreenaway garethgreenaway merged commit cb820b6 into saltstack:master Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sulfur v3006.0 release code name and version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] salt.engines.script: only fire event on data change
6 participants