Skip to content

Conversation

@tolusha
Copy link
Contributor

@tolusha tolusha commented Dec 9, 2025

What does this PR do?

Implements ContainerResourceCaps configuration to enforce maximum resource limits and requests for workspace containers. When configured, container resource requirements that exceed the caps will be limited to the maximum values. This feature does not apply to initContainers or projectClone containers.

Assisted-by: Claude.

What issues does this PR fix or reference?

https://issues.redhat.com/browse/CRW-9546

Is it tested? How?

  1. Create DevWorkspaceOperatorConfig
apiVersion: controller.devfile.io/v1alpha1
config:
  workspace:
    containerResourceCaps:
      limits:
        cpu: "1"
        memory: 2Gi
      requests:
        cpu: "0.1"
        memory: 100Mi
kind: DevWorkspaceOperatorConfig
metadata:
  name: devworkspace-operator-config
  namespace: devworkspace-controller
  1. Start a workspace from devifile

  2. Check containers resources in a workspace deployment:

  • caps applied for tools-1 and tools-2
  • no changes for tools-3

PR Checklist

  • E2E tests pass (when PR is ready, comment /test v8-devworkspace-operator-e2e, v8-che-happy-path to trigger)
    • v8-devworkspace-operator-e2e: DevWorkspace e2e test
    • v8-che-happy-path: Happy path for verification integration with Che

@openshift-ci
Copy link

openshift-ci bot commented Dec 9, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Implements ContainerResourceCaps configuration to enforce maximum resource
limits and requests for workspace containers. When configured, container
resource requirements that exceed the caps will be limited to the maximum
values. This feature does not apply to initContainers or projectClone containers.

Changes include:
- New ContainerResourceCaps field in DevWorkspaceOperatorConfig API
- Updated CRDs with the new field definition
- Controller integration to pass resource caps to container handlers
- Resource capping logic in container, flatten, merge, and projects packages
- Tests for resource cap enforcement

Assisted-by: Claude.
Signed-off-by: Anatolii Bazko <[email protected]>
Signed-off-by: Anatolii Bazko <[email protected]>
Signed-off-by: Anatolii Bazko <[email protected]>
Signed-off-by: Anatolii Bazko <[email protected]>
Signed-off-by: Anatolii Bazko <[email protected]>
@tolusha tolusha marked this pull request as ready for review December 10, 2025 11:39
@tolusha tolusha marked this pull request as draft December 10, 2025 13:28
@openshift-ci
Copy link

openshift-ci bot commented Dec 10, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rohanKanojia, tolusha
Once this PR has been reviewed and has the lgtm label, please assign dkwon17 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Signed-off-by: Anatolii Bazko <[email protected]>
@openshift-ci openshift-ci bot removed the lgtm label Dec 10, 2025
@openshift-ci
Copy link

openshift-ci bot commented Dec 10, 2025

New changes are detected. LGTM label has been removed.

Signed-off-by: Anatolii Bazko <[email protected]>
@tolusha tolusha marked this pull request as ready for review December 10, 2025 14:52
Signed-off-by: Anatolii Bazko <[email protected]>
@dkwon17
Copy link
Collaborator

dkwon17 commented Dec 12, 2025

@tolusha thank you for the PR,

I noticed that if I set for example:

apiVersion: controller.devfile.io/v1alpha1
config:
  workspace:
    containerResourceCaps:
      limits:
        cpu: '102'
        memory: 200Gi
      requests:
        cpu: '102'
        memory: 200Mi
kind: DevWorkspaceOperatorConfig
metadata:
  name: devworkspace-operator-config
  namespace: openshift-operators

And create a devworkspace with no cpu limits or requests:

Devworkspace
apiVersion: workspace.devfile.io/v1alpha2
kind: DevWorkspace
metadata:
  name: devfile
  namespace: admin-devspaces
spec:
  started: true
  template:
    components:
      - container:
          image: 'quay.io/devfile/universal-developer-image:latest'
          memoryLimit: 5Gi
          memoryRequest: 3Gi
          sourceMapping: /projects
        name: tools-2

Then it looks like the cpu: 102 is being applied to the devworkspace:

'Error creating DevWorkspace deployment: Detected unrecoverable event FailedScheduling: 0/1 nodes are available: 1 Insufficient cpu. preemption: 0/1 nodes are available: 1 No preemption victims found for incoming pod.'

If I update the DWOC to set the cpu limit and request cap to 10, the devworkspace starts, and the container has a limit and request set to 10.

I think the cap should not be applied to the cpu in both cases?

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.

4 participants