Skip to content

Conversation

marceloneppel
Copy link
Member

@marceloneppel marceloneppel commented Sep 3, 2024

Issue

The pgAudit plugin/extension is available in the latest revision of the Charmed PostgreSQL snap, but not in this charm.

Solution

Expose pgAudit as another plugin/extension charm config option and enable it when requested by:

  • Using the new snap, which contains the pgAudit plugin/extension.
  • Adding pgaudit to the PostgreSQL shared_preload_libraries parameter.
  • Configuring the requested parameters from DPE-2573 on lib/charms/postgresql_k8s/v0/postgresql.py.

Added new unit and integration tests.

Also, some adjustments were made in the plugin retrieval, which is used in the config-changed and database-requested hook handlers.

This is a port of canonical/postgresql-k8s-operator#688.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Copy link

codecov bot commented Sep 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.89%. Comparing base (01cfd3e) to head (e928fca).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #612      +/-   ##
==========================================
+ Coverage   70.81%   70.89%   +0.08%     
==========================================
  Files          12       12              
  Lines        3039     3048       +9     
  Branches      537      539       +2     
==========================================
+ Hits         2152     2161       +9     
  Misses        771      771              
  Partials      116      116              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
@marceloneppel marceloneppel marked this pull request as ready for review September 12, 2024 20:45
Copy link
Contributor

@taurus-forever taurus-forever left a comment

Choose a reason for hiding this comment

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

Nice!

config.yaml Outdated
type: boolean
description: Enable timescaledb extension
plugin_audit_enable:
default: false
Copy link
Contributor

Choose a reason for hiding this comment

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

JFYI, Audit plugin has been enabled on MySQL by default (for login actions only). Please check with @7annaba3l

@taurus-forever
Copy link
Contributor

Please update PR description: s/rock/snap/

@marceloneppel
Copy link
Member Author

Please update PR description: s/rock/snap/

Thanks, Alex! I updated the description.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
@marceloneppel
Copy link
Member Author

Enable pgAudit by default

Thanks for pointing that out, Alex! After syncing with Mohamed, I updated the plugin to enable it by default on 26ad2c0.

Copy link
Contributor

@taurus-forever taurus-forever left a comment

Choose a reason for hiding this comment

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

LGTM, but I would invert the test logic to be close to the real scenarios.

default: false
type: boolean
plugin_audit_enable:
default: false
Copy link
Contributor

Choose a reason for hiding this comment

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

We are testing possibility to enable pgaudit.
IMHO, we should keep default true, but test possibility of disabling it in the test below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! Fixed on e1d2916.

Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
@marceloneppel marceloneppel merged commit ca3c587 into main Sep 19, 2024
94 checks passed
@marceloneppel marceloneppel deleted the dpe-5248-add-pgaudit branch September 19, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants