postgresql-charms-single-kernel 16.0.0__tar.gz → 16.0.2__tar.gz
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.0 → postgresql_charms_single_kernel-16.0.2}/PKG-INFO +1 -1
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/postgresql_charms_single_kernel.egg-info/PKG-INFO +1 -1
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/pyproject.toml +4 -4
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/single_kernel_postgresql/utils/postgresql.py +27 -3
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/README.md +0 -0
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/postgresql_charms_single_kernel.egg-info/SOURCES.txt +0 -0
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/postgresql_charms_single_kernel.egg-info/dependency_links.txt +0 -0
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/postgresql_charms_single_kernel.egg-info/top_level.txt +0 -0
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/setup.cfg +0 -0
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/single_kernel_postgresql/__init__.py +0 -0
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/single_kernel_postgresql/abstract_charm.py +0 -0
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/single_kernel_postgresql/config/__init__.py +0 -0
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/single_kernel_postgresql/config/literals.py +0 -0
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/single_kernel_postgresql/utils/__init__.py +0 -0
- {postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/single_kernel_postgresql/utils/filesystem.py +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.0.2
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: postgresql-charms-single-kernel
|
|
3
|
-
Version: 16.0.
|
|
3
|
+
Version: 16.0.2
|
|
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
|
{postgresql_charms_single_kernel-16.0.0 → postgresql_charms_single_kernel-16.0.2}/pyproject.toml
RENAMED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[project]
|
|
5
5
|
name = "postgresql-charms-single-kernel"
|
|
6
6
|
description = "Shared and reusable code for PostgreSQL-related charms"
|
|
7
|
-
version = "16.0.
|
|
7
|
+
version = "16.0.2"
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
license = "Apache-2.0"
|
|
10
10
|
authors = [
|
|
@@ -23,15 +23,15 @@ lib = [
|
|
|
23
23
|
"psycopg2>=2.9.10",
|
|
24
24
|
]
|
|
25
25
|
format = [
|
|
26
|
-
"ruff==0.
|
|
26
|
+
"ruff==0.13.1"
|
|
27
27
|
]
|
|
28
28
|
lint = [
|
|
29
29
|
"codespell==2.4.1",
|
|
30
30
|
"pyright==1.1.405"
|
|
31
31
|
]
|
|
32
32
|
unit = [
|
|
33
|
-
"coverage[toml]==7.
|
|
34
|
-
"pytest==8.4.
|
|
33
|
+
"coverage[toml]==7.10.7; python_version > '3.8'",
|
|
34
|
+
"pytest==8.4.2; python_version >= '3.9'"
|
|
35
35
|
]
|
|
36
36
|
|
|
37
37
|
# Testing tools configuration
|
|
@@ -21,14 +21,16 @@ Any charm using this library should import the `psycopg2` or `psycopg2-binary` d
|
|
|
21
21
|
|
|
22
22
|
import logging
|
|
23
23
|
import os
|
|
24
|
+
import pwd
|
|
24
25
|
from collections import OrderedDict
|
|
26
|
+
from datetime import datetime, timezone
|
|
25
27
|
from typing import Dict, List, Optional, Set, Tuple
|
|
26
28
|
|
|
27
29
|
import psycopg2
|
|
28
30
|
from ops import ConfigData
|
|
29
31
|
from psycopg2.sql import SQL, Identifier, Literal
|
|
30
32
|
|
|
31
|
-
from ..config.literals import BACKUP_USER, POSTGRESQL_STORAGE_PERMISSIONS, SYSTEM_USERS
|
|
33
|
+
from ..config.literals import BACKUP_USER, POSTGRESQL_STORAGE_PERMISSIONS, SNAP_USER, SYSTEM_USERS
|
|
32
34
|
from .filesystem import change_owner
|
|
33
35
|
|
|
34
36
|
# Groups to distinguish HBA access
|
|
@@ -1074,9 +1076,31 @@ class PostgreSQL:
|
|
|
1074
1076
|
|
|
1075
1077
|
if temp_location is not None:
|
|
1076
1078
|
# Fix permissions on the temporary tablespace location when a reboot happens and tmpfs is being used.
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
+
temp_location_stats = os.stat(temp_location)
|
|
1080
|
+
if (
|
|
1081
|
+
pwd.getpwuid(temp_location_stats.st_uid).pw_name != SNAP_USER
|
|
1082
|
+
or int(temp_location_stats.st_mode & 0o777) != POSTGRESQL_STORAGE_PERMISSIONS
|
|
1083
|
+
):
|
|
1084
|
+
change_owner(temp_location)
|
|
1085
|
+
os.chmod(temp_location, POSTGRESQL_STORAGE_PERMISSIONS)
|
|
1086
|
+
# Rename existing temp tablespace if it exists, instead of dropping it.
|
|
1087
|
+
cursor.execute("SELECT TRUE FROM pg_tablespace WHERE spcname='temp';")
|
|
1088
|
+
if cursor.fetchone() is not None:
|
|
1089
|
+
new_name = f"temp_{datetime.now(timezone.utc).strftime('%Y%m%d%H%M%S')}"
|
|
1090
|
+
cursor.execute(f"ALTER TABLESPACE temp RENAME TO {new_name};")
|
|
1091
|
+
|
|
1092
|
+
# List temp tablespaces with suffix for operator follow-up cleanup and log them.
|
|
1093
|
+
cursor.execute(
|
|
1094
|
+
"SELECT spcname FROM pg_tablespace WHERE spcname LIKE 'temp_%';"
|
|
1095
|
+
)
|
|
1096
|
+
temp_tbls = sorted([row[0] for row in cursor.fetchall()])
|
|
1097
|
+
logger.info(
|
|
1098
|
+
"There are %d temp tablespaces that should be checked and removed: %s",
|
|
1099
|
+
len(temp_tbls),
|
|
1100
|
+
", ".join(temp_tbls),
|
|
1101
|
+
)
|
|
1079
1102
|
|
|
1103
|
+
# Ensure a fresh temp tablespace exists at the expected location.
|
|
1080
1104
|
cursor.execute("SELECT TRUE FROM pg_tablespace WHERE spcname='temp';")
|
|
1081
1105
|
if cursor.fetchone() is None:
|
|
1082
1106
|
cursor.execute(f"CREATE TABLESPACE temp LOCATION '{temp_location}';")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|