-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
(maint) Compare Environment#name in compiler #9136
Conversation
This is an attempt to resolve support request PE-36986 , a quick review would be appreciated but I want to wait until we hear back from the customer before merging. |
In theory, the puppet/lib/puppet/node/environment.rb Lines 538 to 549 in e177633
So it should be possible to check if two environment objects have the same value. But the check depends on the That said, I think comparing environment names is correct, since all we care about is whether the agent's requested environment matches the server-specified environment (based on classification rules). Tangent 1: It seems strange that we're using
We're probably relying on that in various places, but it seems like a footgun. Tangent 2: In theory, cached environment names should always be symbols, but it wasn't always the case https://puppet.atlassian.net/browse/PUP-10955. |
@joshcooper great callout about overriding |
Yeah I'm pretty something is relying on being able to compare real |
4fd5622
to
27f118b
Compare
Heard back from @vchepkov and it looks like this is working so far. Even if it does turn out not to be the solution to his problem I think it is still a legit bug that should be fixed and doesn't appear to cause regressions. I've updated the comment and commit message based on Josh's comments. I think this is ready to go now. |
LGTM, could you add/update a test around here so that different |
During catalog compilation, after loading the requested environment we load the node and server specified environment. Previously, We would then compare the Environment objects to determine if the requested environment matched the server specified environment. However, if the environment cache is flushed between those two environments being loaded they could be different object instances representing the same desired environment. Environment objects define a `==` method but require the name and modulepath to be the same. If we are running with versioned environment dirs those modulepaths may be different (ie different versions of the same environment). To resolve this race condition we now check the environment names (Environment#name canoncalizes to symbols to avoid symbol/string mismatch). The catalog already uses the server specified environment which, if we are running with versioned environment dirs and have different versions of the same environment, will be the most up to date version of the environment.
27f118b
to
f2866d1
Compare
Thanks, Josh! I've added a test now. (fwiw, I've also changed the comparison back to checking instances and saw the test fail) |
FYI, running this patch since October, 26th, issues with empty catalog hasn't reoccured since |
I think this is waiting on an approval from @puppetlabs/phoenix , let me know if there's something else I can or should do! |
During catalog compilation, after loading the requested environment we load the node and server specified environment. Previously, We would then compare the Environment objects to determine if the requested environment matched the server specified environment. However, if the environment cache is flushed between those two environments being loaded they could be different object instances representing the same desired environment.
To resolve this race condition we now check the environment names (Environment#name canoncalizes to symbols to avoid symbol/string mismatch).