millicpu allowed to be higher then overwriteMaxAllowed
Summary
In !874 (merged) introduced a new configuration to the user tho set cpu_limit_overwrite_max_allowed
and cpu_request_overwrite_max_allowed
however when use the millicpu values for example 100m
this doesn't work and the user can set a higher value. Also, the error returned when it's an invalid is confusing with the resource "MemoryLimit" requested by the build "4Gi" does not match or is less than limit allowed "512Mi"
is not "less" but it should be "higher"
Steps to reproduce
- Configure a Kubernetes Runner with the same overwrites set below.
- Run the
.gitlab-ci.yml
below
.gitlab-ci.yml
variables:
IMAGE: alpine:3.11
job:
variables:
KUBERNETES_CPU_REQUEST: 400m
KUBERNETES_CPU_LIMIT: 600m
KUBERNETES_MEMORY_REQUEST: 500Mi
KUBERNETES_MEMORY_LIMIT: 4Gi
image: ${IMAGE}
script:
- echo -n "things are breaking"
Actual behavior
CPU limit is set, even though it's higher than max. Error messing regarding memory is confusing requested by the build "4Gi" does not match or is less than limit allowed "512Mi"
Expected behavior
Job failed during setting CPU limits since we set the CPU LIMIT to be 600m
but the max CPU limit that is allowed is 400m
Relevant logs and/or screenshots
job log
Running with gitlab-runner 13.0.0~beta.169.gdccb3f31 (dccb3f31)
on test-gitlab-runner-669f8c894c-pdtsr _fDJFULD
Preparing the "kubernetes" executor
00:09
"CPULimit" overwritten with "600m" <-------- Should not be set
"CPURequest" overwritten with "400m"
ERROR: Preparation failed: couldn't prepare overwrites: the resource "MemoryLimit" requested by the build "4Gi" does not match or is less than limit allowed "512Mi" <--- Confusing error message because of "is less" when we mean "higher"
Will be retried in 3s ...
"CPULimit" overwritten with "600m"
"CPURequest" overwritten with "400m"
ERROR: Preparation failed: couldn't prepare overwrites: the resource "MemoryLimit" requested by the build "4Gi" does not match or is less than limit allowed "512Mi"
Will be retried in 3s ...
"CPULimit" overwritten with "600m"
"CPURequest" overwritten with "400m"
ERROR: Preparation failed: couldn't prepare overwrites: the resource "MemoryLimit" requested by the build "4Gi" does not match or is less than limit allowed "512Mi"
Will be retried in 3s ...
ERROR: Job failed (system failure): couldn't prepare overwrites: the resource "MemoryLimit" requested by the build "4Gi" does not match or is less than limit allowed "512Mi"
Environment description
config.toml contents
[[runners]]
name = "kubernetes"
url = "http://192.168.144.160:3000"
token = "xxxx"
executor = "kubernetes"
[runners.kubernetes]
image = "alpine:3.11"
privileged = true
bearer_token = ""
namespace = "default"
namespace_overwrite_allowed = ""
cpu_limit = "200m"
cpu_limit_overwrite_max_allowed = "400m"
memory_limit = "256Mi"
memory_limit_overwrite_max_allowed = "512Mi"
cpu_request = "100m"
cpu_request_overwrite_max_allowed = "200m"
memory_request = "128Mi"
memory_request_overwrite_max_allowed = "256Mi"
poll_timeout = 180
Used GitLab Runner version
12.9
Possible fixes
Instead of use .Value to compare the two resources use .Cmp because .Value always returns 1 when it's set to millicpus