From e6b11084db5d71be46677b078a8523c536b1697f Mon Sep 17 00:00:00 2001 From: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> Date: Tue, 14 Nov 2023 13:41:30 -0600 Subject: [PATCH] Omit storage resource limit if empty (#1637) We discovered some weird behavior observed on later Kubernetes version (OCP 4.12+) For some reason why we apply the templates postgres resource with ``` postgres_storage_requirements: limit: {} requests: storage: Gi ``` the `Create Database if no database is specified` task that does the k8s apply will always think the resource is "changed" and proceed to cycle the task and web pod This resulted in AWX pods being continuously restarted Update postgres.yaml.j2 --- .../templates/statefulsets/postgres.yaml.j2 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/roles/installer/templates/statefulsets/postgres.yaml.j2 b/roles/installer/templates/statefulsets/postgres.yaml.j2 index 0e60fb4f..ce4e2141 100644 --- a/roles/installer/templates/statefulsets/postgres.yaml.j2 +++ b/roles/installer/templates/statefulsets/postgres.yaml.j2 @@ -33,7 +33,7 @@ spec: app.kubernetes.io/instance: 'postgres-{{ supported_pg_version }}-{{ ansible_operator_meta.name }}' app.kubernetes.io/component: 'database' app.kubernetes.io/part-of: '{{ ansible_operator_meta.name }}' - app.kubernetes.io/managed-by: '{{ deployment_type }}-operator' + app.kubernetes.io/managed-by: '{{ deployment_type }}-operator' spec: {% if image_pull_secret is defined %} imagePullSecrets: @@ -137,7 +137,15 @@ spec: {% if postgres_storage_class is defined %} storageClassName: '{{ postgres_storage_class }}' {% endif %} - resources: {{ postgres_storage_requirements }} + resources: +{% if postgres_storage_requirements.limits.storage | default("", true) %} + limits: + storage: {{ postgres_storage_requirements.limits.storage }} +{% endif %} +{% if postgres_storage_requirements.requests.storage | default("", true) %} + requests: + storage: {{ postgres_storage_requirements.requests.storage }} +{% endif %} # Postgres Service. ---