Skip to content

Commit 633b362

Browse files
Axel von BertoldiPishel65itayf287
committed
Merge branch '3678/enable-check-interval' into 'main'
Ensure check_interval takes effect and eliminate race condition between fleet of runners See merge request https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/6081 Merged-by: Axel von Bertoldi <avonbertoldi@gitlab.com> Approved-by: Axel von Bertoldi <avonbertoldi@gitlab.com> Approved-by: Joe Burnett <jburnett@gitlab.com> Approved-by: Roshni Sarangadharan <rsarangadharan@gitlab.com> Approved-by: Igor <iwiedler@gitlab.com> Co-authored-by: Pishel65 <30761928-pishel65@users.noreply.gitlab.com> Co-authored-by: Pishel <fishel.itay@gmail.com>
2 parents ab12637 + c45c148 commit 633b362

3 files changed

Lines changed: 24 additions & 14 deletions

File tree

commands/multi.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,11 +1002,11 @@ func (mr *RunCommand) processBuildOnRunner(
10021002
mr.usageLoggerStore(common.UsageLogRecordFrom(runner, build))
10031003
}
10041004
}()
1005-
1006-
// Process the same runner by different worker again
1007-
// to speed up taking the builds
1008-
mr.requeueRunner(runner, runners)
1009-
1005+
if !runner.GetStrictCheckInterval() {
1006+
// Process the same runner by different worker again
1007+
// to speed up taking the builds
1008+
mr.requeueRunner(runner, runners)
1009+
}
10101010
// Process a build
10111011
return build.Run(mr.configfile.Config(), trace)
10121012
}

common/config.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,13 +1300,14 @@ type RunnerSettings struct {
13001300
}
13011301

