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

Fixes #20626 - Periodic execution plan cleaner #37

Merged
merged 4 commits into from Aug 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/settings.yml.example
Expand Up @@ -39,3 +39,7 @@

# Log level, one of UNKNOWN, FATAL, ERROR, WARN, INFO, DEBUG
# :log_level: ERROR

# Maximum age of execution plans to keep before having them cleaned
# by the execution plan cleaner (in seconds), defaults to 24 hours
# :execution_plan_cleaner_age: 86400
9 changes: 9 additions & 0 deletions lib/smart_proxy_dynflow_core/core.rb
Expand Up @@ -42,6 +42,7 @@ def default_world_config
config.auto_rescue = true
config.logger_adapter = logger_adapter
config.persistence_adapter = persistence_adapter
config.execution_plan_cleaner = execution_plan_cleaner
yield config if block_given?
end
end
Expand All @@ -54,6 +55,14 @@ def logger_adapter
end
end

def execution_plan_cleaner
proc do |world|
age = Settings.instance.execution_plan_cleaner_age
options = { :poll_interval => age, :max_age => age }
::Dynflow::Actors::ExecutionPlanCleaner.new(world, options)
end
end

class << self
attr_reader :instance

Expand Down
4 changes: 3 additions & 1 deletion lib/smart_proxy_dynflow_core/settings.rb
Expand Up @@ -40,13 +40,15 @@ class Settings < OpenStruct
:plugins => {},
:pid_file => '/var/run/foreman-proxy/smart_proxy_dynflow_core.pid',
:daemonize => false,
:execution_plan_cleaner_age => 60 * 60 * 24,
Copy link
Member

Choose a reason for hiding this comment

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

You need to add this also to PLUGIN_SETTINGS for the code to properly load the data from settings

:loaded => false
}

PROXY_SETTINGS = [:ssl_ca_file, :ssl_certificate, :ssl_private_key, :foreman_url,
:foreman_ssl_ca, :foreman_ssl_cert, :foreman_ssl_key,
:log_file, :log_level, :ssl_disabled_ciphers]
PLUGIN_SETTINGS = [:database, :core_url, :console_auth]
PLUGIN_SETTINGS = [:database, :core_url, :console_auth,
:execution_plan_cleaner_age]

def initialize(settings = {})
super(DEFAULT_SETTINGS.merge(settings))
Expand Down
1 change: 1 addition & 0 deletions lib/smart_proxy_dynflow_core/testing.rb
Expand Up @@ -16,6 +16,7 @@ def create_world(&block)
config.exit_on_terminate = false
config.auto_terminate = false
config.logger_adapter = ::Dynflow::LoggerAdapters::Simple.new $stderr, DYNFLOW_TESTING_LOG_LEVEL
config.execution_plan_cleaner = nil
block.call(config) if block
end
end
Expand Down
2 changes: 1 addition & 1 deletion smart_proxy_dynflow_core.gemspec
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |gem|
gem.add_development_dependency('rubocop', '0.32.1')

gem.add_runtime_dependency('foreman-tasks-core', '>= 0.1')
gem.add_runtime_dependency('dynflow', "~> 0.8.4")
gem.add_runtime_dependency('dynflow', "~> 0.8.27")
gem.add_runtime_dependency('sequel')
gem.add_runtime_dependency('sqlite3')
gem.add_runtime_dependency('sinatra', '~> 1.4')
Expand Down