Skip to content

Commit

Permalink
Omit storage resource limit if empty (#1637)
Browse files Browse the repository at this point in the history
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: <x>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
  • Loading branch information
TheRealHaoLiu authored Nov 14, 2023
1 parent 669fe1d commit e6b1108
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions roles/installer/templates/statefulsets/postgres.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
---
Expand Down

0 comments on commit e6b1108

Please sign in to comment.