Skip to content

Commit

Permalink
[local] Explicitely only support ephemeral volumes for topolvm
Browse files Browse the repository at this point in the history
Explicitely do not trigger a scale up if we request a persistent topolvm volume (or an ephemeral local data volume)
  • Loading branch information
Fricounet committed Jun 27, 2024
1 parent 411e2cd commit 09996d5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
25 changes: 23 additions & 2 deletions cluster-autoscaler/processors/datadog/pods/transform_local_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,35 @@ func (p *transformLocalData) Process(ctx *context.AutoscalingContext, pods []*ap

switch *pvcSpec.StorageClassName {
case storageClassNameTopolvm:
// Only support ephemeral volumes for topolvm
if vol.Ephemeral == nil {
volumes = append(volumes, vol)
continue
}
if storage, ok := pvcSpec.Resources.Requests[corev1.ResourceStorage]; ok {
po.Spec.Containers[0].Resources.Requests[common.DatadogEphemeralLocalDataResource] = storage.DeepCopy()
po.Spec.Containers[0].Resources.Limits[common.DatadogEphemeralLocalDataResource] = storage.DeepCopy()
if request, ok := po.Spec.Containers[0].Resources.Requests[common.DatadogEphemeralLocalDataResource]; ok {
request.Add(storage)
po.Spec.Containers[0].Resources.Requests[common.DatadogEphemeralLocalDataResource] = request
} else {
po.Spec.Containers[0].Resources.Requests[common.DatadogEphemeralLocalDataResource] = storage.DeepCopy()
}

if limit, ok := po.Spec.Containers[0].Resources.Limits[common.DatadogEphemeralLocalDataResource]; ok {
limit.Add(storage)
po.Spec.Containers[0].Resources.Limits[common.DatadogEphemeralLocalDataResource] = limit
} else {
po.Spec.Containers[0].Resources.Limits[common.DatadogEphemeralLocalDataResource] = storage.DeepCopy()
}
} else {
klog.Warningf("ignoring pvc as it does not have storage request information")
volumes = append(volumes, vol)
}
case storageClassNameLocal:
// Only support persistent volumes for local storage
if vol.PersistentVolumeClaim == nil {
volumes = append(volumes, vol)
continue
}
po.Spec.Containers[0].Resources.Requests[common.DatadogLocalDataResource] = common.DatadogLocalDataQuantity.DeepCopy()
po.Spec.Containers[0].Resources.Limits[common.DatadogLocalDataResource] = common.DatadogLocalDataQuantity.DeepCopy()
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ func TestTransformLocalDataProcess(t *testing.T) {
},
[]*corev1.Pod{buildPod("pod1", testMixedResources, testMixedResources)},
},
{
"no persistent volume for topolvm",
[]*corev1.Pod{buildPod("pod1", testEmptyResources, testEmptyResources, "pvc-1")},
[]*corev1.PersistentVolumeClaim{
buildPVC("pvc-1", storageClassNameTopolvm),
},
[]*corev1.Pod{buildPod("pod1", testEmptyResources, testEmptyResources, "pvc-1")},
},
}

for _, tt := range tests {
Expand Down

0 comments on commit 09996d5

Please sign in to comment.