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

CFE-4244: Add the function name to the result cache key #5317

Merged
merged 2 commits into from
Sep 15, 2023

Conversation

amousset
Copy link
Contributor

@amousset amousset commented Sep 7, 2023

The function cache only used the args values as key, which in some cases could lead to mixing results from different functions with the same arguments.

Related to #5313.

libpromises/eval_context.c Fixed Show resolved Hide resolved
libpromises/eval_context.c Fixed Show fixed Hide fixed
libpromises/eval_context.c Fixed Show fixed Hide fixed
libpromises/eval_context.c Fixed Show fixed Hide fixed
@amousset amousset changed the title Add the function name to the result cache key CFE-4244: Add the function name to the result cache key Sep 7, 2023
libpromises/eval_context.c Fixed Show fixed Hide fixed
@larsewi larsewi self-requested a review September 8, 2023 07:49
@amousset amousset force-pushed the function-name-cache branch 2 times, most recently from 781663b to 4fbabae Compare September 11, 2023 13:01
@amousset
Copy link
Contributor Author

The acceptance test fails on Windows:

./01_vars/02_functions/cache_name.cf FAIL (UNEXPECTED FAILURE)

Maybe a difference in the way dns resolution is implemented. I will try to find a safer test case.

@larsewi
Copy link
Contributor

larsewi commented Sep 13, 2023

Tried a third attempt to create an acceptance test. Let me know what you think @amousset

----------------------------------------------------------------------
./01_vars/02_functions/cache_name.cf 
----------------------------------------------------------------------
R: test description: Test that the function result cache checks function name
R: /home/vagrant/core/tests/acceptance/./01_vars/02_functions/cache_name.cf Pass
R: res1!=res2 -> 'cfengine.com'!='cfengine_com'

Return code is 0.

  ==> Pass

@larsewi
Copy link
Contributor

larsewi commented Sep 13, 2023

@amousset, let me know if you agree with the changes I made :)

@larsewi larsewi added the cherry-pick? Fixes which may need to be cherry-picked to LTS branches label Sep 13, 2023
@amousset
Copy link
Contributor Author

Looks good 👍

The function cache only used the args values, which in some cases could
lead to mixing results from different functions with the same arguments.

Ticket: CFE-4244
Changelog: Cashed policy function results now take into account number of arguments and function name.
Signed-off-by: Lars Erik Wik <[email protected]>
Co-authored-by: Alexis Mousset <[email protected]>
@larsewi
Copy link
Contributor

larsewi commented Sep 13, 2023

Squashed the commits. Please ACK if you agree with the results @amousset :)

@amousset
Copy link
Contributor Author

Please ACK if you agree with the results @amousset :)

yes 👍

@larsewi
Copy link
Contributor

larsewi commented Sep 14, 2023

@cf-bottom can you run this through Jenkins please?

@cf-bottom
Copy link

larsewi
larsewi previously approved these changes Sep 14, 2023
Copy link
Contributor

@larsewi larsewi left a comment

Choose a reason for hiding this comment

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

Thanks! Let's wait for CI to approve

Two reasons for this:
 1. CONTRIBUTING.md says to do this at the top
 2. the `ctx` argument was actually used before the assert

Ticket: None
Changelog: None
Signed-off-by: Lars Erik Wik <[email protected]>
Copy link
Contributor

@vpodzime vpodzime left a comment

Choose a reason for hiding this comment

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

ACK

@larsewi larsewi merged commit 4eb6a9d into cfengine:master Sep 15, 2023
12 of 13 checks passed
@larsewi
Copy link
Contributor

larsewi commented Sep 15, 2023

Thanks for your contribution @amousset 🚀

@larsewi larsewi removed the cherry-pick? Fixes which may need to be cherry-picked to LTS branches label Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants