-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DPE-5833] Create new PostgreSQL version 16 charm #788
base: 16/edge
Are you sure you want to change the base?
Changes from all commits
62e073d
ae2446c
485fe58
df73c21
1a899bb
4b076b7
75560d9
78b4df6
4151296
08dade0
9110cef
560f1eb
adafd4d
c9cbf70
ba536a0
efb6603
d38b768
f2d3bab
66cf401
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,16 +50,16 @@ jobs: | |
build: | ||
name: Build charm | ||
uses: canonical/data-platform-workflows/.github/workflows/[email protected] | ||
with: | ||
cache: false | ||
|
||
integration-test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
juju: | ||
- agent: 2.9.51 # renovate: juju-agent-pin-minor | ||
libjuju: ==2.9.49.1 # renovate: latest libjuju 2 | ||
allure_on_amd64: false | ||
- agent: 3.6.2 # renovate: juju-agent-pin-minor | ||
libjuju: ==3.6.1.0 # renovate: latest libjuju 2 | ||
allure_on_amd64: true | ||
architecture: | ||
- amd64 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ name: Release to Charmhub | |
on: | ||
push: | ||
branches: | ||
- main | ||
- 16/edge | ||
paths-ignore: | ||
- 'tests/**' | ||
- 'docs/**' | ||
|
@@ -46,7 +46,7 @@ jobs: | |
- ci-tests | ||
uses: canonical/data-platform-workflows/.github/workflows/[email protected] | ||
with: | ||
channel: 14/edge | ||
channel: 16/edge | ||
artifact-prefix: ${{ needs.ci-tests.outputs.artifact-prefix }} | ||
secrets: | ||
charmhub-token: ${{ secrets.CHARMHUB_TOKEN }} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ | |
|
||
# Increment this PATCH version before using `charmcraft publish-lib` or reset | ||
# to 0 if you are raising the major API version | ||
LIBPATCH = 42 | ||
LIBPATCH = 43 | ||
|
||
INVALID_EXTRA_USER_ROLE_BLOCKING_MESSAGE = "invalid role(s) for extra user roles" | ||
|
||
|
@@ -317,7 +317,7 @@ def delete_user(self, user: str) -> None: | |
logger.error(f"Failed to delete user: {e}") | ||
raise PostgreSQLDeleteUserError() from e | ||
|
||
def enable_disable_extensions( | ||
def enable_disable_extensions( # noqa: C901 | ||
self, extensions: Dict[str, bool], database: Optional[str] = None | ||
) -> None: | ||
"""Enables or disables a PostgreSQL extension. | ||
|
@@ -347,10 +347,12 @@ def enable_disable_extensions( | |
|
||
# Enable/disabled the extension in each database. | ||
for database in databases: | ||
with self._connect_to_database( | ||
database=database | ||
) as connection, connection.cursor() as cursor: | ||
connection = self._connect_to_database(database=database) | ||
connection.autocommit = True | ||
with connection.cursor() as cursor: | ||
for extension, enable in ordered_extensions.items(): | ||
if extension == "postgis": | ||
cursor.execute("SET pgaudit.log = 'none';") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. necessary for postgis to work There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. So, postgis and pgaudit don't work together? |
||
cursor.execute( | ||
f"CREATE EXTENSION IF NOT EXISTS {extension};" | ||
if enable | ||
|
@@ -372,6 +374,7 @@ def _generate_database_privileges_statements( | |
) -> List[Composed]: | ||
"""Generates a list of databases privileges statements.""" | ||
statements = [] | ||
statements.append(SQL("GRANT USAGE, CREATE ON SCHEMA public TO PUBLIC;")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and below are the specific workarounds mentioned in the doc for the new restrictive permissions added on PG 15/16. |
||
if relations_accessing_this_database == 1: | ||
statements.append( | ||
SQL( | ||
|
@@ -428,8 +431,10 @@ def _generate_database_privileges_statements( | |
SQL("GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA {} TO {};").format( | ||
schema, Identifier(user) | ||
), | ||
SQL("GRANT USAGE ON SCHEMA {} TO {};").format(schema, Identifier(user)), | ||
SQL("GRANT CREATE ON SCHEMA {} TO {};").format(schema, Identifier(user)), | ||
SQL("GRANT USAGE, CREATE ON SCHEMA {} TO {};").format( | ||
schema, Identifier(user) | ||
), | ||
SQL("GRANT USAGE, CREATE ON SCHEMA {} TO admin;").format(schema), | ||
Comment on lines
+434
to
+437
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked the PostgreSQL 15 release notes and changed my mind about the approach here. Now, I think that it's important that we don't grant those permissions to users on the public schema to avoid CVE-2018-1058. |
||
]) | ||
return statements | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ resources: | |
postgresql-image: | ||
type: oci-image | ||
description: OCI image for PostgreSQL | ||
upstream-source: ghcr.io/canonical/charmed-postgresql@sha256:7e41d7f60e45ee2f5463aa9aafcd3c35121423423ee08c26a174b99ad0235b7e # renovate: oci-image tag: 14.15-22.04_edge | ||
upstream-source: ghcr.io/canonical/charmed-postgresql:16.4-24.04_edge | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer to keep the SHA256 digest here because it'll prevent us from publishing the charm with a newer and not yet tested version of the OCI image. |
||
|
||
peers: | ||
database-peers: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -534,7 +534,7 @@ def render_patroni_yml_file( | |
) | ||
self._render_file(f"{self._storage_path}/patroni.yml", rendered, 0o644) | ||
|
||
@retry(stop=stop_after_attempt(10), wait=wait_exponential(multiplier=1, min=2, max=30)) | ||
@retry(stop=stop_after_attempt(20), wait=wait_exponential(multiplier=1, min=2, max=30)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you have a link to a failing test that motivated this change? Did it happen multiple times? |
||
def reload_patroni_configuration(self) -> None: | ||
"""Reloads the configuration after it was updated in the file.""" | ||
requests.post( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,11 +156,26 @@ postgresql: | |
authentication: | ||
replication: | ||
password: {{ replication_password }} | ||
{%- if enable_tls %} | ||
sslrootcert: {{ conf_path }}/ca.pem | ||
sslcert: {{ conf_path }}/cert.pem | ||
sslkey: {{ conf_path }}/key.pem | ||
{%- endif %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no idea why this wasn't an issue before. |
||
rewind: | ||
username: {{ rewind_user }} | ||
password: {{ rewind_password }} | ||
{%- if enable_tls %} | ||
sslrootcert: {{ conf_path }}/ca.pem | ||
sslcert: {{ conf_path }}/cert.pem | ||
sslkey: {{ conf_path }}/key.pem | ||
{%- endif %} | ||
superuser: | ||
password: {{ superuser_password }} | ||
{%- if enable_tls %} | ||
sslrootcert: {{ conf_path }}/ca.pem | ||
sslcert: {{ conf_path }}/cert.pem | ||
sslkey: {{ conf_path }}/key.pem | ||
{%- endif %} | ||
use_endpoints: true | ||
use_unix_socket: true | ||
{%- if is_no_sync_member or is_creating_backup %} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,11 @@ | |
import pytest | ||
from pytest_operator.plugin import OpsTest | ||
|
||
from .helpers import build_charm | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
async def database_charm(ops_test: OpsTest): | ||
"""Build the database charm.""" | ||
charm = await ops_test.build_charm(".") | ||
charm = await build_charm(".") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. workaround for multi-base integration testing (currently hardcoded to jammy) |
||
return charm |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
|
||
from ..helpers import ( | ||
APPLICATION_NAME, | ||
CHARM_BASE, | ||
app_name, | ||
build_and_deploy, | ||
db_connect, | ||
|
@@ -43,7 +42,6 @@ async def test_build_and_deploy(ops_test: OpsTest) -> None: | |
await ops_test.model.deploy( | ||
APPLICATION_NAME, | ||
application_name=APPLICATION_NAME, | ||
base=CHARM_BASE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this parameter still doesn't play nice with noble base. |
||
channel="edge", | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no more juju 2