Skip to content

Conversation

@ffeghali
Copy link

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

@bsquizz
Copy link
Contributor

bsquizz commented Sep 3, 2025

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

@bsquizz
Copy link
Contributor

bsquizz commented Sep 4, 2025

/ok-to-test

@bsquizz
Copy link
Contributor

bsquizz commented Sep 4, 2025

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
Copy link
Contributor

bsquizz commented Sep 4, 2025

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
Copy link
Contributor

bsquizz commented Sep 4, 2025

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

@bsquizz
Copy link
Contributor

bsquizz commented Sep 4, 2025

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

@bsquizz
Copy link
Contributor

bsquizz commented Sep 4, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants