From d356c3dbd83b7fed9478d0b5943611a323d21d11 Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Mon, 13 Nov 2023 21:35:25 -0600 Subject: [PATCH] Omit storage resource limit if empty 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 --- .../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 0e60fb4f7f..cfbdacbfa6 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 }} +{% if postgres_storage_requirements.limit or postgres_storage_requirements.requests %} + resources: +{% if postgres_storage_requirements.limit %} + limit: {{ postgres_storage_requirements.limit }} +{% endif %} +{% if postgres_storage_requirements.requests %} + request: {{ postgres_storage_requirements.requests }} +{% endif %} +{% endif %} # Postgres Service. ---