Skip to content

Upstream 2071 - Add postgres_extra_settings for postgresql.conf overrides - #30

Merged
cigamit merged 2 commits into
ctrliq:develfrom
blaipr:feat/postgres-extra-settings
Aug 20, 2026
Merged

Upstream 2071 - Add postgres_extra_settings for postgresql.conf overrides#30
cigamit merged 2 commits into
ctrliq:develfrom
blaipr:feat/postgres-extra-settings

Conversation

@blaipr

@blaipr blaipr commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Upstream PR: ansible/awx-operator#2071

SUMMARY

Adds a postgres_extra_settings field to the AWX CRD. When set, the operator renders a ConfigMap of postgresql.conf overrides and mounts it into the managed postgres pod:

spec:
  postgres_extra_settings:
    - setting: max_connections
      value: "499"
    - setting: ssl_ciphers
      value: "HIGH:!aNULL:!MD5"

This supersedes postgres_extra_args, which upstream marks deprecated in the same change. That variable exists in this fork too, so the deprecation note applies as written.

Every template hunk is gated on postgres_extra_settings | length > 0, so with the field unset the rendered StatefulSet is unchanged.

ADDITIONAL INFORMATION

This one needed real adaptation rather than a clean cherry-pick, so the deviations from upstream are worth stating up front.

Task layout. Upstream applies the ConfigMap in roles/installer/tasks/database.yml. This fork has no such file — upstream split it out after the fork point, and its contents are still inside database_configuration.yml here (the two files' tails are identical). I placed the task at the equivalent point: immediately after Set database as managed, which is where upstream's ordering puts it relative to the surrounding tasks, and well before the statefulset that mounts the ConfigMap is applied.

Dropped from the upstream hunk. The conflicting hunk in statefulsets/postgres.yaml.j2 bundled two things belonging to other upstream changes:

  • postgres_annotations (from #1829) — not ported to this fork, and postgres_annotations is not defined in roles/installer/defaults/main.yml. Taking it verbatim would have put an undefined variable into the postgres StatefulSet template for every managed-database deploy.
  • checksum-secret-postgres_configuration_secret — unrelated to this feature.

I kept only the checksum-postgres_extra_settings annotation this feature needs, and wrapped annotations: inside the same conditional so an empty annotations: key isn't emitted when the field is unset.

Also dropped: upstream's .gitignore entry for hacking/ and dev/awx-cr/awx-db-configuration.cr.yml — this fork has no dev/ directory.

Verified rather than assumed: the ConfigMap mounts at /opt/app-root/src/postgresql-cfg, which is the sclorg config include directory, and this fork's _postgres_image is quay.io/sclorg/postgresql-15-c9s, so the path is right. The new template's ../common/templates/labels/common.yaml.j2 lookup is the same one the existing configmaps/config.yaml.j2 uses.

Not verified: I have no cluster to deploy this against, so it is untested beyond reading. The CRD parses.

The docs hunk lands in docs/user-guide/database-configuration.md, which #17 also touches, so one of the two will need a rebase.

ISSUE TYPE
  • New or Enhanced Feature
COMPONENT NAME
  • API (AWX CRD), installer role, Docs

…ides

Adds a postgres_extra_settings field to the AWX CRD. When set, the
operator renders a ConfigMap of postgresql.conf overrides and mounts it
into the managed postgres pod, superseding the deprecated
postgres_extra_args.

The upstream change targets roles/installer/tasks/database.yml, which
this fork does not have; its contents live in database_configuration.yml
here. The ConfigMap task is placed at the matching point, after the
database configuration facts are set and before the statefulset that
mounts it.

Ports ansible/awx-operator#2071.
@cigamit cigamit self-assigned this Aug 20, 2026
@cigamit cigamit added the enhancement New feature or request label Aug 20, 2026
@cigamit
cigamit requested a lite review from Copilot August 20, 2026 17:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for managing postgresql.conf overrides for the managed PostgreSQL instance via a new spec.postgres_extra_settings field on the AWX CRD. This introduces a rendered ConfigMap containing override snippets and mounts it into the managed Postgres pod, while marking the legacy postgres_extra_args as deprecated.

Changes:

  • Add spec.postgres_extra_settings to the AWX CRD and OLM CSV, and deprecate postgres_extra_args.
  • Render a postgres-extra-settings ConfigMap and mount it into the managed Postgres StatefulSet, triggering rollouts via checksum annotation.
  • Document the new field and update the Molecule example CR.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
roles/installer/templates/statefulsets/postgres.yaml.j2 Mounts the overrides ConfigMap and adds a checksum annotation to roll pods on changes.
roles/installer/templates/configmaps/postgres_extra_settings.yaml.j2 New template to render postgresql.conf override lines into a ConfigMap.
roles/installer/tasks/database_configuration.yml Applies the new ConfigMap during DB configuration.
roles/installer/defaults/main.yml Deprecation note for postgres_extra_args and default for postgres_extra_settings.
molecule/default/templates/awx_cr_molecule.yml.j2 Adds example postgres_extra_settings to the Molecule CR template.
docs/user-guide/database-configuration.md Documents postgres_extra_settings and deprecates postgres_extra_args.
config/manifests/bases/awx-operator.clusterserviceversion.yaml Exposes the new field in CSV descriptors and marks args deprecated.
config/crd/bases/awx.ansible.com_awxs.yaml Adds the new CRD schema for postgres_extra_settings.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +10 to +16
{% for pg_setting in postgres_extra_settings %}
{% if pg_setting.value is string %}
{{ pg_setting.setting }} = '{{ pg_setting.value }}'
{% else %}
{{ pg_setting.setting }} = {{ pg_setting.value }}
{% endif %}
{% endfor %}
k8s:
apply: true
definition: "{{ lookup('template', 'configmaps/postgres_extra_settings.yaml.j2') }}"
when: postgres_extra_settings | length
Comment on lines +142 to +144
- String values should be quoted in the YAML configuration.
- Numeric values can be provided as strings or numbers.
- Boolean values should be provided as strings ("on"/"off" or "true"/"false").
The CRD types value as a string, so the numeric branch in the ConfigMap
template was unreachable and a value containing a single quote rendered
an invalid postgresql.conf line. Values are now always rendered quoted,
with embedded single quotes doubled.

The ConfigMap was also created for external databases, where nothing
mounts it, so its creation is now gated on managed_database, and the
docs no longer suggest numeric values may be passed unquoted.
@blaipr

blaipr commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

All three review comments are addressed in be84aed.

  • ConfigMap template — the value is string branch is gone. value is always rendered as a quoted string with embedded single quotes doubled ({{ pg_setting.value | string | replace("'", "''") }}), which is the escaping postgresql.conf expects, so a value containing a quote no longer produces an invalid snippet.
  • ConfigMap creation for external databases — the task is now gated on managed_database | bool as well as a non-empty postgres_extra_settings, so nothing is created when an external database is configured.
  • Docs — the tip block now states that every value must be a string and that an unquoted number is rejected by the CRD schema, and the intro notes the parameter applies only to the managed PostgreSQL instance.

@cigamit
cigamit merged commit 132f8b5 into ctrliq:devel Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

3 participants