mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-09 07:15:57 +02:00
Fix resource constraints (#2735)
* Add empty string cases to patterns for pod resources * Added empty strings test case * Restored k8sres.go and changed test to zeros * Updated validation pattern in manifests/operatorconfiguration.crd.yaml and pkg/apis/acid.zalan.do/v1/crds.go
This commit is contained in:
@@ -2993,6 +2993,44 @@ func TestGenerateResourceRequirements(t *testing.T) {
|
||||
ResourceRequests: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("100m"), Memory: k8sutil.StringToPointer("100Mi")},
|
||||
},
|
||||
},
|
||||
{
|
||||
subTest: "test generation of resources when min limits are all set to zero",
|
||||
config: config.Config{
|
||||
Resources: config.Resources{
|
||||
ClusterLabels: map[string]string{"application": "spilo"},
|
||||
ClusterNameLabel: clusterNameLabel,
|
||||
DefaultCPURequest: "0",
|
||||
DefaultCPULimit: "0",
|
||||
MaxCPURequest: "0",
|
||||
MinCPULimit: "0",
|
||||
DefaultMemoryRequest: "0",
|
||||
DefaultMemoryLimit: "0",
|
||||
MaxMemoryRequest: "0",
|
||||
MinMemoryLimit: "0",
|
||||
PodRoleLabel: "spilo-role",
|
||||
},
|
||||
PodManagementPolicy: "ordered_ready",
|
||||
SetMemoryRequestToLimit: false,
|
||||
},
|
||||
pgSpec: acidv1.Postgresql{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: clusterName,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Spec: acidv1.PostgresSpec{
|
||||
Resources: &acidv1.Resources{
|
||||
ResourceLimits: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("5m"), Memory: k8sutil.StringToPointer("5Mi")},
|
||||
},
|
||||
TeamID: "acid",
|
||||
Volume: acidv1.Volume{
|
||||
Size: "1G",
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedResources: acidv1.Resources{
|
||||
ResourceLimits: acidv1.ResourceDescription{CPU: k8sutil.StringToPointer("5m"), Memory: k8sutil.StringToPointer("5Mi")},
|
||||
},
|
||||
},
|
||||
{
|
||||
subTest: "test matchLimitsWithRequestsIfSmaller",
|
||||
config: config.Config{
|
||||
|
||||
Reference in New Issue
Block a user