Exclude empty slices during the validation of the config.toml
What does this MR do?
This MR makes sure that empty slices are ignored when validating the config.toml provided by the user. While the INFO logs do not affect the functionality of GitLab Runner, they do cause confusion.
Why was this MR needed?
This MR is needed to reduce the noise in GitLab Runner logs when validating the config.toml provided
What's the best way to test this MR?
config.toml
concurrent = 1
check_interval = 1
log_level = "debug"
shutdown_timeout = 0
listen_address = ':9252'
[session_server]
session_timeout = 1800
[[runners]]
name = ""
url = "https://gitlab.com/"
id = 0
token = "glrt-REDACTED"
token_obtained_at = "0001-01-01T00:00:00Z"
token_expires_at = "0001-01-01T00:00:00Z"
executor = "kubernetes"
shell = "bash"
[runners.kubernetes]
host = ""
bearer_token_overwrite_allowed = false
image = "alpine"
memory_request = "128Mi"
cpu_request = "1"
namespace = ""
namespace_overwrite_allowed = ""
pod_labels_overwrite_allowed = ""
service_account_overwrite_allowed = ""
pod_annotations_overwrite_allowed = ""
node_selector_overwrite_allowed = ".*"
allow_privilege_escalation = false
[runners.kubernetes.affinity]
[runners.kubernetes.affinity.node_affinity]
[runners.kubernetes.affinity.node_affinity.required_during_scheduling_ignored_during_execution]
[[runners.kubernetes.affinity.node_affinity.required_during_scheduling_ignored_during_execution.node_selector_terms]]
[[runners.kubernetes.affinity.node_affinity.required_during_scheduling_ignored_during_execution.node_selector_terms.match_expressions]]
key = "kubernetes.io/os"
operator = "In"
values = ["linux"]
[[runners.kubernetes.services]]
[runners.kubernetes.dns_config]
[runners.kubernetes.pod_labels]
Start GitLab Runner using the main branch and the config.toml provided above
GitLab Runner log will display an error similar to this:
There might be a problem with your config based on jsonschema annotations in common/config.go (experimental feature):
jsonschema: '/runners/0/kubernetes/affinity/node_affinity/preferred_during_scheduling_ignored_during_execution' does not validate with https://gitlab.com/gitlab-org/gitlab-runner/common/config#/$ref/properties/runners/items/$ref/properties/kubernetes/$ref/properties/affinity/$ref/properties/node_affinity/$ref/properties/preferred_during_scheduling_ignored_during_execution/type: expected array, but got null
Start GitLab Runner using the MR branch config-best-effort-validation and the config.toml provided above
There won't be any error related to k8s PodAffinity
What are the relevant issue numbers?
fixes #36868 (closed)