zalando / postgres-operator

Postgres operator creates and manages PostgreSQL clusters running in Kubernetes
https://postgres-operator.readthedocs.io/
MIT License
4.37k stars 980 forks source link

Fix resource constraints #2735

Closed dmotte closed 1 month ago

dmotte commented 3 months ago

The documentation about postgres_pod_resources says that you can disable the defaults by setting them to zero OR empty string:

Empty string or 0 disables the default.

Source: https://github.com/zalando/postgres-operator/blob/2582b934bfb5bfaba9e5d7116ef270e507c5d6a2/docs/reference/operator_parameters.md#L570-L604

But it's not currently possible to set them to empty string, due to the regular expressions in charts/postgres-operator/crds/operatorconfigurations.yaml.

Also, the enforceMinResourceLimits function currently supports only the empty string case, which is impossible to use due to the aforementioned regexes.

This PR aims to fix these two issues 🙂

FxKu commented 3 months ago

@dmotte thanks! Could you provide also unit tests that cover this "new" behavior so I could also try them on the main branch and see what doesn't work? This would be a great improvement to this PR.

dmotte commented 3 months ago

@FxKu done :slightly_smiling_face: I hope it's ok

FxKu commented 2 months ago

Seems to me that only the schema validation needs to change. It's still good though to add a "0" example to the unit test.

dmotte commented 2 months ago

@FxKu yeah, I think I got your point and you are right :)

Just to double check, correct me if I'm wrong: util.IsSmallerQuantity(somePositiveQuantity, "0") returns false, so isSmaller ends up being false and the limit is not enforced.

Thank you! Fixed in 24df591

FxKu commented 2 months ago

Thanks. Can you also update these files with the new validation pattern:

dmotte commented 2 months ago

@FxKu I think you meant manifests/operatorconfiguration.crd.yaml instead of manifests/postgresql.crd.yaml, so I updated that one instead. Done in 107fe9b :wink: let me know if it's OK or you have other requests

FxKu commented 2 months ago

:+1:

idanovinda commented 1 month ago

👍