| Puppet's environment cache has several methods for evicting an environment, but they do not mutate the cache in a consistent way: 1. Whenever an environment is requested, we evict all environments that are now expired, but the evict_if_expired 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. The clear_all method does not notify the cache_expiration_service that it evicted all of the environments. This could lead to puppetserver holding onto environment names unnecessarily. The method also does not clear environment related settings (for each environment). 3. The clear method does not remove the environment entry from the @expirations sorted set, it doesn't recalculate the @next_expiration time, or clear the enviroment related settings. The clear_all and clear methods do not appear to be used in puppet, as it was decided earlier to only support a REST API for cache eviction. So we might want to remove clear_all and clear to avoid confusion. |