Skip to content

Commit

Permalink
Cache refresh fix (#381)
Browse files Browse the repository at this point in the history
* Changes for shaping traffic to api server

* Added delay for cache refresh

* updated variable name and removed redundant conversion

* Updated cache refresh delay variable name
  • Loading branch information
gizmo-rt authored Dec 13, 2021
1 parent ea75372 commit ed9f44d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class EnhanceK8sMetadataFilter < Fluent::Plugin::Filter
config_param :cache_ttl, :integer, default: 60 * 60 * 2
config_param :cache_refresh, :integer, default: 60 * 60
config_param :cache_refresh_variation, :integer, default: 60 * 15
config_param :cache_refresh_apiserver_request_delay, :float, default: Float::NAN

def configure(conf)
super
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def refresh_cache
entries.each { |key, _|
begin
refresh_cache_entry(key)
# Adding friction to avoid aggressive refresh.
if !@cache_refresh_apiserver_request_delay.nan? && !@cache_refresh_apiserver_request_delay.negative?
sleep @cache_refresh_apiserver_request_delay
end
rescue => e
log.error "Cannot refresh metadata for key #{key}: #{e}"
end
Expand Down

0 comments on commit ed9f44d

Please sign in to comment.