clowder icon indicating copy to clipboard operation
clowder copied to clipboard

Updated default cpu limit

Open ffeghali opened this issue 4 months ago • 7 comments

The default cpu limit is now null. This is to remove the cpu limit when a limit is not specified.

ffeghali avatar Aug 28 '25 18:08 ffeghali

Will run the test on this one once tests wrap on another PR ...

bsquizz avatar Sep 03 '25 16:09 bsquizz

/ok-to-test

bsquizz avatar Sep 04 '25 14:09 bsquizz

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

bsquizz avatar Sep 04 '25 15:09 bsquizz

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

bsquizz avatar Sep 04 '25 15:09 bsquizz

The problem might be that there's a LimitRange set in the namespace

bsquizz avatar Sep 04 '25 15:09 bsquizz

Don't think that is the problem either. Trying to debug it.

bsquizz avatar Sep 04 '25 15:09 bsquizz

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, then resourceRequirements.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), then resourceRequirements.Limits["cpu"] = env.Spec.ResourceDefaults.Limits["cpu"]
  • If the cpu limit is not defined on the .pod.Resources.Limits and it is also not defined at env.Spec.ResourceDefaults.Limits["cpu"], then the 'cpu' key should not be set at all.

bsquizz avatar Sep 04 '25 19:09 bsquizz