diff --git a/REFERENCE.md b/REFERENCE.md index 24dd6c3..5f85a5e 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -76,6 +76,7 @@ The following parameters are available in the `gitlab_ci_runner` class: * [`log_level`](#-gitlab_ci_runner--log_level) * [`log_format`](#-gitlab_ci_runner--log_format) * [`check_interval`](#-gitlab_ci_runner--check_interval) +* [`shutdown_timeout`](#-gitlab_ci_runner--shutdown_timeout) * [`sentry_dsn`](#-gitlab_ci_runner--sentry_dsn) * [`listen_address`](#-gitlab_ci_runner--listen_address) * [`session_server`](#-gitlab_ci_runner--session_server) @@ -145,7 +146,15 @@ Default value: `undef` Data type: `Optional[Integer]` -defines the interval length, in seconds, between new jobs check. The default value is 3; if set to 0 or lower, the default value will be used. +Defines the interval length, in seconds, between new jobs check. The default value is 3; if set to 0 or lower, the default value will be used. + +Default value: `undef` + +##### `shutdown_timeout` + +Data type: `Optional[Integer]` + +Number of seconds until the forceful shutdown operation times out and exits the process. Default value: `undef` diff --git a/manifests/config.pp b/manifests/config.pp index 8726cbc..d4c8c92 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -3,20 +3,21 @@ # @api private # class gitlab_ci_runner::config ( - $config_path = $gitlab_ci_runner::config_path, + $config_path = $gitlab_ci_runner::config_path, $config_owner = $gitlab_ci_runner::config_owner, $config_group = $gitlab_ci_runner::config_group, $config_mode = $gitlab_ci_runner::config_mode, $manage_config_dir = $gitlab_ci_runner::manage_config_dir, $config_dir_mode = $gitlab_ci_runner::config_dir_mode, - $concurrent = $gitlab_ci_runner::concurrent, - $log_level = $gitlab_ci_runner::log_level, - $log_format = $gitlab_ci_runner::log_format, - $check_interval = $gitlab_ci_runner::check_interval, - $sentry_dsn = $gitlab_ci_runner::sentry_dsn, - $session_server = $gitlab_ci_runner::session_server, - $listen_address = $gitlab_ci_runner::listen_address, - $package_name = $gitlab_ci_runner::package_name, + $concurrent = $gitlab_ci_runner::concurrent, + $log_level = $gitlab_ci_runner::log_level, + $log_format = $gitlab_ci_runner::log_format, + $check_interval = $gitlab_ci_runner::check_interval, + $shutdown_timeout = $gitlab_ci_runner::shutdown_timeout, + $sentry_dsn = $gitlab_ci_runner::sentry_dsn, + $session_server = $gitlab_ci_runner::session_server, + $listen_address = $gitlab_ci_runner::listen_address, + $package_name = $gitlab_ci_runner::package_name, ) { assert_private() @@ -29,13 +30,14 @@ } $global_options = { - concurrent => $concurrent, - log_level => $log_level, - log_format => $log_format, - check_interval => $check_interval, - sentry_dsn => $sentry_dsn, - session_server => $session_server, - listen_address => $listen_address, + concurrent => $concurrent, + log_level => $log_level, + log_format => $log_format, + check_interval => $check_interval, + shutdown_timeout => $shutdown_timeout, + sentry_dsn => $sentry_dsn, + session_server => $session_server, + listen_address => $listen_address, }.filter |$key, $val| { $val =~ NotUndef } concat::fragment { "${config_path} - header": diff --git a/manifests/init.pp b/manifests/init.pp index b77c2ef..dc58275 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -24,7 +24,9 @@ # @param log_format # Log format (options: runner, text, json). Note that this setting has lower priority than format set by command line argument --log-format # @param check_interval -# defines the interval length, in seconds, between new jobs check. The default value is 3; if set to 0 or lower, the default value will be used. +# Defines the interval length, in seconds, between new jobs check. The default value is 3; if set to 0 or lower, the default value will be used. +# @param shutdown_timeout +# Number of seconds until the forceful shutdown operation times out and exits the process. # @param sentry_dsn # Enable tracking of all system level errors to sentry. # @param listen_address @@ -77,30 +79,31 @@ # class gitlab_ci_runner ( String $xz_package_name, # Defaults in module hieradata - Hash $runners = {}, - Hash $runner_defaults = {}, - Optional[Integer] $concurrent = undef, - Optional[Gitlab_ci_runner::Log_level] $log_level = undef, - Optional[Gitlab_ci_runner::Log_format] $log_format = undef, - Optional[Integer] $check_interval = undef, - Optional[String] $sentry_dsn = undef, - Optional[Pattern[/.*:.+/]] $listen_address = undef, - Optional[Gitlab_ci_runner::Session_server] $session_server = undef, - Boolean $manage_docker = false, - Boolean $manage_repo = true, - String $package_ensure = installed, - String $package_name = 'gitlab-runner', - Stdlib::HTTPUrl $repo_base_url = 'https://packages.gitlab.com', - Optional[Gitlab_ci_runner::Keyserver] $repo_keyserver = undef, - String $config_path = '/etc/gitlab-runner/config.toml', - String[1] $config_owner = 'root', - String[1] $config_group = 'root', - Stdlib::Filemode $config_mode = '0444', + Hash $runners = {}, + Hash $runner_defaults = {}, + Optional[Integer] $concurrent = undef, + Optional[Gitlab_ci_runner::Log_level] $log_level = undef, + Optional[Gitlab_ci_runner::Log_format] $log_format = undef, + Optional[Integer] $check_interval = undef, + Optional[Integer] $shutdown_timeout = undef, + Optional[String] $sentry_dsn = undef, + Optional[Pattern[/.*:.+/]] $listen_address = undef, + Optional[Gitlab_ci_runner::Session_server] $session_server = undef, + Boolean $manage_docker = false, + Boolean $manage_repo = true, + String $package_ensure = installed, + String $package_name = 'gitlab-runner', + Stdlib::HTTPUrl $repo_base_url = 'https://packages.gitlab.com', + Optional[Gitlab_ci_runner::Keyserver] $repo_keyserver = undef, + String $config_path = '/etc/gitlab-runner/config.toml', + String[1] $config_owner = 'root', + String[1] $config_group = 'root', + Stdlib::Filemode $config_mode = '0444', Boolean $manage_config_dir = false, - Optional[Stdlib::Filemode] $config_dir_mode = undef, - Optional[Stdlib::HTTPUrl] $http_proxy = undef, - Optional[Stdlib::Unixpath] $ca_file = undef, - Stdlib::HTTPSUrl $repo_keysource = "${repo_base_url}/gpg.key", + Optional[Stdlib::Filemode] $config_dir_mode = undef, + Optional[Stdlib::HTTPUrl] $http_proxy = undef, + Optional[Stdlib::Unixpath] $ca_file = undef, + Stdlib::HTTPSUrl $repo_keysource = "${repo_base_url}/gpg.key", ) { if $manage_docker { # workaround for cirunner issue #1617 diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb index 60a0296..168c664 100644 --- a/spec/acceptance/class_spec.rb +++ b/spec/acceptance/class_spec.rb @@ -91,6 +91,22 @@ class { 'gitlab_ci_runner': end end + context 'shutdown_timeout => 22' do + it_behaves_like 'an idempotent resource' do + let(:manifest) do + <<-EOS + class { 'gitlab_ci_runner': + shutdown_timeout => 22, + } + EOS + end + end + + describe file('/etc/gitlab-runner/config.toml') do + it { is_expected.to contain 'shutdown_timeout = 22' } + end + end + context 'sentry_dsn => https://123abc@localhost/1' do it_behaves_like 'an idempotent resource' do let(:manifest) do diff --git a/spec/classes/gitlab_ci_runner_spec.rb b/spec/classes/gitlab_ci_runner_spec.rb index 1427b77..ddd778c 100644 --- a/spec/classes/gitlab_ci_runner_spec.rb +++ b/spec/classes/gitlab_ci_runner_spec.rb @@ -229,6 +229,23 @@ end end + context 'with shutdown_timeout => 4' do + let(:params) do + { + 'shutdown_timeout' => 4 + } + end + + it do + is_expected.to contain_concat__fragment('/etc/gitlab-runner/config.toml - global options'). + with( + target: '/etc/gitlab-runner/config.toml', + order: 1, + content: %r{shutdown_timeout = 4} + ) + end + end + context 'with sentry_dsn => https://123abc@localhost/1' do let(:params) do {