Updated default cpu limit
The default cpu limit is now null. This is to remove the cpu limit when a limit is not specified.
Will run the test on this one once tests wrap on another PR ...
/ok-to-test
Many of the kuttl e2e tests are failing because of errors like this:
+ "puptoo-processor" is invalid: spec.template.spec.containers[0].resources.requests:
+ Invalid value: "30m": must be less than or equal to cpu limit of 0'
Which is making me question if we are supposed to be removing the request ... or the limit. The ticket may have been written wrong, I'm thinking we probably want to be setting the limit to 0... see https://home.robusta.dev/blog/stop-using-cpu-limits
Nevermind, you're attempting to do the right thing here. Perhaps the key needs to be totally absent instead of being set to '0' to avoid the error we are getting
The problem might be that there's a LimitRange set in the namespace
Don't think that is the problem either. Trying to debug it.
Ok, I think what needs to happen is the 'cpu' key needs to be absent instead of being set to '0':
What I'd recommend doing is:
- At this point instead of returning, define the resourceRequirements like this:
resourceRequirements = core.ResourceRequirements{
Limits: core.ResourceList{
"memory": lmemory,
},
Requests: core.ResourceList{
"cpu": rcpu,
"memory": rmemory,
},
}
Move the logic here below that, and check for these conditions:
- Condition 1: If
*pod.Resources.Limits.Cpu() != nullCPU, thenresourceRequirements.Limits["cpu"] = pod.Resources.Limits["cpu"] - Condition 2: If the config for
env.Spec.ResourceDefaults.Limits["cpu"]is defined (in other words, if the key is present in that config), thenresourceRequirements.Limits["cpu"] = env.Spec.ResourceDefaults.Limits["cpu"] - If the cpu limit is not defined on the
.pod.Resources.Limitsand it is also not defined atenv.Spec.ResourceDefaults.Limits["cpu"], then the 'cpu' key should not be set at all.