Skip to content

Commit efca2d9

Browse files
Release - RC1 (#74)
* Improve unit tests * Implementer beter management for redis * Fix test unit * Bump docker/login-action from 3.4.0 to 3.5.0 (#80) Bumps [docker/login-action](https://github.com/docker/login-action) from 3.4.0 to 3.5.0. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](docker/login-action@74a5d14...184bdaa) --- updated-dependencies: - dependency-name: docker/login-action dependency-version: 3.5.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump step-security/harden-runner from 2.12.1 to 2.13.0 (#78) Bumps [step-security/harden-runner](https://github.com/step-security/harden-runner) from 2.12.1 to 2.13.0. - [Release notes](https://github.com/step-security/harden-runner/releases) - [Commits](step-security/harden-runner@v2.12.1...ec9f2d5) --- updated-dependencies: - dependency-name: step-security/harden-runner dependency-version: 2.13.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump github/codeql-action from 3.29.0 to 3.29.9 (#77) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.29.0 to 3.29.9. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@ce28f5b...df55935) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.29.9 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump gitlab.com/gitlab-org/api/client-go from 0.138.0 to 0.139.2 (#75) Bumps [gitlab.com/gitlab-org/api/client-go](https://gitlab.com/gitlab-org/api/client-go) from 0.138.0 to 0.139.2. - [Release notes](https://gitlab.com/gitlab-org/api/client-go/tags) - [Changelog](https://gitlab.com/gitlab-org/api/client-go/blob/main/CHANGELOG.md) - [Commits](https://gitlab.com/gitlab-org/api/client-go/compare/v0.138.0...v0.139.2) --- updated-dependencies: - dependency-name: gitlab.com/gitlab-org/api/client-go dependency-version: 0.139.2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump anchore/sbom-action from 0.20.4 to 0.20.5 (#76) Bumps [anchore/sbom-action](https://github.com/anchore/sbom-action) from 0.20.4 to 0.20.5. - [Release notes](https://github.com/anchore/sbom-action/releases) - [Changelog](https://github.com/anchore/sbom-action/blob/main/RELEASE.md) - [Commits](anchore/sbom-action@v0.20.4...v0.20.5) --- updated-dependencies: - dependency-name: anchore/sbom-action dependency-version: 0.20.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump goreleaser/goreleaser-action from 6.3.0 to 6.4.0 (#79) Bumps [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action) from 6.3.0 to 6.4.0. - [Release notes](https://github.com/goreleaser/goreleaser-action/releases) - [Commits](goreleaser/goreleaser-action@9c156ee...e435ccd) --- updated-dependencies: - dependency-name: goreleaser/goreleaser-action dependency-version: 6.4.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Support rc releases * Fix regex * Improve tag regex match * Fix - Github action does not support full regex so lets do a trick * test - only test what is matter * Update dashboard --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent a77651b commit efca2d9

File tree

22 files changed

+525
-144
lines changed

22 files changed

+525
-144
lines changed

.github/workflows/codeql.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ jobs:
5959
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
6060
steps:
6161
- name: Harden the runner (Audit all outbound calls)
62-
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
62+
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
6363
with:
6464
egress-policy: audit
6565

6666
- name: Checkout repository
67-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
67+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
6868

6969
# Add any setup steps before running the `github/codeql-action/init` action.
7070
# This includes steps like installing compilers or runtimes (`actions/setup-node`
@@ -74,7 +74,7 @@ jobs:
7474

7575
# Initializes the CodeQL tools for scanning.
7676
- name: Initialize CodeQL
77-
uses: github/codeql-action/init@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
77+
uses: github/codeql-action/init@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
7878
with:
7979
languages: ${{ matrix.language }}
8080
build-mode: ${{ matrix.build-mode }}
@@ -102,6 +102,6 @@ jobs:
102102
exit 1
103103
104104
- name: Perform CodeQL Analysis
105-
uses: github/codeql-action/analyze@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
105+
uses: github/codeql-action/analyze@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.30.5
106106
with:
107107
category: "/language:${{matrix.language}}"

.github/workflows/go-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Harden the runner (Audit all outbound calls)
17-
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
17+
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
1818
with:
1919
egress-policy: audit
2020

21-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
21+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2222

2323
- name: Set up Go
24-
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
24+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
2525
with:
2626
go-version: '1.24'
2727

examples/grafana/dashboards/dasboard_gl_exporter_metrics.json

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"editable": true,
1919
"fiscalYearStartMonth": 0,
2020
"graphTooltip": 0,
21-
"id": 8,
21+
"id": 7,
2222
"links": [],
2323
"panels": [
2424
{
@@ -453,13 +453,34 @@
453453
"expr": "gcpe_metrics_count",
454454
"fullMetaSearch": false,
455455
"includeNullMetadata": true,
456-
"legendFormat": "__auto",
456+
"legendFormat": "Metrics count",
457457
"range": true,
458458
"refId": "A",
459459
"useBackend": false
460460
}
461461
],
462462
"title": "Metrics over time",
463+
"transformations": [
464+
{
465+
"id": "calculateField",
466+
"options": {
467+
"alias": "Median",
468+
"mode": "reduceRow",
469+
"reduce": {
470+
"include": [
471+
"Nb of metrics"
472+
],
473+
"reducer": "median"
474+
},
475+
"window": {
476+
"reducer": "mean",
477+
"windowAlignment": "trailing",
478+
"windowSize": 1000,
479+
"windowSizeMode": "fixed"
480+
}
481+
}
482+
}
483+
],
463484
"type": "timeseries"
464485
},
465486
{
@@ -955,27 +976,38 @@
955976
{
956977
"datasource": {
957978
"type": "prometheus",
958-
"uid": "${DS_PROMETHEUS}"
979+
"uid": "P1809F7CD0C75ACF3"
959980
},
960-
"disableTextWrap": false,
961-
"editorMode": "builder",
962-
"exemplar": false,
963-
"expr": "gitlab_ci_runners",
964-
"fullMetaSearch": false,
965-
"includeNullMetadata": true,
966-
"instant": true,
967-
"interval": "",
981+
"editorMode": "code",
982+
"expr": "gitlab_ci_runners_info",
983+
"instant": false,
968984
"legendFormat": "__auto",
969-
"range": false,
970-
"refId": "A",
971-
"useBackend": false
985+
"range": true,
986+
"refId": "A"
972987
}
973988
],
974989
"title": "Runner List",
975990
"transformations": [
976991
{
977992
"id": "labelsToFields",
978-
"options": {}
993+
"options": {
994+
"keepLabels": [
995+
"active",
996+
"contacted_at",
997+
"instance",
998+
"is_shared",
999+
"job",
1000+
"online",
1001+
"paused",
1002+
"runner_description",
1003+
"runner_groups",
1004+
"runner_id",
1005+
"runner_maintenance_note",
1006+
"runner_projects",
1007+
"runner_name",
1008+
"project"
1009+
]
1010+
}
9791011
}
9801012
],
9811013
"type": "table"
@@ -986,20 +1018,7 @@
9861018
"schemaVersion": 41,
9871019
"tags": [],
9881020
"templating": {
989-
"list": [
990-
{
991-
"current": {
992-
"text": "",
993-
"value": ""
994-
},
995-
"name": "DataSource",
996-
"options": [],
997-
"query": "",
998-
"refresh": 1,
999-
"regex": "",
1000-
"type": "query"
1001-
}
1002-
]
1021+
"list": []
10031022
},
10041023
"time": {
10051024
"from": "now-1h",
@@ -1009,5 +1028,5 @@
10091028
"timezone": "browser",
10101029
"title": "Gitlab Exporter Metrics",
10111030
"uid": "2f6fa597-4273-4243-980f-dded5c6bd301",
1012-
"version": 5
1031+
"version": 1
10131032
}

pkg/config/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package config
22

33
import (
44
"fmt"
5+
"time"
56

67
"github.com/creasty/defaults"
78
"github.com/go-playground/validator/v10"
@@ -111,6 +112,12 @@ type Redis struct {
111112
// URL is the connection string used to connect to the Redis server.
112113
// Format example: redis[s]://[:password@]host[:port][/db-number][?option=value]
113114
URL string `yaml:"url"`
115+
116+
ProjectTTL time.Duration `default:"336h" yaml:"project_ttl"` // ProjectTTL defines TTL for projects by default 2 weeks
117+
RefTTL time.Duration `default:"1h" yaml:"ref_ttl"` // RefTTL defines TTL for references by default 1h
118+
RunnerTTL time.Duration `default:"1h" yaml:"runner_ttl"` // RunnerTTL defines TTL for runners by default 1h
119+
EnvTTL time.Duration `default:"1h" yaml:"env_ttl"` // EnvTTL defines TTL for Environments by default 1h
120+
MetricTTL time.Duration `default:"1h" yaml:"metric_ttl"` // MetricTTL defines TTL for Metrics by default 1h
114121
}
115122

116123
// Pull holds configuration related to how and when data is pulled from GitLab.

pkg/config/config_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package config
22

33
import (
44
"testing"
5+
"time"
56

67
log "github.com/sirupsen/logrus"
78
"github.com/stretchr/testify/assert"
@@ -66,6 +67,9 @@ func TestNew(t *testing.T) {
6667
c.ProjectDefaults.Pull.Environments.Regexp = `.*`
6768
c.ProjectDefaults.Pull.Environments.ExcludeStopped = true
6869

70+
c.ProjectDefaults.Pull.Runners.Enabled = true
71+
c.ProjectDefaults.Pull.Runners.Regexp = `.*`
72+
6973
c.ProjectDefaults.Pull.Refs.Branches.Enabled = true
7074
c.ProjectDefaults.Pull.Refs.Branches.Regexp = `^(?:main|master)$`
7175
c.ProjectDefaults.Pull.Refs.Branches.ExcludeDeleted = true
@@ -80,6 +84,14 @@ func TestNew(t *testing.T) {
8084
c.ProjectDefaults.Pull.Pipeline.Jobs.RunnerDescription.Enabled = true
8185
c.ProjectDefaults.Pull.Pipeline.Jobs.RunnerDescription.AggregationRegexp = `shared-runners-manager-(\d*)\.gitlab\.com`
8286
c.ProjectDefaults.Pull.Pipeline.Variables.Regexp = `.*`
87+
c.ProjectDefaults.Pull.Pipeline.PerRef = 1
88+
89+
// Redis config tests
90+
c.Redis.ProjectTTL = 336 * time.Hour
91+
c.Redis.RefTTL = 1 * time.Hour
92+
c.Redis.RunnerTTL = 1 * time.Hour
93+
c.Redis.EnvTTL = 1 * time.Hour
94+
c.Redis.MetricTTL = 1 * time.Hour
8395

8496
assert.Equal(t, c, New())
8597
}

pkg/config/parser_test.go

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ garbage_collect:
7979
scheduled: false
8080
interval_seconds: 2
8181
runners:
82-
interval_seconds: 14400
83-
scheduled: false
84-
interval_seconds: 3
82+
on_init: true
83+
scheduled: false
84+
interval_seconds: 3
8585
refs:
8686
on_init: true
8787
scheduled: false
@@ -97,9 +97,9 @@ project_defaults:
9797
environments:
9898
enabled: true
9999
regexp: "^baz$"
100-
runners:
100+
runners:
101101
enabled: true
102-
regex: ".*"
102+
regexp: ".*"
103103
ExcludeStopped: false
104104
refs:
105105
branches:
@@ -120,10 +120,11 @@ project_defaults:
120120
max_age_seconds: 3
121121
pipeline:
122122
jobs:
123-
enabled: true
123+
enabled: false
124124
variables:
125-
enabled: true
125+
enabled: false
126126
regexp: "^CI_"
127+
PerRef: 3
127128
128129
projects:
129130
- name: foo/project
@@ -136,6 +137,8 @@ projects:
136137
branches:
137138
regexp: "^foo$"
138139
max_age_seconds: 2
140+
pipeline:
141+
PerRef: 10
139142
runners:
140143
enabled: true
141144
regex: ".*"
@@ -162,6 +165,7 @@ wildcards:
162165

163166
xcfg := New()
164167

168+
// Explicit YAML overrides
165169
xcfg.Log.Level = "trace"
166170
xcfg.Log.Format = "json"
167171

@@ -171,13 +175,12 @@ wildcards:
171175
xcfg.Server.ListenAddress = ":1025"
172176
xcfg.Server.Metrics.Enabled = false
173177
xcfg.Server.Metrics.EnableOpenmetricsEncoding = false
174-
175178
xcfg.Server.Webhook.Enabled = true
176179
xcfg.Server.Webhook.SecretToken = "secret"
177180

178181
xcfg.Gitlab.URL = "https://gitlab.example.com"
179-
xcfg.Gitlab.HealthURL = "https://gitlab.example.com/-/health"
180182
xcfg.Gitlab.Token = "xrN14n9-ywvAFxdwadadadadwadadw"
183+
xcfg.Gitlab.HealthURL = "https://gitlab.example.com/-/health"
181184
xcfg.Gitlab.EnableHealthCheck = false
182185
xcfg.Gitlab.EnableTLSVerify = false
183186
xcfg.Gitlab.MaximumRequestsPerSecond = 2
@@ -192,17 +195,13 @@ wildcards:
192195
xcfg.Pull.EnvironmentsFromProjects.Scheduled = false
193196
xcfg.Pull.EnvironmentsFromProjects.IntervalSeconds = 2
194197

195-
xcfg.Pull.RunnersFromProjects.OnInit = false
196-
xcfg.Pull.RunnersFromProjects.Scheduled = false
197-
xcfg.Pull.RunnersFromProjects.IntervalSeconds = 3
198-
199198
xcfg.Pull.RefsFromProjects.OnInit = false
200199
xcfg.Pull.RefsFromProjects.Scheduled = false
201-
xcfg.Pull.RefsFromProjects.IntervalSeconds = 4
200+
xcfg.Pull.RefsFromProjects.IntervalSeconds = 3
202201

203202
xcfg.Pull.Metrics.OnInit = false
204203
xcfg.Pull.Metrics.Scheduled = false
205-
xcfg.Pull.Metrics.IntervalSeconds = 5
204+
xcfg.Pull.Metrics.IntervalSeconds = 4
206205

207206
xcfg.GarbageCollect.Projects.OnInit = true
208207
xcfg.GarbageCollect.Projects.Scheduled = false
@@ -212,13 +211,17 @@ wildcards:
212211
xcfg.GarbageCollect.Environments.Scheduled = false
213212
xcfg.GarbageCollect.Environments.IntervalSeconds = 2
214213

214+
xcfg.GarbageCollect.Runners.OnInit = true
215+
xcfg.GarbageCollect.Runners.Scheduled = false
216+
xcfg.GarbageCollect.Runners.IntervalSeconds = 3
217+
215218
xcfg.GarbageCollect.Refs.OnInit = true
216219
xcfg.GarbageCollect.Refs.Scheduled = false
217-
xcfg.GarbageCollect.Refs.IntervalSeconds = 3
220+
xcfg.GarbageCollect.Refs.IntervalSeconds = 4
218221

219222
xcfg.GarbageCollect.Metrics.OnInit = true
220223
xcfg.GarbageCollect.Metrics.Scheduled = false
221-
xcfg.GarbageCollect.Metrics.IntervalSeconds = 4
224+
xcfg.GarbageCollect.Metrics.IntervalSeconds = 5
222225

223226
xcfg.ProjectDefaults.OutputSparseStatusMetrics = false
224227

@@ -245,23 +248,27 @@ wildcards:
245248
xcfg.ProjectDefaults.Pull.Refs.MergeRequests.MostRecent = 3
246249
xcfg.ProjectDefaults.Pull.Refs.MergeRequests.MaxAgeSeconds = 3
247250

248-
xcfg.ProjectDefaults.Pull.Pipeline.Jobs.Enabled = true
249-
xcfg.ProjectDefaults.Pull.Pipeline.Variables.Enabled = true
251+
// YAML explicitly sets Jobs.enabled=false and Variables.enabled=false
252+
xcfg.ProjectDefaults.Pull.Pipeline.Jobs.Enabled = false
253+
xcfg.ProjectDefaults.Pull.Pipeline.Variables.Enabled = false
250254
xcfg.ProjectDefaults.Pull.Pipeline.Variables.Regexp = `^CI_`
255+
xcfg.ProjectDefaults.Pull.Pipeline.PerRef = 3
251256

257+
// Projects
252258
p1 := NewProject("foo/project")
253259
p1.ProjectParameters = xcfg.ProjectDefaults
254260

255261
p2 := NewProject("bar/project")
256262
p2.ProjectParameters = xcfg.ProjectDefaults
257-
258263
p2.Pull.Environments.Enabled = false
259264
p2.Pull.Environments.Regexp = `^foo$`
260265
p2.Pull.Refs.Branches.Regexp = `^foo$`
261266
p2.Pull.Refs.Branches.MaxAgeSeconds = 2
267+
p2.Pull.Pipeline.PerRef = 10
262268

263269
xcfg.Projects = []Project{p1, p2}
264270

271+
// Wildcards
265272
w1 := NewWildcard()
266273
w1.ProjectParameters = xcfg.ProjectDefaults
267274
w1.Search = "bar"
@@ -275,7 +282,6 @@ wildcards:
275282

276283
xcfg.Wildcards = []Wildcard{w1}
277284

278-
// Test variable assignments
279285
assert.Equal(t, xcfg, cfg)
280286
}
281287

0 commit comments

Comments
 (0)