13021302
type RunnerConfig struct {
1303-
Name string `toml:"name" json:"name" short:"name" long:"description" env:"RUNNER_NAME" description:"Runner name"`
1304-
Limit int `toml:"limit,omitzero" json:"limit" long:"limit" env:"RUNNER_LIMIT" description:"Maximum number of builds processed by this runner"`
1305-
OutputLimit int `toml:"output_limit,omitzero" long:"output-limit" env:"RUNNER_OUTPUT_LIMIT" description:"Maximum build trace size in kilobytes"`
1306-
RequestConcurrency int `toml:"request_concurrency,omitzero" long:"request-concurrency" env:"RUNNER_REQUEST_CONCURRENCY" description:"Maximum concurrency for job requests" jsonschema:"min=1"`
1307-
1308-
UnhealthyRequestsLimit int `toml:"unhealthy_requests_limit,omitzero" long:"unhealthy-requests-limit" env:"RUNNER_UNHEALTHY_REQUESTS_LIMIT" description:"The number of 'unhealthy' responses to new job requests after which a runner worker will be disabled"`
1309-
UnhealthyInterval *time.Duration `toml:"unhealthy_interval,omitzero" json:",omitempty" long:"unhealthy-interval" ENV:"RUNNER_UNHEALTHY_INTERVAL" description:"Duration for which a runner worker is disabled after exceeding the unhealthy requests limit. Supports syntax like '3600s', '1h30min' etc"`
1303+
Name string `toml:"name" json:"name" short:"name" long:"description" env:"RUNNER_NAME" description:"Runner name"`
1304+
Limit int `toml:"limit,omitzero" json:"limit" long:"limit" env:"RUNNER_LIMIT" description:"Maximum number of builds processed by this runner"`
1305+
OutputLimit int `toml:"output_limit,omitzero" long:"output-limit" env:"RUNNER_OUTPUT_LIMIT" description:"Maximum build trace size in kilobytes"`
1306+
RequestConcurrency int `toml:"request_concurrency,omitzero" long:"request-concurrency" env:"RUNNER_REQUEST_CONCURRENCY" description:"Maximum concurrency for job requests" jsonschema:"min=1"`
1307+
StrictCheckInterval *bool `toml:"strict_check_interval,omitzero" json:",omitempty" long:"strict-check-interval" env:"RUNNER_STRICT_CHECK_INTERVAL" description:"When you set StrictCheckInterval to true, the runner disables the faster-than-check_interval re-polling loop that occurs when a runner receives a job. Instead, the runner waits <check_interval> seconds before it polls again, even if additional jobs are available."`
1308+
1309+
UnhealthyRequestsLimit int `toml:"unhealthy_requests_limit,omitzero" long:"unhealthy-requests-limit" env:"RUNNER_UNHEALTHY_REQUESTS_LIMIT" description:"The number of unhealthy responses to new job requests after which a runner worker is turned off."`
1310+
UnhealthyInterval *time.Duration `toml:"unhealthy_interval,omitzero" json:",omitempty" long:"unhealthy-interval" ENV:"RUNNER_UNHEALTHY_INTERVAL" description:"Duration that the runner worker is turned off after it exceeds the unhealthy requests limit. Supports syntax like '3600s' and '1h30min'."`
13101311
JobStatusFinalUpdateRetryLimit int `toml:"job_status_final_update_retry_limit,omitzero" json:"job_status_final_update_retry_limit,omitzero" long:"job-status-final-update-retry-limit" env:"RUNNER_job_status_final_update_retry_limit" description:"The maximum number of times GitLab Runner can retry to push the final job status to the GitLab instance."`
13111312

13121313
SystemID string `toml:"-" json:",omitempty"`
@@ -2181,6 +2182,14 @@ func (c *RunnerConfig) GetRequestConcurrency() int {
21812182
return max(1, c.RequestConcurrency)
21822183
}
21832184

2185+
func (c *RunnerConfig) GetStrictCheckInterval() bool {
2186+
if c.StrictCheckInterval == nil {
2187+
return false
2188+
}
2189+
2190+
return *c.StrictCheckInterval
2191+
}
2192+
21842193
func (c *RunnerConfig) GetVariables() spec.Variables {
21852194
variables := spec.Variables{
21862195
{Key: "CI_RUNNER_SHORT_TOKEN", Value: c.ShortDescription(), Public: true, Internal: true, File: false},

docs/configuration/advanced-configuration.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ adding `-p 8093:8093` to your [`docker run` command](../install/docker.md).
339339
Each `[[runners]]` section defines one runner.
340340

341341
| Setting | Description |
342-
|---------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
342+
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
343343
| `name` | The runner's description. Informational only. |
344344
| `url` | GitLab instance URL. |
345345
| `token` | The runner's authentication token, which is obtained during runner registration. [Not the same as the registration token](https://docs.gitlab.com/api/runners/#registration-and-authentication-tokens). |
@@ -352,7 +352,8 @@ Each `[[runners]]` section defines one runner.
352352
| `builds_dir` | Absolute path to a directory where builds are stored in the context of the selected executor. For example, locally, Docker, or SSH. |
353353
| `cache_dir` | Absolute path to a directory where build caches are stored in context of selected executor. For example, locally, Docker, or SSH. If the `docker` executor is used, this directory needs to be included in its `volumes` parameter. |
354354
| `environment` | Append or overwrite environment variables. |
355-
| `request_concurrency` | Limit number of concurrent requests for new jobs from GitLab. Default is `1`. For more information about how `concurrency` , `limit`, and `request_concurrency` interact to control job flow, see the [KB article on GitLab Runner concurrency tuning](https://support.gitlab.com/hc/en-us/articles/21324350882076-GitLab-Runner-Concurrency-Tuning-Understanding-request-concurrency). |
355+
| `request_concurrency` | Limit number of concurrent requests for new jobs from GitLab. Default is `1`. For more information about how `concurrency` , `limit`, and `request_concurrency` interact to control job flow, see the [KB article on GitLab Runner concurrency tuning](https://support.gitlab.com/hc/en-us/articles/21324350882076-GitLab-Runner-Concurrency-Tuning-Understanding-request-concurrency). |
356+
| `strict_check_interval` | Under normal operation, when a runner polls for jobs and receives a job, it immediately re-polls for jobs until the number of jobs being processed matches `concurrent` or `limit`, or until no jobs are available. When you turn on `strict_check_interval`, the runner disables this faster-than-`check_interval` re-polling loop and strictly respects `check_interval`. Default is `false`. |
356357
| `output_limit` | Maximum build log size in kilobytes. Default is `4096` (4 MB). |
357358
| `pre_get_sources_script` | Commands to be executed on the runner before updating the Git repository and updating submodules. Use it to adjust the Git client configuration first, for example. To insert multiple commands, use a (triple-quoted) multi-line string or `\n` character. |
358359
| `post_get_sources_script` | Commands to be executed on the runner after updating the Git repository and updating submodules. To insert multiple commands, use a (triple-quoted) multi-line string or `\n` character. |

0 commit comments

Comments
 (0)