mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-19 01:54:29 +02:00
Set maximum CPU and Memory requests on K8s (#1959)
* Set maximum CPU and Memory requests on K8s
This commit is contained in:
@@ -367,3 +367,21 @@ func IsSmallerQuantity(requestStr, limitStr string) (bool, error) {
|
||||
|
||||
return request.Cmp(limit) == -1, nil
|
||||
}
|
||||
|
||||
func MinResource(maxRequestStr, requestStr string) (resource.Quantity, error) {
|
||||
|
||||
isSmaller, err := IsSmallerQuantity(maxRequestStr, requestStr)
|
||||
if isSmaller && err == nil {
|
||||
maxRequest, err := resource.ParseQuantity(maxRequestStr)
|
||||
if err != nil {
|
||||
return maxRequest, err
|
||||
}
|
||||
return maxRequest, nil
|
||||
}
|
||||
|
||||
request, err := resource.ParseQuantity(requestStr)
|
||||
if err != nil {
|
||||
return request, err
|
||||
}
|
||||
return request, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user