Skip to content

Fix jsonschema validation warning for monitoring struct

  • 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 Monitoring struct.

It is based on the solution from !4248 (merged) and adds the omitempty flag to the Monitoring block inside common/config.go. Because the monitoring feature is still experimental and requires the user to opt-in it should be optional in the jsonschema validation - and not throw a warning.

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/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

What's the best way to test this MR?

To reproduce the issue:

  1. Create a basic config.toml (or use the example provided in the linked issue)
  2. Download the latest gitlab-runner binary
  3. Run gitlab-runner list --config path/to/config.toml
  4. Verify that the validation warning is being displayed

To test the fix:

  1. Re-use the config.toml
  2. Build the gitlab-runner binary
  3. Run gitlab-runner list --config path/to/config.toml
  4. Ensure that no validation warnings are being displayed

What are the relevant issue numbers?

Fixes Validation warning: jsonschema '/runners/0/Moni... (#37475 - closed)

Edited by 🤖 GitLab Bot 🤖

Merge request reports