Skip to content

Commit

Permalink
Omit storage resource limit if empty
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
  • Loading branch information
TheRealHaoLiu committed Nov 14, 2023
1 parent 669fe1d commit d356c3d
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 }}
{% 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.
---
Expand Down

0 comments on commit d356c3d

Please sign in to comment.