Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
None
-
Coremunity
-
Platform Core KANBAN
-
Needs Assessment
-
Bug Fix
-
-
Needs Assessment
Description
Puppet's environment cache has three methods for evicting a single expired environment, all expired environments, or all environments, but they don't mutate the cache in a consistent way:
1. Whenever Puppet::Environments::Cached#get_conf(name) is called to lookup the EnvironmentConf for an environment, we clear that environment if it is now expired via evict_if_expired(name), but the method doesn't update the @next_expiration instance variable. As a result, the optimization in clear_all_evicted may cause us to call the cache_expiration_service.expired?(name.to_sym twice.
2. Whenever Puppet::Environments::Cached#get(name) is called, we clear all environments that are now expired via clear_all_expired. This method updates the cache consistently.
3. Whenever Puppet::Environments::Cached#clear_all is called, the cache_expiration_service is never notified of the eviction, which could lead to puppetserver holding onto environment names in memory. The method also does not clear environment related settings (for each environment). So anyone calling `Puppet[:rich_data]` for example could "see" the value from the now evicted environment. The clear_all method is used when Puppet[:rich_data] is set and also in unit tests.
4. The Puppet::Environments::Cached#clear method does not remove the environment entry from the @expirations sorted set and doesn't recalculate the @next_expiration time, or clear the enviroment related settings. The clear methods does not appear to be used in puppet, as it was decided earlier to only support a REST API for cache eviction.
Attachments
Issue Links
- relates to
-
PUP-10780 Optimize environment cache eviction
-
- Closed
-