Fix jsonschema validation warning for docker services_limit
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA -
Please check this box if this contribution uses AI-generated content as outlined in the GitLab DCO & CLA
What does this MR do?
This MR fixes a jsonschema validation warning for the docker services_limit
option.
It is based on the solutions from !4248 (merged) (and !4724 (merged)) and adds the omitempty
flag to the ServicesLimit
option inside common/config.go
. There is already a default/fallback logic in place that sets this value to -1
in case no other value is provided by the user.
Why was this MR needed?
Running gitlab-runner list
with a basic config.toml
currently throws a jsonschema validation warning:
$ gitlab-runner list
Runtime platform arch=amd64 os=linux pid=100411 revision=81ab07f6 version=16.10.0
There might be a problem with your config based on jsonschema annotations in common/config.go (experimental feature):
jsonschema: '/runners/0/docker/services_limit' does not validate with https://gitlab.com/gitlab-org/gitlab-runner/common/config#/$ref/properties/runners/items/$ref/properties/docker/$ref/properties/services_limit/type: expected integer, but got null
Listing configured runners ConfigFile=/etc/gitlab-runner/config.toml
runner-host-001 Executor=docker Token=xj484ijsdjoiv892 URL=https://gitlab.company.local
What's the best way to test this MR?
To reproduce the issue:
- Create a basic
config.toml
that uses the docker executor (see example config below) - Download the latest gitlab-runner binary
- Run
gitlab-runner list --config path/to/config.toml
- Verify that the validation warning is being displayed
To test the fix:
- Re-use the
config.toml
- Build the gitlab-runner binary
- Run
gitlab-runner list --config path/to/config.toml
- Ensure that no validation warnings are being displayed
Example `config.toml`
listen_address = ":9252"
concurrent = 3
check_interval = 0
connection_max_age = "15m0s"
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "runner-host-001"
output_limit = 409600
url = "https://git.company.local"
id = 901
token = "xj484ijsdjoiv892"
token_obtained_at = 2024-04-09T07:03:53Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker"
environment = ["DOCKER_TLS_CERTDIR=/certs"]
shell = "bash"
[runners.cache]
Type = "s3"
Shared = true
MaxUploadedArchiveSize = 0
[runners.cache.s3]
ServerAddress = "minio.company.local"
AccessKey = "access-key"
SecretKey = "secret-key"
BucketName = "gitlab-runner"
AuthenticationType = "access-key"
[runners.feature_flags]
FF_USE_IMPROVED_URL_MASKING = true
[runners.docker]
tls_verify = false
image = "registry.company.local/docker/docker:stable"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache", "/certs/client"]
pull_policy = ["always"]
shm_size = 2147483648
network_mtu = 0
What are the relevant issue numbers?
Fixes Warning message about services_limit. (#37424 - closed)