Skip to content

Commit

Permalink
Allow empty resources for CPU and Memory in Katib config (#1564)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreyvelich authored Jun 29, 2021
1 parent 9b33615 commit 61d7008
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/util/v1beta1/katibconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,18 @@ func setResourceRequirements(configResource corev1.ResourceRequirements) corev1.
configResource.Limits[corev1.ResourceEphemeralStorage] = defaultDiskLimit
}

// If user explicitly sets CPU value to -1, nuke it.
if cpuLimit.Sign() == -1 && cpuRequest.Sign() == -1 {
delete(configResource.Limits, corev1.ResourceCPU)
delete(configResource.Requests, corev1.ResourceCPU)
}

// If user explicitly sets Memory value to -1, nuke it.
if memLimit.Sign() == -1 && memRequest.Sign() == -1 {
delete(configResource.Limits, corev1.ResourceMemory)
delete(configResource.Requests, corev1.ResourceMemory)
}

// If user explicitly sets ephemeral-storage value to something negative, nuke it.
// This enables compability with the GKE nodepool autoscalers, which cannot scale
// pods which define ephemeral-storage resource constraints.
Expand Down

0 comments on commit 61d7008

Please sign in to comment.