From 0b8ca269cb7d966818bcdaee8b0b112d492b7e51 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 22 Mar 2022 09:35:53 +0900 Subject: [PATCH] Support more [execution_expiration_policy] parameters Change-Id: I3fb67451dea1a9834002a466e4bc206869527fbb --- manifests/engine.pp | 27 +++++---- manifests/execution_expiration_policy.pp | 50 ++++++++++++++++ ...on_expiration_policy-d0e9ebbd2e3b8c76.yaml | 13 +++++ ...istral_execution_expiration_policy_spec.rb | 58 +++++++++++++++++++ 4 files changed, 138 insertions(+), 10 deletions(-) create mode 100644 manifests/execution_expiration_policy.pp create mode 100644 releasenotes/notes/execution_expiration_policy-d0e9ebbd2e3b8c76.yaml create mode 100644 spec/classes/mistral_execution_expiration_policy_spec.rb diff --git a/manifests/engine.pp b/manifests/engine.pp index 4fab942..a8316f4 100644 --- a/manifests/engine.pp +++ b/manifests/engine.pp @@ -52,11 +52,13 @@ # (Optional) Enables startin subworkflows via RPC. # Defaults to $::os_service_default. # +# DEPRECATED PARAMETERS +# # [*evaluation_interval*] # (Optional) How often will the executions be evaluated # (in minutes). For example for value 120 the interval # will be 2 hours (every 2 hours). -# Defaults to $::os_service_default. +# Defaults to undef. # # [*older_than*] # (Optional) Evaluate from which time remove executions in minutes. @@ -64,7 +66,7 @@ # that finished a 60 minutes ago or more. # Minimum value is 1. # Note that only final state execution will remove (SUCCESS/ERROR). -# Defaults to $::os_service_default. +# Defaults to undef. # class mistral::engine ( $package_ensure = present, @@ -78,13 +80,24 @@ class mistral::engine ( $execution_integrity_check_batch_size = $::os_service_default, $action_definition_cache_time = $::os_service_default, $start_subworkflows_via_rpc = $::os_service_default, - $evaluation_interval = $::os_service_default, - $older_than = $::os_service_default, + # DEPRECATED PARAMETERS + $evaluation_interval = undef, + $older_than = undef, ) { include mistral::deps include mistral::params + if $evaluation_interval != undef { + warning('The mistral::engine::evaluation_interval parameter is deprecated. \ +Use the mistral::execution_expiration_policy class instead.') + } + if $older_than != undef { + warning('The mistral::engine::older_than parameter is deprecated. \ +Use the mistral::execution_expiration_policy class instead.') + } + include mistral::execution_expiration_policy + package { 'mistral-engine': ensure => $package_ensure, name => $::mistral::params::engine_package_name, @@ -118,10 +131,4 @@ class mistral::engine ( 'engine/action_definition_cache_time': value => $action_definition_cache_time; 'engine/start_subworkflows_via_rpc': value => $start_subworkflows_via_rpc; } - - mistral_config { - 'execution_expiration_policy/evaluation_interval': value => $evaluation_interval; - 'execution_expiration_policy/older_than': value => $older_than; - } - } diff --git a/manifests/execution_expiration_policy.pp b/manifests/execution_expiration_policy.pp new file mode 100644 index 0000000..1777dbb --- /dev/null +++ b/manifests/execution_expiration_policy.pp @@ -0,0 +1,50 @@ +# == Class: mistral::execution_expiration_policy +# +# Configure the mistral execution_expiration_policy +# +# === Parameters +# +# [*evaluation_interval*] +# (Optional) How often will the executions be evaluated (in minutes). +# Defaults to $::os_service_default. +# +# [*older_than*] +# (Optional) Evaluate from which time remove executions in minutes. +# Note that only final state execution will remove (SUCCESS/ERROR). +# Defaults to $::os_service_default. +# +# [*max_finished_executions*] +# (Optional) THe maximum nuber of finised workflow executions to be stored. +# Defaults to $::os_service_default. +# +# [*batch_size*] +# (Optional) Size of batch of expired executions to be deleted. +# Defaults to $::os_service_default. +# +# [*ignored_states*] +# (Optional) THe states that the expiration policy will filter out and will +# not delete. +# Defaults to $::os_service_default. +# +class mistral::execution_expiration_policy ( + $evaluation_interval = $::os_service_default, + $older_than = $::os_service_default, + $max_finished_executions = $::os_service_default, + $batch_size = $::os_service_default, + $ignored_states = $::os_service_default, +) { + + include mistral::deps + include mistral::params + + $evaluation_interval_real = pick($::mistral::engine::evaluation_interval, $evaluation_interval) + $older_than_real = pick($::mistral::engine::older_than, $older_than) + + mistral_config { + 'execution_expiration_policy/evaluation_interval': value => $evaluation_interval_real; + 'execution_expiration_policy/older_than': value => $older_than_real; + 'execution_expiration_policy/max_finished_executions': value => $max_finished_executions; + 'execution_expiration_policy/batch_size': value => $batch_size; + 'execution_expiration_policy/ignored_states': value => join(any2array($ignored_states), ','); + } +} diff --git a/releasenotes/notes/execution_expiration_policy-d0e9ebbd2e3b8c76.yaml b/releasenotes/notes/execution_expiration_policy-d0e9ebbd2e3b8c76.yaml new file mode 100644 index 0000000..db572ea --- /dev/null +++ b/releasenotes/notes/execution_expiration_policy-d0e9ebbd2e3b8c76.yaml @@ -0,0 +1,13 @@ +--- +features: + - | + The new ``mistral::execution_expiration_policy`` class has been added. + +deprecations: + - | + The following parameters of the ``mistral::engine`` class have been + deprecated in favor of the new ``mistral::execution_expiration_policy`` + class. + + - ``evaluation_interval`` + - ``older_than`` diff --git a/spec/classes/mistral_execution_expiration_policy_spec.rb b/spec/classes/mistral_execution_expiration_policy_spec.rb new file mode 100644 index 0000000..78f06f1 --- /dev/null +++ b/spec/classes/mistral_execution_expiration_policy_spec.rb @@ -0,0 +1,58 @@ +require 'spec_helper' + +describe 'mistral::execution_expiration_policy' do + + shared_examples_for 'mistral::execution_expiration_policy' do + context 'with defaults' do + it 'configures execution_expiration_policy parameters' do + is_expected.to contain_mistral_config('execution_expiration_policy/evaluation_interval')\ + .with_value('') + is_expected.to contain_mistral_config('execution_expiration_policy/older_than')\ + .with_value('') + is_expected.to contain_mistral_config('execution_expiration_policy/max_finished_executions')\ + .with_value('') + is_expected.to contain_mistral_config('execution_expiration_policy/batch_size')\ + .with_value('') + is_expected.to contain_mistral_config('execution_expiration_policy/ignored_states')\ + .with_value('') + end + end + + context 'with specific parameters' do + let :params do + { + :evaluation_interval => 120, + :older_than => 1, + :max_finished_executions => 0, + :batch_size => 10, + :ignored_states => ['SUCCESS', 'ERROR', 'CANCELLED'] + } + end + + it 'configures execution_expiration_policy parameters' do + is_expected.to contain_mistral_config('execution_expiration_policy/evaluation_interval')\ + .with_value(120) + is_expected.to contain_mistral_config('execution_expiration_policy/older_than')\ + .with_value(1) + is_expected.to contain_mistral_config('execution_expiration_policy/max_finished_executions')\ + .with_value(0) + is_expected.to contain_mistral_config('execution_expiration_policy/batch_size')\ + .with_value(10) + is_expected.to contain_mistral_config('execution_expiration_policy/ignored_states')\ + .with_value('SUCCESS,ERROR,CANCELLED') + end + end + end + + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge!(OSDefaults.get_facts()) + end + + it_configures 'mistral::execution_expiration_policy' + end + end +end