Skip to content

Commit 94f31bd

Browse files
[DPE-6965] Bump snap revision to 197/198 (#1024)
Issue: The snap user snap_daemon has been deprecated by SNAP team, see: https://forum.snapcraft.io/t/system-usernames/13386 Also the newer charmed-postgresql snap is available with new parts there. Solution: * bump snap revision to 197/198. Use _daemon_ (UID:584792) instead of snap_daemon (UID:584788) temporary disable upgrade tests due to snap user change. * upgrade tests will be re-enabled after releasing to edge, as we do not provide upgrade path for snap ownership changes. Upgrade path is unnecessary here, as it is a first stable release to PG16 charm. * stop creating $SNAP_COMMON/data/db (unnecessary) + polishing * new snap adds postgresql-16-repack PG extentions
1 parent 4d6ef0b commit 94f31bd

File tree

18 files changed

+62
-56
lines changed

18 files changed

+62
-56
lines changed

docs/explanation/logs.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ PostgreSQL and Patroni logs can be found in `/var/snap/charmed-postgresql/common
1111
```text
1212
> ls -alh /var/snap/charmed-postgresql/common/var/log/postgresql
1313
total 20K
14-
drwxr-xr-x 2 snap_daemon root 4.0K Oct 11 15:09 .
15-
drwxr-xr-x 6 snap_daemon root 4.0K Oct 11 15:04 ..
16-
-rw------- 1 snap_daemon snap_daemon 4.3K Oct 11 15:05 postgresql-3_1505.log
17-
-rw------- 1 snap_daemon snap_daemon 0 Oct 11 15:06 postgresql-3_1506.log
18-
-rw------- 1 snap_daemon snap_daemon 0 Oct 11 15:07 postgresql-3_1507.log
19-
-rw------- 1 snap_daemon snap_daemon 817 Oct 11 15:08 postgresql-3_1508.log
20-
-rw------- 1 snap_daemon snap_daemon 0 Oct 11 15:09 postgresql-3_1509.log
14+
drwxr-xr-x 2 _daemon_ root 4.0K Oct 11 15:09 .
15+
drwxr-xr-x 6 _daemon_ root 4.0K Oct 11 15:04 ..
16+
-rw------- 1 _daemon_ _daemon_ 4.3K Oct 11 15:05 postgresql-3_1505.log
17+
-rw------- 1 _daemon_ _daemon_ 0 Oct 11 15:06 postgresql-3_1506.log
18+
-rw------- 1 _daemon_ _daemon_ 0 Oct 11 15:07 postgresql-3_1507.log
19+
-rw------- 1 _daemon_ _daemon_ 817 Oct 11 15:08 postgresql-3_1508.log
20+
-rw------- 1 _daemon_ _daemon_ 0 Oct 11 15:09 postgresql-3_1509.log
2121
```
2222

2323
```text
2424
> ls -alh /var/snap/charmed-postgresql/common/var/log/patroni/
2525
total 28K
26-
drwxr-xr-x 2 snap_daemon root 4.0K Oct 11 15:29 .
27-
drwxr-xr-x 6 snap_daemon root 4.0K Oct 11 15:25 ..
28-
-rw-r--r-- 1 snap_daemon snap_daemon 356 Oct 11 15:29 patroni.log
29-
-rw-r--r-- 1 snap_daemon snap_daemon 534 Oct 11 15:28 patroni.log.1
30-
-rw-r--r-- 1 snap_daemon snap_daemon 520 Oct 11 15:27 patroni.log.2
31-
-rw-r--r-- 1 snap_daemon snap_daemon 584 Oct 11 15:27 patroni.log.3
32-
-rw-r--r-- 1 snap_daemon snap_daemon 464 Oct 11 15:27 patroni.log.4
26+
drwxr-xr-x 2 _daemon_ root 4.0K Oct 11 15:29 .
27+
drwxr-xr-x 6 _daemon_ root 4.0K Oct 11 15:25 ..
28+
-rw-r--r-- 1 _daemon_ _daemon_ 356 Oct 11 15:29 patroni.log
29+
-rw-r--r-- 1 _daemon_ _daemon_ 534 Oct 11 15:28 patroni.log.1
30+
-rw-r--r-- 1 _daemon_ _daemon_ 520 Oct 11 15:27 patroni.log.2
31+
-rw-r--r-- 1 _daemon_ _daemon_ 584 Oct 11 15:27 patroni.log.3
32+
-rw-r--r-- 1 _daemon_ _daemon_ 464 Oct 11 15:27 patroni.log.4
3333
```
3434

3535
The PostgreSQL log naming convention is `postgresql-<weekday>_<hour><minute>.log`. The log message format is `<date> <time> UTC [<pid>]: <connection details> <level>: <message>`. E.g:
@@ -64,11 +64,11 @@ If S3 backups are enabled, Pgbackrest logs would be located in `/var/snap/charme
6464
```text
6565
> ls -alh /var/snap/charmed-postgresql/common/var/log/pgbackrest/
6666
total 20K
67-
drwxr-xr-x 2 snap_daemon root 4.0K Oct 11 15:14 .
68-
drwxr-xr-x 6 snap_daemon root 4.0K Oct 11 15:04 ..
69-
-rw-r----- 1 snap_daemon snap_daemon 1.7K Oct 11 15:14 pg.pg-backup.log
70-
-rw-r----- 1 snap_daemon snap_daemon 717 Oct 11 15:14 pg.pg-expire.log
71-
-rw-r----- 1 snap_daemon snap_daemon 859 Oct 11 15:08 pg.pg-stanza-create.log
67+
drwxr-xr-x 2 _daemon_ root 4.0K Oct 11 15:14 .
68+
drwxr-xr-x 6 _daemon_ root 4.0K Oct 11 15:04 ..
69+
-rw-r----- 1 _daemon_ _daemon_ 1.7K Oct 11 15:14 pg.pg-backup.log
70+
-rw-r----- 1 _daemon_ _daemon_ 717 Oct 11 15:14 pg.pg-expire.log
71+
-rw-r----- 1 _daemon_ _daemon_ 859 Oct 11 15:08 pg.pg-stanza-create.log
7272
```
7373

7474
The naming convention of the Pgbackrest logs is `<model name>.patroni-<postgresql app name>-<action>.log`. Log output should look similar to:

docs/how-to/switchover-failover.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Find the current primary/standby/replica:
7373

7474
```text
7575
> juju ssh postgresql/0
76-
ubuntu@juju-422c1a-0:~$ sudo -u snap_daemon patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml list
76+
ubuntu@juju-422c1a-0:~$ sudo -u _daemon_ patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml list
7777
+ Cluster: postgresql (7499430436963402504) ---+-----------+----+-----------+
7878
| Member | Host | Role | State | TL | Lag in MB |
7979
+--------------+----------------+--------------+-----------+----+-----------+

docs/reference/troubleshooting/cli-helpers.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Learn more about Patroni in the [Architecture](/explanation/architecture) page.
2121

2222
The main Patroni tool is `patronictl`.
2323

24-
**It should only be used under the snap context**, via the user `snap_daemon`.
24+
**It should only be used under the snap context**, via the user `_daemon_`.
2525

2626
#### Cluster status
2727

@@ -34,7 +34,7 @@ The main Patroni tool is `patronictl`.
3434
> juju ssh postgresql/2
3535
...
3636
37-
ubuntu@juju-b87344-2:~$ sudo -u snap_daemon patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml topology
37+
ubuntu@juju-b87344-2:~$ sudo -u _daemon_ patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml topology
3838
+ Cluster: postgresql (7496847632512033809) ------+-----------+----+-----------+
3939
| Member | Host | Role | State | TL | Lag in MB |
4040
+-----------------+----------------+--------------+-----------+----+-----------+
@@ -53,7 +53,7 @@ Use `--help` to find all the available Patroni actions.
5353
<details><summary>Example: Patroni actions</summary>
5454

5555
```text
56-
> sudo -u snap_daemon patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml --help
56+
> sudo -u _daemon_ patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml --help
5757
...
5858
failover Failover to a replica
5959
history Show the history of failovers/switchovers
@@ -78,7 +78,7 @@ Patroni can perform a low-level [switchover/failover](https://patroni.readthedoc
7878
<details><summary>Example: switchover (healthy cluster only)</summary>
7979

8080
```text
81-
ubuntu@juju-b87344-2:~$ sudo -u snap_daemon patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml switchover postgresql --candidate postgresql-2 --force
81+
ubuntu@juju-b87344-2:~$ sudo -u _daemon_ patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml switchover postgresql --candidate postgresql-2 --force
8282
Current cluster topology
8383
+ Cluster: postgresql (7496847632512033809) ----+-----------+----+-----------+
8484
| Member | Host | Role | State | TL | Lag in MB |
@@ -96,7 +96,7 @@ Current cluster topology
9696
| postgresql-3 | 10.189.210.26 | Replica | stopped | | unknown |
9797
+---------------+----------------+---------+-----------+----+-----------+
9898
99-
ubuntu@juju-b87344-2:~$ sudo -u snap_daemon patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml list
99+
ubuntu@juju-b87344-2:~$ sudo -u _daemon_ patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml list
100100
+ Cluster: postgresql (7496847632512033809) ----+-----------+----+-----------+
101101
| Member | Host | Role | State | TL | Lag in MB |
102102
+---------------+----------------+--------------+-----------+----+-----------+
@@ -110,7 +110,7 @@ ubuntu@juju-b87344-2:~$ sudo -u snap_daemon patronictl -c /var/snap/charmed-post
110110
<details><summary>Example: failover</summary>
111111

112112
```text
113-
ubuntu@juju-b87344-2:~$ sudo -u snap_daemon patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml failover postgresql --candidate postgresql-3
113+
ubuntu@juju-b87344-2:~$ sudo -u _daemon_ patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml failover postgresql --candidate postgresql-3
114114
Current cluster list
115115
+ Cluster: postgresql (7496847632512033809) ----+-----------+----+-----------+
116116
| Member | Host | Role | State | TL | Lag in MB |
@@ -129,14 +129,14 @@ Are you sure you want to failover cluster postgresql, demoting current leader po
129129
| postgresql-3 | 10.189.210.26 | Leader | running | 1 | |
130130
+---------------+----------------+---------+---------+----+-----------+
131131
132-
ubuntu@juju-b87344-2:~$ sudo -u snap_daemon patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml history
132+
ubuntu@juju-b87344-2:~$ sudo -u _daemon_ patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml history
133133
+----+-----------+------------------------------+----------------------------------+--------------+
134134
| TL | LSN | Reason | Timestamp | New Leader |
135135
+----+-----------+------------------------------+----------------------------------+--------------+
136136
| 1 | 335544480 | no recovery target specified | 2025-04-25T04:44:53.137152+00:00 | postgresql-3 |
137137
+----+-----------+------------------------------+----------------------------------+--------------+
138138
139-
ubuntu@juju-b87344-2:~$ sudo -u snap_daemon patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml list
139+
ubuntu@juju-b87344-2:~$ sudo -u _daemon_ patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml list
140140
+ Cluster: postgresql (7496847632512033809) ----+-----------+----+-----------+
141141
| Member | Host | Role | State | TL | Lag in MB |
142142
+---------------+----------------+--------------+-----------+----+-----------+
@@ -154,7 +154,7 @@ Sometimes the cluster member might stuck in the middle of nowhere, the easiest w
154154
<details><summary>Example: cluster member re-initialization</summary>
155155

156156
```text
157-
ubuntu@juju-b87344-2:~$ sudo -u snap_daemon patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml reinit postgresql postgresql-1
157+
ubuntu@juju-b87344-2:~$ sudo -u _daemon_ patronictl -c /var/snap/charmed-postgresql/current/etc/patroni/patroni.yaml reinit postgresql postgresql-1
158158
+ Cluster: postgresql (7496847632512033809) ----+-----------+----+-----------+
159159
| Member | Host | Role | State | TL | Lag in MB |
160160
+---------------+----------------+--------------+-----------+----+-----------+

docs/reference/troubleshooting/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ The Patroni/PostgreSQL logs are located inside the snap:
4848
> ls -la /var/snap/charmed-postgresql/common/var/log/*
4949
5050
/var/snap/charmed-postgresql/common/var/log/patroni:
51-
-rw-r--r-- 1 snap_daemon snap_daemon 292519 Sep 15 21:47 patroni.log
51+
-rw-r--r-- 1 _daemon_ _daemon_ 292519 Sep 15 21:47 patroni.log
5252
5353
/var/snap/charmed-postgresql/common/var/log/pgbackrest:
54-
-rw-r----- 1 snap_daemon snap_daemon 7337 Sep 15 21:46 all-server.log
55-
-rw-r----- 1 snap_daemon snap_daemon 5858 Sep 15 10:41 testbet.postgresql-stanza-create.log
54+
-rw-r----- 1 _daemon_ _daemon_ 7337 Sep 15 21:46 all-server.log
55+
-rw-r----- 1 _daemon_ _daemon_ 5858 Sep 15 10:41 testbet.postgresql-stanza-create.log
5656
5757
/var/snap/charmed-postgresql/common/var/log/pgbouncer:
5858
# The pgBouncer should be stopped on Charmed PostgreSQL deployments and produce no logs.

refresh_versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ name = "charmed-postgresql"
66

77
[snap.revisions]
88
# amd64
9-
x86_64 = "183"
9+
x86_64 = "197"
1010
# arm64
11-
aarch64 = "185"
11+
aarch64 = "198"

scripts/cluster_topology_observer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def check_for_database_changes(run_cmd, unit, charm_dir, previous_databases):
102102
"-E",
103103
"-H",
104104
"-u",
105-
"snap_daemon",
105+
"_daemon_",
106106
"charmed-postgresql.patronictl",
107107
"-c",
108108
conf_file_path,

src/backups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def _execute_command(
344344
"""Execute a command in the workload container."""
345345

346346
def demote():
347-
pw_record = pwd.getpwnam("snap_daemon")
347+
pw_record = pwd.getpwnam("_daemon_")
348348

349349
def result():
350350
os.setgid(pw_record.pw_gid)

src/charm.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,15 +1324,15 @@ def _on_install(self, event: InstallEvent) -> None:
13241324
except snap.SnapError:
13251325
logger.warning("Unable to create psql alias")
13261326

1327-
# Create the user home directory for the snap_daemon user.
1327+
# Create the user home directory for the _daemon_ user.
13281328
# This is needed due to https://bugs.launchpad.net/snapd/+bug/2011581.
13291329
try:
13301330
# Input is hardcoded
1331-
subprocess.check_call(["mkdir", "-p", "/home/snap_daemon"]) # noqa: S607
1332-
subprocess.check_call(["chown", "snap_daemon:snap_daemon", "/home/snap_daemon"]) # noqa: S607
1333-
subprocess.check_call(["usermod", "-d", "/home/snap_daemon", "snap_daemon"]) # noqa: S607
1331+
subprocess.check_call(["mkdir", "-p", "/home/_daemon_"]) # noqa: S607
1332+
subprocess.check_call(["chown", "_daemon_:_daemon_", "/home/_daemon_"]) # noqa: S607
1333+
subprocess.check_call(["usermod", "-d", "/home/_daemon_", "_daemon_"]) # noqa: S607
13341334
except subprocess.CalledProcessError:
1335-
logger.exception("Unable to create snap_daemon home dir")
1335+
logger.exception("Unable to create _daemon_ home dir")
13361336

13371337
self.set_unit_status(WaitingStatus("waiting to start PostgreSQL"))
13381338

src/cluster.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ def _change_owner(self, path: str) -> None:
218218
Args:
219219
path: path to a file or directory.
220220
"""
221-
# Get the uid/gid for the snap_daemon user.
222-
user_database = pwd.getpwnam("snap_daemon")
221+
# Get the uid/gid for the _daemon_ user.
222+
user_database = pwd.getpwnam("_daemon_")
223223
# Set the correct ownership for the file or directory.
224224
os.chown(path, uid=user_database.pw_uid, gid=user_database.pw_gid)
225225

@@ -590,7 +590,7 @@ def render_file(self, path: str, content: str, mode: int, change_owner: bool = T
590590
mode: access permission mask applied to the
591591
file using chmod (e.g. 0o640).
592592
change_owner: whether to change the file owner
593-
to the snap_daemon user.
593+
to the _daemon_ user.
594594
"""
595595
# TODO: keep this method to use it also for generating replication configuration files and
596596
# move it to an utils / helpers file.

src/relations/async_replication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def get_system_identifier(self) -> tuple[str | None, str | None]:
336336
"""Returns the PostgreSQL system identifier from this instance."""
337337

338338
def demote():
339-
pw_record = pwd.getpwnam("snap_daemon")
339+
pw_record = pwd.getpwnam("_daemon_")
340340

341341
def result():
342342
os.setgid(pw_record.pw_gid)

0 commit comments

Comments
 (0)