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

Add shutdown_timeout parameter #182

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 the runner checking for new jobs. The default value is 3. If set to 0 or lower, the default value is used.
Copy link
Member

Choose a reason for hiding this comment

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

This change does not appear in manifests/init.pp, maybe this change was not committed on your side.

CI ensure REFERENCE.md is up-to-date so both files should match. Please check your local repo, update your commits and push to update the PR.


Default value: `undef`

##### <a name="-gitlab_ci_runner--shutdown_timeout"></a>`shutdown_timeout`

Data type: `Optional[Integer]`

Number of seconds until the forceful shutdown operation times out and exits the process.

Default value: `undef`

Expand Down
34 changes: 18 additions & 16 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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":
Expand Down
49 changes: 26 additions & 23 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
# 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.
# @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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions spec/classes/gitlab_ci_runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Loading