Skip to content

[BUG]CacheRuntime: a partially specified resources silently drops the rest of the container's resource requirements #6173

Description

@btxu-db

What is your environment(Kubernetes version, Fluid version, etc.)

Describe the bug

AdvancedStatefulSetManager.updateResources replaces the container's entire ResourceRequirements struct rather than merging it key by key:

// pkg/ddc/cache/component/advanced_statefulset_manager.go:299
container.Resources = *resources.DeepCopy()

ResourceRequirements holds Limits, Requests and Claims. Anything the user does not restate in CacheRuntime.spec.<component>.resources is dropped from the workload on the next reconcile, including values that were rendered from the CacheRuntimeClass template at creation time. There is no error and no event.

The practical case is a user who only wants to raise one number. Setting just limits.memory also clears requests.cpu, limits.cpu, requests.memory and claims, which changes both how the pod is scheduled and what caps its usage on the node.

What you expect to happen:

Only the keys the user actually set should change. Values that came from the CacheRuntimeClass template and were not mentioned in the CacheRuntime should survive the sync.

How to reproduce it

  1. CacheRuntimeClass whose worker template declares a full set of resources:
topology:
  worker:
    template:
      spec:
        containers:
        - name: worker
          resources:
            requests: {cpu: "1", memory: 2Gi}
            limits:   {cpu: "2", memory: 4Gi}
  1. Create a CacheRuntime that does not set spec.worker.resources. The AdvancedStatefulSet correctly
    inherits the template values and stays there (verified stable over 70s of reconciles, generation 1):
gen = 1  {"limits":{"cpu":"2","memory":"4Gi"},"requests":{"cpu":"1","memory":"2Gi"}}
  1. Now raise a single value — the memory limit only:
kubectl patch cacheruntime restest --type=merge \
  -p '{"spec":{"worker":{"resources":{"limits":{"memory":"8Gi"}}}}}'
  1. Everything else is gone, and the pods roll (generation 1 -> 2):
gen = 2  {"limits":{"memory":"8Gi"}}

limits.cpu: 2, requests.cpu: 1 and requests.memory: 2Gi were all dropped. On the resulting pod:

qosClass = Burstable
worker    {"limits":{"memory":"8Gi"},"requests":{"memory":"8Gi"}}

The container now has no CPU request and no CPU limit at all, so the scheduler stops reserving CPU for it
and nothing caps its CPU usage on the node. The requests.memory: 8Gi is Kubernetes defaulting requests to
limits, which also silently raises the memory reservation from the intended 2Gi to 8Gi.

Additional Information

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions