Skip to content

Commit

Permalink
Merge pull request #91 from tuxmea/manage_check_interval
Browse files Browse the repository at this point in the history
Allow management of check_interval config setting
  • Loading branch information
bastelfreak authored Sep 15, 2020
2 parents cf023d0 + b022a0a commit 0c0f28b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ To use the Gitlab CI runners it is required to have the [puppetlabs/docker](http
```yaml
gitlab_ci_runner::concurrent: 4

gitlab_ci_runner::check_interval: 4

gitlab_ci_runner::metrics_server: "localhost:8888"

gitlab_ci_runner::manage_docker: true
Expand Down
9 changes: 9 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class gitlab_ci_runner::config (
$config_path = $gitlab_ci_runner::config_path,
$concurrent = $gitlab_ci_runner::concurrent,
$check_interval = $gitlab_ci_runner::check_interval,
$metrics_server = $gitlab_ci_runner::metrics_server,
$listen_address = $gitlab_ci_runner::listen_address,
$builds_dir = $gitlab_ci_runner::builds_dir,
Expand All @@ -28,6 +29,14 @@
}
}

if $check_interval {
file_line { 'gitlab-runner-check-interval':
path => $config_path,
line => "check_interval = ${check_interval}",
match => '^check_interval = \d+',
}
}

if $metrics_server {
file_line { 'gitlab-runner-metrics_server':
path => $config_path,
Expand Down
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# The name of the 'xz' package. Needed for local docker installations.
# @param concurrent
# Limits how many jobs globally can be run concurrently. The most upper limit of jobs using all defined runners. 0 does not mean unlimited!
# @param check_interval
# Integer which defines the interval length, in seconds, between new jobs check. If not set via Puppet the default value is 3; if set to 0 or lower, GitLab runner will use the default value.
# @param builds_dir
# Absolute path to a directory where builds will be stored in context of selected executor (Locally, Docker, SSH).
# @param cache_dir
Expand Down Expand Up @@ -49,6 +51,7 @@
Hash $runners = {},
Hash $runner_defaults = {},
Optional[Integer] $concurrent = undef,
Optional[Integer] $check_interval = undef,
Optional[String] $builds_dir = undef,
Optional[String] $cache_dir = undef,
Optional[Pattern[/.*:.+/]] $metrics_server = undef,
Expand Down
16 changes: 16 additions & 0 deletions spec/classes/gitlab_ci_runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
it { is_expected.to contain_file('/etc/gitlab-runner/config.toml') }

it { is_expected.not_to contain_file_line('gitlab-runner-concurrent') }
it { is_expected.not_to contain_file_line('gitlab-runner-check-interval') }
it { is_expected.not_to contain_file_line('gitlab-runner-metrics_server') }
it { is_expected.not_to contain_file_line('gitlab-runner-builds_dir') }
it { is_expected.not_to contain_file_line('gitlab-runner-cache_dir') }
Expand All @@ -58,6 +59,21 @@
'match' => '^concurrent = \d+')
end
end
context 'with check_interval => 10' do
let(:params) do
{
'runner_defaults' => {},
'runners' => {},
'check_interval' => 10
}
end

it do
is_expected.to contain_file_line('gitlab-runner-check-interval').with('path' => '/etc/gitlab-runner/config.toml',
'line' => 'check_interval = 10',
'match' => '^check_interval = \d+')
end
end
context 'with metrics_server => localhost:9252' do
let(:params) do
{
Expand Down

0 comments on commit 0c0f28b

Please sign in to comment.