Skip to content

Validation warning: jsonschema '/runners/0/Monitoring' does not validate

Summary

After upgrading from GitLab Runner v16.8 to v16.10 we started seeing config validation warnings when running gitlab-runner list:

$ 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/Monitoring' does not validate with https://gitlab.com/gitlab-org/gitlab-runner/common/config#/$ref/properties/runners/items/$ref/properties/Monitoring/$ref/type: expected object, but got null

Listing configured runners                          ConfigFile=/etc/gitlab-runner/config.toml
runner-host-001                                     Executor=docker Token=xj484ijsdjoiv892 URL=https://gitlab.company.local

Steps to reproduce

  • Install a gitlab-runner and do not configure any [runners.monitoring] settings in the config.toml
  • Run gitlab-runner list to list registered runners

Actual behavior

A config validation warning is thrown because [runners.monitoring] is not configured - and therefore the jsonschema validation can not match null to the nested object.

Expected behavior

Because [runners.monitoring] is an optional (and currently experimental) config block it should not throw any warnings when left out.

Environment description

config.toml contents
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 = 0
    services_limit = 4
    network_mtu = 0

Used GitLab Runner version

Version:      16.10.0
Git revision: 81ab07f6
Git branch:   16-10-stable
GO version:   go1.21.7
Built:        2024-03-21T19:43:25+0000
OS/Arch:      linux/amd64

Possible fixes

The experimental [runners.monitoring] feature was introduced in [Experimental] Define monitoring threshold for ... (!4480 - merged) - which was first released in GitLab Runner v16.10.

Looking at a similar issue #36049 (closed) the fix required omitempty to be added to the common/config.go struct. Right now https://gitlab.com/gitlab-org/gitlab-runner/-/blob/81ab07f6dd8cb2d577396a20d059fea7086e0d81/common/config.go#L1168 does not seem to allow an empty object for Monitoring - while all the other objects (like [runners.docker], [runners.kubernets], ...) do so: https://gitlab.com/gitlab-org/gitlab-runner/-/blob/81ab07f6dd8cb2d577396a20d059fea7086e0d81/common/config.go#L1172

Monitoring *runner.Monitoring `toml:"monitoring" long:"runner-monitoring"

Instance   *InstanceConfig   `toml:"instance,omitempty" json:"instance,omitempty"`
SSH        *ssh.Config       `toml:"ssh,omitempty" json:"ssh,omitempty" group:"ssh executor" namespace:"ssh"`
Docker     *DockerConfig     `toml:"docker,omitempty" json:"docker,omitempty" group:"docker executor" namespace:"docker"`

So I assume that adding json:monitoring,omitempty to the monitoring struct will solve this. If that is the case then I can create a merge request to solve this issue.