Skip to content

Commit 9a41525

Browse files
dragomirprenovate[bot]marceloneppela-velascoizmalk
authored
[MISC] Sync up changes from 14 (#834)
* [MISC] Use latest/stable lxd (#804) * Use latest stable lxd * Test tweaks * Test tweaks * Update canonical/data-platform-workflows action to v31.0.1 (#805) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [DPE-6874] Poll all members in the cluster topology script (#810) * Poll all members in the cluster topology script * Dual branch config * Unit tests and bugfixes * Add peers when starting the observer * Retry sync up checks * [DPE-6572] Add wal_keep_size config option (#799) * Add wal_keep_size config option Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Remove parameter addition Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Reset durability_wal_keep_size value to PG default Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> --------- Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> * Create pull_request_template.md (#814) * Create SECURITY.md (#822) * Update README file's security section (#827) * Refactor headings for syntax best practice * Update the Security section * Sync docs from Discourse (#796) Co-authored-by: GitHub Actions <41898282+github-actions[bot]@users.noreply.github.com> * [MISC] Conditional checksum calculation (#812) * Bump boto * Conditional checksum calculation * [DPE-6218] Static code analysis (#828) * Create tiobe_scan.yaml * Remove push trigger * Bump snap revisions * [MISC] Disable landscape subordinate test lxd (#831) * Set series for ubuntu-advantage test and disable the landscape test * Revert to LTS LXD --------- Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com> Co-authored-by: Andreia <andreia.velasco@canonical.com> Co-authored-by: Vladimir Izmalkov <48120135+izmalk@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 1902cf6 commit 9a41525

28 files changed

+559
-116
lines changed

.github/pull_request_template.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Issue
2+
3+
## Solution
4+
5+
## Checklist
6+
- [ ] I have added or updated any relevant documentation.
7+
- [ ] I have cleaned any remaining cloud resources from my accounts.

.github/workflows/tiobe_scan.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2025 Canonical Ltd.
2+
# See LICENSE file for licensing details.
3+
4+
name: Weekly TICS scan
5+
6+
on:
7+
schedule:
8+
- cron: "0 2 * * 6" # Every Saturday 2:00 AM UTC
9+
workflow_dispatch:
10+
11+
jobs:
12+
TICS:
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Create and activate virtual environment
19+
run: |
20+
python3 -m venv .venv
21+
. .venv/bin/activate
22+
pip install flake8 poetry pylint pytest tox
23+
poetry install --all-groups
24+
echo PATH="$PATH" >> "$GITHUB_ENV"
25+
26+
- name: Run coverage tests
27+
run: |
28+
tox -e unit
29+
30+
- name: Move results to the necessary folder for TICS
31+
run: |
32+
mkdir -p .cover
33+
mv coverage.xml .cover/cobertura.xml
34+
35+
- name: TICS GitHub Action
36+
uses: tiobe/tics-github-action@v3
37+
with:
38+
mode: qserver
39+
project: postgresql-operator
40+
viewerUrl: https://canonical.tiobe.com/tiobeweb/TICS/api/cfg?name=default
41+
branchdir: ${{ env.GITHUB_WORKSPACE }}
42+
ticsAuthToken: ${{ secrets.TICSAUTHTOKEN }}
43+
installTics: true
44+
calc: ALL

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ To deploy on Kubernetes, please use [Charmed PostgreSQL K8s Operator](https://ch
1212
This operator provides a PostgreSQL database with replication enabled: one primary instance and one (or more) hot standby replicas. The Operator in this repository is a Python script which wraps PostgreSQL versions distributed by Ubuntu Jammy series and adding [Patroni](https://github.com/zalando/patroni) on top of it, providing lifecycle management and handling events (install, configure, integrate, remove, etc).
1313

1414
## README contents
15+
1516
* [Basic usage](#basic-usage): Deploy and scale Charmerd PostgreSQL
1617
* [Integrations](#integrations-relations): Supported interfaces for integrations
1718
* [Contributing](#contributing)
@@ -20,6 +21,7 @@ This operator provides a PostgreSQL database with replication enabled: one prima
2021
## Basic usage
2122

2223
### Deployment
24+
2325
Bootstrap a [lxd controller](https://juju.is/docs/olm/lxd#heading--create-a-controller) and create a new Juju model:
2426

2527
```shell
@@ -46,7 +48,9 @@ To add replicas to an existing deployment, see the [Add replicas](#add-replicas)
4648
>It is generally recommended to have an odd number of units to avoid a "[split-brain](https://en.wikipedia.org/wiki/Split-brain_(computing))" scenario
4749
4850
### Primary replica
51+
4952
To retrieve the primary replica, use the action `get-primary` on any of the units running PostgreSQL.
53+
5054
```shell
5155
juju run postgresql/leader get-primary
5256
```
@@ -58,27 +62,33 @@ Similarly, the primary replica is displayed as a status message in `juju status`
5862
#### Add replicas
5963

6064
To add more replicas one can use the `juju add-unit` functionality i.e.
65+
6166
```shell
6267
juju add-unit postgresql -n <number_of_units_to_add>
6368
```
69+
6470
The implementation of `add-unit` allows the operator to add more than one unit, but functions internally by adding one replica at a time. This is done to avoid multiple replicas syncing from the primary at the same time.
6571

6672
#### Remove replicas
6773

6874
To scale down the number of replicas the `juju remove-unit` functionality may be used i.e.
75+
6976
```shell
7077
juju remove-unit postgresql <name_of_unit_1> <name_of_unit_2>
7178
```
79+
7280
The implementation of `remove-unit` allows the operator to remove more than one unit. The functionality of `remove-unit` functions by removing one replica at a time to avoid downtime.
7381

7482
### Password rotation
7583

7684
#### Charm users
7785

7886
To rotate the password of users internal to the Charmed PostgreSQL operator, use the `set-password` action as follows:
87+
7988
```shell
8089
juju run postgresql/leader set-password username=<user> password=<password>
8190
```
91+
8292
>[!NOTE]
8393
>Currently, internal users are `operator`, `replication`, `backup` and `rewind`. These users should not be used outside the operator.
8494
@@ -90,7 +100,7 @@ To rotate the passwords of users created for integrated applications, the integr
90100

91101
Supported [integrations](https://juju.is/docs/olm/relations):
92102

93-
#### New `postgresql_client` interface:
103+
#### New `postgresql_client` interface
94104

95105
Current charm relies on [Data Platform libraries](https://charmhub.io/data-platform-libs). Your
96106
application should define an interface in `metadata.yaml`:
@@ -125,14 +135,15 @@ To remove a relation:
125135
juju remove-relation postgresql <application_name>
126136
```
127137

128-
#### Legacy `pgsql` interface:
138+
#### Legacy `pgsql` interface
139+
129140
We have also added support for the two database legacy relations from the [original version](https://launchpad.net/postgresql-charm) of the charm via the `pgsql` interface. Please note that these relations will be deprecated.
130141
```shell
131142
juju relate postgresql:db mailman3-core
132143
juju relate postgresql:db-admin landscape-server
133144
```
134145

135-
#### `tls-certificates` interface:
146+
#### `tls-certificates` interface
136147

137148
The Charmed PostgreSQL Operator also supports TLS encryption on internal and external connections. Below is an example of enabling TLS with the [self-signed certificates charm](https://charmhub.io/self-signed-certificates).
138149

@@ -146,19 +157,24 @@ juju integrate postgresql self-signed-certificates
146157
# Disable TLS by removing relation.
147158
juju remove-relation postgresql self-signed-certificates
148159
```
160+
149161
>[!WARNING]
150162
>The TLS settings shown here are for self-signed-certificates, which are not recommended for production clusters. See the guide [Security with X.509 certificates](https://charmhub.io/topics/security-with-x-509-certificates) for an overview of available certificates charms.
151163

152164
## Security
153-
Security issues in the Charmed PostgreSQL Operator can be reported through [LaunchPad](https://wiki.ubuntu.com/DebuggingSecurity#How%20to%20File). Please do not use GitHub to submit security issues.
165+
166+
Security issues in the Charmed PostgreSQL Operator can be reported through [private security reports](https://github.com/canonical/postgresql-operator/security/advisories/new) on GitHub.
167+
For more information, see the [Security policy](SECURITY.md).
154168

155169
## Contributing
170+
156171
* For best practices on how to write and contribute to charms, see the [Juju SDK docs](https://juju.is/docs/sdk/how-to)
157172
* For more specific developer guidance for contributions to Charmed PostgreSQL, see the file [CONTRIBUTING.md](CONTRIBUTING.md)
158173
* Report security issues for the Charmed PostgreSQL Operator through [LaunchPad](https://wiki.ubuntu.com/DebuggingSecurity#How%20to%20File).
159174
* Report technical issues, bug reports and feature requests through the [GitHub Issues tab](https://github.com/canonical/postgresql-operator/issues).
160175

161176
## Licensing and trademark
177+
162178
The Charmed PostgreSQL Operator is distributed under the [Apache Software License, version 2.0](https://github.com/canonical/postgresql-operator/blob/main/LICENSE). It installs, operates and depends on [PostgreSQL](https://www.postgresql.org/ftp/source/), which is licensed under the [PostgreSQL License](https://www.postgresql.org/about/licence/), a liberal Open Source license similar to the BSD or MIT licenses.
163179

164180
PostgreSQL is a trademark or registered trademark of PostgreSQL Global Development Group. Other trademarks are property of their respective owners.

SECURITY.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Security policy
2+
3+
## What qualifies as a security issue
4+
5+
Credentials leakage, outdated dependencies with known vulnerabilities, and
6+
other issues that could lead to unprivileged or unauthorized access to the
7+
database or the system.
8+
9+
## Reporting a vulnerability
10+
11+
The easiest way to report a security issue is through
12+
[GitHub](https://github.com/canonical/postgresql-operator/security/advisories/new). See
13+
[Privately reporting a security
14+
vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)
15+
for instructions.
16+
17+
The repository admins will be notified of the issue and will work with you
18+
to determine whether the issue qualifies as a security issue and, if so, in
19+
which component. We will then handle figuring out a fix, getting a CVE
20+
assigned and coordinating the release of the fix.
21+
22+
The [Ubuntu Security disclosure and embargo
23+
policy](https://ubuntu.com/security/disclosure-policy) contains more
24+
information about what you can expect when you contact us, and what we
25+
expect from you.

config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ options:
3232
crashes and there are replicas.
3333
type: string
3434
default: "on"
35+
durability_wal_keep_size:
36+
description: |
37+
Sets the minimum size of the WAL file to be kept for the replication.
38+
Allowed values are: from 0 to 2147483647.
39+
type: int
40+
default: 4096
3541
experimental_max_connections:
3642
type: int
3743
description: |

docs/explanation.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
# Explanation
22

3-
This section contains pages with more detailed explanations that provide additional context about some of the key concepts behind the PostgreSQL charm:
3+
This section contains pages with more detailed explanations that provide additional context about key concepts behind the PostgreSQL charm.
44

5+
## Core concepts and design
56
* [Architecture]
67
* [Interfaces and endpoints]
8+
* [Juju]
9+
* [Legacy charm]
10+
11+
## Operational concepts
712
* [Connection pooling]
813
* [Users]
914
* [Logs]
10-
* [Juju]
11-
* [Legacy charm]
15+
16+
## Security and hardening
17+
* [Security hardening guide][Security]
18+
* [Cryptography]
19+
1220

1321
<!-- Links -->
1422

@@ -18,4 +26,6 @@ This section contains pages with more detailed explanations that provide additio
1826
[Logs]: /t/12099
1927
[Juju]: /t/11985
2028
[Legacy charm]: /t/10690
21-
[Connection pooling]: /t/15777
29+
[Connection pooling]: /t/15777
30+
[Security]: /t/16852
31+
[Cryptography]: /t/16853

docs/explanation/e-architecture.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ The snap "charmed-postgresql" also ships list of tools used by charm:
7575

7676
The charm "[PostgreSQL Test App](https://charmhub.io/postgresql-test-app)" is a Canonical test application to validate the charm installation / functionality and perform the basic performance tests.
7777

78+
### GLAuth
79+
80+
GLAuth is a secure, easy-to-use and open-sourced LDAP server which provides capabilities to centrally manage accounts across infrastructures. The charm is only available for Kubernetes clouds, under the [GLAuth-K8s operator](https://charmhub.io/glauth-k8s) page, so a cross-controller relation is needed in order to integrate both charms.
81+
7882
### Grafana
7983

8084
Grafana is an open-source visualization tools that allows to query, visualize, alert on, and visualize metrics from mixed datasources in configurable dashboards for observability. This charms is shipped with its own Grafana dashboard and supports integration with the [Grafana Operator](https://charmhub.io/grafana-k8s) to simplify observability. Please follow [COS Monitoring](/t/10600) setup.

docs/explanation/e-users.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Charm Users explanations
22

3-
There are two types of users in PostgreSQL:
3+
There are three types of users in PostgreSQL:
44
* Internal users (used by charm operator)
5-
* Relation/integration users (used by related applications)
5+
* Relation users (used by related applications)
66
* Extra user roles (if default permissions are not enough)
7+
* Identity users (used when LDAP is enabled)
78

89
<a name="internal-users"></a>
910
## Internal users explanations:
@@ -72,7 +73,7 @@ unit-postgresql-1:
7273
**Note**: the action `set-password` must be executed on juju leader unit (to update peer relation data with new value).
7374
7475
<a name="relation-users"></a>
75-
## Relation/integration users explanations:
76+
## Relation users explanations:
7677
7778
The operator created a dedicated user for every application related/integrated with database. Those users are removed on the juju relation/integration removal request. However, DB data stays in place and can be reused on re-created relations (using new user credentials):
7879
@@ -99,4 +100,10 @@ postgres=# \du
99100
100101
When an application charm requests a new user through the relation/integration it can specify that the user should have the `admin` role in the `extra-user-roles` field. The `admin` role enables the new user to read and write to all databases (for the `postgres` system database it can only read data) and also to create and delete non-system databases.
101102
102-
**Note**: `extra-user-roles` is supported by modern interface `postgresql_client` only and missing for legacy `pgsql` interface. Read more about the supported charm interfaces [here](/t/10251).
103+
**Note**: `extra-user-roles` is supported by modern interface `postgresql_client` only and missing for legacy `pgsql` interface. Read more about the supported charm interfaces [here](/t/10251).
104+
105+
<a name="identity-users"></a>
106+
## Identity users explanations:
107+
The operator considers Identity users all those that are automatically created when the LDAP integration is enabled, or in other words, the [GLAuth](https://charmhub.io/glauth-k8s) charm is related/integrated.
108+
109+
When synchronized from the LDAP server, these users do not have any permissions by default, so the LDAP group they belonged to must be mapped to a PostgreSQL pre-defined authorization role by using the `ldap_map` configuration option.

docs/how-to.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The following guides cover key processes and common tasks for managing and using
44

55
## Deployment and setup
66

7-
The following guides walk you through the details of how to install different cloud services and bootstrap them to Juju:
7+
Installation of different cloud services with Juju:
88
* [Sunbeam]
99
* [LXD]
1010
* [MAAS]
@@ -13,7 +13,7 @@ The following guides walk you through the details of how to install different cl
1313
* [Azure]
1414
* [Multi-availability zones (AZ)][Multi-AZ]
1515

16-
The following guides cover some specific deployment scenarios and architectures:
16+
Specific deployment scenarios and architectures:
1717
* [Terraform]
1818
* [Air-gapped]
1919
* [TLS VIP access]
@@ -54,7 +54,7 @@ The following guides cover some specific deployment scenarios and architectures:
5454

5555
## Development
5656

57-
This section is aimed at charm developers looking to support PostgreSQL integrations with their charm.
57+
This section is for charm developers looking to support PostgreSQL integrations with their charm.
5858

5959
* [Integrate with your charm]
6060
* [Migrate data via pg_dump]

docs/how-to/h-deploy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Then, either continue with the `juju` client **or** use the `terraform juju` cli
2121

2222
To deploy with the `juju` client:
2323
```shell
24-
juju deploy postgresql
24+
juju deploy postgresql -n <number_of_replicas>
2525
```
2626
> See also: [`juju deploy` command](https://canonical-juju.readthedocs-hosted.com/en/latest/user/reference/juju-cli/list-of-juju-cli-commands/deploy/)
2727

0 commit comments

Comments
 (0)