postgresql-charms-single-kernel 16.0.2__py3-none-any.whl → 16.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {postgresql_charms_single_kernel-16.0.2.dist-info → postgresql_charms_single_kernel-16.1.0.dist-info}/METADATA +1 -1
- postgresql_charms_single_kernel-16.1.0.dist-info/RECORD +11 -0
- single_kernel_postgresql/abstract_charm.py +2 -1
- single_kernel_postgresql/config/literals.py +9 -0
- single_kernel_postgresql/utils/postgresql.py +23 -3
- postgresql_charms_single_kernel-16.0.2.dist-info/RECORD +0 -11
- {postgresql_charms_single_kernel-16.0.2.dist-info → postgresql_charms_single_kernel-16.1.0.dist-info}/WHEEL +0 -0
- {postgresql_charms_single_kernel-16.0.2.dist-info → postgresql_charms_single_kernel-16.1.0.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: postgresql-charms-single-kernel
|
|
3
|
-
Version: 16.0
|
|
3
|
+
Version: 16.1.0
|
|
4
4
|
Summary: Shared and reusable code for PostgreSQL-related charms
|
|
5
5
|
Author-email: Canonical Data Platform <data-platform@lists.launchpad.net>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
single_kernel_postgresql/__init__.py,sha256=F57JUcML43xgR0kpj9csryZkAoDSBPLLRjzSTHPaTd4,116
|
|
2
|
+
single_kernel_postgresql/abstract_charm.py,sha256=jWYV7nTZLiwxCZEedMZwyXzU3iNDRUcz5ZdI4LGUkUw,841
|
|
3
|
+
single_kernel_postgresql/config/__init__.py,sha256=k9Ud5ZZNd3l0nn8xi8AIlT45oZk8hJ542BjAFGDJzuc,140
|
|
4
|
+
single_kernel_postgresql/config/literals.py,sha256=88r33TBX7SXqgpV6EEXtZmSJrfOtsFiVJ_omop0RuBo,643
|
|
5
|
+
single_kernel_postgresql/utils/__init__.py,sha256=VwAEW3wYjs99q38bid47aS6Os4s3catK4H5HfdPkp94,121
|
|
6
|
+
single_kernel_postgresql/utils/filesystem.py,sha256=CJ2iXqFPKM0NfqqZSTDlENOrM0RW7rmTmcuzwV0bR9A,552
|
|
7
|
+
single_kernel_postgresql/utils/postgresql.py,sha256=qtyawiqZG-rlFIeKFpXhBl2m2aCi8sgEIF7YgCKw-XA,76654
|
|
8
|
+
postgresql_charms_single_kernel-16.1.0.dist-info/METADATA,sha256=n5gts0rhk9hCZebYKPLPvpU1are6VsW2SG93pYmTw-0,484
|
|
9
|
+
postgresql_charms_single_kernel-16.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
postgresql_charms_single_kernel-16.1.0.dist-info/top_level.txt,sha256=fH85HKyfDV3--1JuYe-rWJmN5XTlXVXGOBO5iNA36Rk,25
|
|
11
|
+
postgresql_charms_single_kernel-16.1.0.dist-info/RECORD,,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
from ops.charm import CharmBase
|
|
6
6
|
|
|
7
|
-
from .config.literals import SYSTEM_USERS, USER
|
|
7
|
+
from .config.literals import SYSTEM_USERS, USER, Substrates
|
|
8
8
|
from .utils.postgresql import PostgreSQL
|
|
9
9
|
|
|
10
10
|
|
|
@@ -15,6 +15,7 @@ class AbstractPostgreSQLCharm(CharmBase):
|
|
|
15
15
|
super().__init__(*args)
|
|
16
16
|
|
|
17
17
|
self.postgresql = PostgreSQL(
|
|
18
|
+
substrate=Substrates.VM,
|
|
18
19
|
primary_host="localhost",
|
|
19
20
|
current_host="localhost",
|
|
20
21
|
user=USER,
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
This module should contain the literals used in the charms (paths, enums, etc).
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
from enum import Enum
|
|
9
|
+
|
|
8
10
|
# Permissions.
|
|
9
11
|
POSTGRESQL_STORAGE_PERMISSIONS = 0o700
|
|
10
12
|
|
|
@@ -19,3 +21,10 @@ REWIND_USER = "rewind"
|
|
|
19
21
|
SNAP_USER = "_daemon_"
|
|
20
22
|
USER = "operator"
|
|
21
23
|
SYSTEM_USERS = [MONITORING_USER, REPLICATION_USER, REWIND_USER, USER]
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Substrates(str, Enum):
|
|
27
|
+
"""Possible substrates."""
|
|
28
|
+
|
|
29
|
+
K8S = "k8s"
|
|
30
|
+
VM = "vm"
|
|
@@ -30,7 +30,13 @@ import psycopg2
|
|
|
30
30
|
from ops import ConfigData
|
|
31
31
|
from psycopg2.sql import SQL, Identifier, Literal
|
|
32
32
|
|
|
33
|
-
from ..config.literals import
|
|
33
|
+
from ..config.literals import (
|
|
34
|
+
BACKUP_USER,
|
|
35
|
+
POSTGRESQL_STORAGE_PERMISSIONS,
|
|
36
|
+
SNAP_USER,
|
|
37
|
+
SYSTEM_USERS,
|
|
38
|
+
Substrates,
|
|
39
|
+
)
|
|
34
40
|
from .filesystem import change_owner
|
|
35
41
|
|
|
36
42
|
# Groups to distinguish HBA access
|
|
@@ -60,6 +66,7 @@ ALLOWED_ROLES = {
|
|
|
60
66
|
}
|
|
61
67
|
|
|
62
68
|
INVALID_DATABASE_NAME_BLOCKING_MESSAGE = "invalid database name"
|
|
69
|
+
INVALID_DATABASE_NAMES = ["databases", "postgres", "template0", "template1"]
|
|
63
70
|
INVALID_EXTRA_USER_ROLE_BLOCKING_MESSAGE = "invalid role(s) for extra user roles"
|
|
64
71
|
|
|
65
72
|
REQUIRED_PLUGINS = {
|
|
@@ -216,6 +223,7 @@ class PostgreSQL:
|
|
|
216
223
|
|
|
217
224
|
def __init__(
|
|
218
225
|
self,
|
|
226
|
+
substrate: Substrates,
|
|
219
227
|
primary_host: Optional[str],
|
|
220
228
|
current_host: Optional[str],
|
|
221
229
|
user: str,
|
|
@@ -223,6 +231,18 @@ class PostgreSQL:
|
|
|
223
231
|
database: str,
|
|
224
232
|
system_users: Optional[List[str]] = None,
|
|
225
233
|
):
|
|
234
|
+
"""Create a PostgreSQL helper.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
substrate: substrate where the charm is running (Substrates.K8S or Substrates.VM).
|
|
238
|
+
primary_host: hostname or address for primary database host.
|
|
239
|
+
current_host: hostname or address for the current database host.
|
|
240
|
+
user: username to connect as.
|
|
241
|
+
password: password for the user.
|
|
242
|
+
database: default database name.
|
|
243
|
+
system_users: list of system users.
|
|
244
|
+
"""
|
|
245
|
+
self.substrate = substrate
|
|
226
246
|
self.primary_host = primary_host
|
|
227
247
|
self.current_host = current_host
|
|
228
248
|
self.user = user
|
|
@@ -322,7 +342,7 @@ class PostgreSQL:
|
|
|
322
342
|
if len(database) > 49:
|
|
323
343
|
logger.error(f"Invalid database name (it must not exceed 49 characters): {database}.")
|
|
324
344
|
raise PostgreSQLCreateDatabaseError(INVALID_DATABASE_NAME_BLOCKING_MESSAGE)
|
|
325
|
-
if database in
|
|
345
|
+
if database in INVALID_DATABASE_NAMES:
|
|
326
346
|
logger.error(f"Invalid database name: {database}.")
|
|
327
347
|
raise PostgreSQLCreateDatabaseError(INVALID_DATABASE_NAME_BLOCKING_MESSAGE)
|
|
328
348
|
plugins = plugins if plugins else []
|
|
@@ -1077,7 +1097,7 @@ class PostgreSQL:
|
|
|
1077
1097
|
if temp_location is not None:
|
|
1078
1098
|
# Fix permissions on the temporary tablespace location when a reboot happens and tmpfs is being used.
|
|
1079
1099
|
temp_location_stats = os.stat(temp_location)
|
|
1080
|
-
if (
|
|
1100
|
+
if self.substrate == Substrates.VM and (
|
|
1081
1101
|
pwd.getpwuid(temp_location_stats.st_uid).pw_name != SNAP_USER
|
|
1082
1102
|
or int(temp_location_stats.st_mode & 0o777) != POSTGRESQL_STORAGE_PERMISSIONS
|
|
1083
1103
|
):
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
single_kernel_postgresql/__init__.py,sha256=F57JUcML43xgR0kpj9csryZkAoDSBPLLRjzSTHPaTd4,116
|
|
2
|
-
single_kernel_postgresql/abstract_charm.py,sha256=grlJCmpz8rq7_NKVkyuoK7_8I2r6DRkh5DhbtyPWna8,792
|
|
3
|
-
single_kernel_postgresql/config/__init__.py,sha256=k9Ud5ZZNd3l0nn8xi8AIlT45oZk8hJ542BjAFGDJzuc,140
|
|
4
|
-
single_kernel_postgresql/config/literals.py,sha256=4EpAnoxCEMfOCPpFD5dyAU_0h2OwAHgEX9OjTWNcaQg,527
|
|
5
|
-
single_kernel_postgresql/utils/__init__.py,sha256=VwAEW3wYjs99q38bid47aS6Os4s3catK4H5HfdPkp94,121
|
|
6
|
-
single_kernel_postgresql/utils/filesystem.py,sha256=CJ2iXqFPKM0NfqqZSTDlENOrM0RW7rmTmcuzwV0bR9A,552
|
|
7
|
-
single_kernel_postgresql/utils/postgresql.py,sha256=ZhTZZcshgHjZgP4aRCWyfmW9ArUISLdqo9NnJBg1fdM,75963
|
|
8
|
-
postgresql_charms_single_kernel-16.0.2.dist-info/METADATA,sha256=TCKebjoRLWERCEzeLgiRcX9dfZx-TLXf0CU55Ki7xik,484
|
|
9
|
-
postgresql_charms_single_kernel-16.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
-
postgresql_charms_single_kernel-16.0.2.dist-info/top_level.txt,sha256=fH85HKyfDV3--1JuYe-rWJmN5XTlXVXGOBO5iNA36Rk,25
|
|
11
|
-
postgresql_charms_single_kernel-16.0.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|