Skip to content

Commit 90444f1

Browse files
committed
made the jobs queue bufferSize configurable
1 parent 9212e2c commit 90444f1

File tree

6 files changed

+49
-5
lines changed

6 files changed

+49
-5
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,30 @@ and this project adheres to [0ver](https://0ver.org) (more or less).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- new metrics:
13+
- `gitlab_ci_pipeline_test_report_total_time` -> Duration in seconds of all the tests in the most recently finished pipeline
14+
- `gitlab_ci_pipeline_test_report_total_count` -> Number of total tests in the most recently finished pipeline
15+
- `gitlab_ci_pipeline_test_report_success_count` -> Number of successful tests in the most recently finished pipeline
16+
- `gitlab_ci_pipeline_test_report_failed_count` -> Number of failed tests in the most recently finished pipeline
17+
- `gitlab_ci_pipeline_test_report_skipped_count` -> Number of skipped tests in the most recently finished pipeline
18+
- `gitlab_ci_pipeline_test_report_error_count` -> Number of errored tests in the most recently finished pipeline
19+
- `gitlab_ci_pipeline_test_suite_total_time` -> Duration in seconds for the test suite
20+
- `gitlab_ci_pipeline_test_suite_total_count` -> Number of total tests for the test suite
21+
- `gitlab_ci_pipeline_test_suite_success_count` -> Number of successful tests for the test suite
22+
- `gitlab_ci_pipeline_test_suite_failed_count` -> Number of failed tests for the test suite
23+
- `gitlab_ci_pipeline_test_suite_skipped_count` -> Number of skipped tests for the test suite
24+
- `gitlab_ci_pipeline_test_suite_error_count` -> Duration in errored tests for the test suite
25+
- new configuration parameter: `gitlab.burstable_requests_per_second`, introducing a burstable amount of API RPS
26+
- new configuration parameter: `gitlab.maximum_jobs_queue_size`, controlling the queue buffer size
27+
28+
### Changed
29+
30+
- Upgraded golang to **v1.20**
31+
- Upgraded most dependencies to their latest versions
32+
- Reduced the amount of data being pulled from the project list API calls
33+
1034
## [v0.5.4] - 2022-08-25
1135

1236
### Added

docs/configuration_syntax.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ gitlab:
9494
# (optional, default: 5)
9595
burstable_requests_per_second: 5
9696

97+
# Maximum amount of jobs to keep queue, if this limit is reached
98+
# newly created ones will get dropped. As a best practice you should not change this value.
99+
# Workarounds to avoid hitting the limit are:
100+
# - increase polling intervals
101+
# - increase API rate limit
102+
# - reduce the amount of projects, refs, environments or metrics you are looking into
103+
# - leverage webhooks instead of polling schedules
104+
#
105+
# (optional, default: 1000)
106+
maximum_jobs_queue_size: 1000
107+
97108
pull:
98109
projects_from_wildcards:
99110
# Whether to trigger a discovery or not when the

pkg/config/config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ type Gitlab struct {
114114

115115
// Burstable limit for the GitLab API requests/sec
116116
BurstableRequestsPerSecond int `default:"5" validate:"gte=1" yaml:"burstable_requests_per_second"`
117+
118+
// Maximum amount of jobs to keep queue, if this limit is reached
119+
// newly created ones will get dropped. As a best practice you should not change this value.
120+
// Workarounds to avoid hitting the limit are:
121+
// - increase polling intervals
122+
// - increase API rate limit
123+
// - reduce the amount of projects, refs, environments or metrics you are looking into
124+
// - leverage webhooks instead of polling schedules
125+
//
126+
MaximumJobsQueueSize int `default:"1000" validate:"gte=10" yaml:"maximum_jobs_queue_size"`
117127
}
118128

119129
// Redis ..

pkg/config/config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func TestNew(t *testing.T) {
2424
c.Gitlab.EnableTLSVerify = true
2525
c.Gitlab.MaximumRequestsPerSecond = 1
2626
c.Gitlab.BurstableRequestsPerSecond = 5
27+
c.Gitlab.MaximumJobsQueueSize = 1000
2728

2829
c.Pull.ProjectsFromWildcards.OnInit = true
2930
c.Pull.ProjectsFromWildcards.Scheduled = true

pkg/controller/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func New(ctx context.Context, cfg config.Config, version string) (c Controller,
5252
return
5353
}
5454

55-
c.TaskController = NewTaskController(ctx, c.Redis)
55+
c.TaskController = NewTaskController(ctx, c.Redis, cfg.Gitlab.MaximumJobsQueueSize)
5656
c.registerTasks()
5757

5858
c.Store = store.New(ctx, c.Redis, c.Config.Projects)

pkg/controller/scheduler.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import (
1919
"github.com/mvisonneau/gitlab-ci-pipelines-exporter/pkg/store"
2020
)
2121

22-
const bufferSize = 1000
23-
2422
// TaskController holds task related clients.
2523
type TaskController struct {
2624
Factory taskq.Factory
@@ -30,7 +28,7 @@ type TaskController struct {
3028
}
3129

3230
// NewTaskController initializes and returns a new TaskController object.
33-
func NewTaskController(ctx context.Context, r *redis.Client) (t TaskController) {
31+
func NewTaskController(ctx context.Context, r *redis.Client, maximumJobsQueueSize int) (t TaskController) {
3432
ctx, span := otel.Tracer(tracerName).Start(ctx, "controller:NewTaskController")
3533
defer span.End()
3634

@@ -40,7 +38,7 @@ func NewTaskController(ctx context.Context, r *redis.Client) (t TaskController)
4038
Name: "default",
4139
PauseErrorsThreshold: 3,
4240
Handler: t.TaskMap,
43-
BufferSize: bufferSize,
41+
BufferSize: maximumJobsQueueSize,
4442
}
4543

4644
if r != nil {

0 commit comments

Comments
 (0)