-
Notifications
You must be signed in to change notification settings - Fork 27
[DPE-7584] Update single kernel library to fix tmpfs ownership and permission after reboot #1156
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
Merged
marceloneppel
merged 12 commits into
16/edge
from
fix-temp-tablespace-directory-permissions
Oct 1, 2025
Merged
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
adaf9ce
Update single kernel library and add integration test for checking th…
marceloneppel 696ab89
Merge remote-tracking branch 'origin/16/edge' into fix-temp-tablespac…
marceloneppel 5d89720
Update lock file
marceloneppel 4e544cf
Add spread test file
marceloneppel 91c9fe2
Point library to commit
marceloneppel 7c93672
Merge remote-tracking branch 'origin/16/edge' into fix-temp-tablespac…
marceloneppel cadaf11
Update library version
marceloneppel 7263ae4
Fix storage permissions after restore
marceloneppel b0c80cd
Revert "Fix storage permissions after restore"
marceloneppel 19805fd
Update library for correct permissions comparison and set the right p…
marceloneppel 3840d18
Merge remote-tracking branch 'origin/16/edge' into fix-temp-tablespac…
marceloneppel fd7bd63
Update lib version
marceloneppel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| #!/usr/bin/env python3 | ||
| # Copyright 2025 Canonical Ltd. | ||
| # See LICENSE file for licensing details. | ||
|
|
||
| import logging | ||
| import subprocess | ||
|
|
||
| import jubilant | ||
| import psycopg2 | ||
| import pytest | ||
|
|
||
| from .helpers import DATABASE_APP_NAME | ||
| from .jubilant_helpers import get_credentials | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| TIMEOUT = 20 * 60 | ||
| RELATION_ENDPOINT = "postgresql" | ||
| DATA_INTEGRATOR_APP_NAME = "data-integrator" | ||
|
|
||
|
|
||
| @pytest.mark.abort_on_fail | ||
| def test_deploy_with_tmpfs_storage(juju: jubilant.Juju, charm) -> None: | ||
| """Deploy PostgreSQL with tmpfs temp storage and data-integrator.""" | ||
| # Deploy database app with tmpfs for temporary storage. | ||
| if DATABASE_APP_NAME not in juju.status().apps: | ||
| logger.info("Deploying PostgreSQL with tmpfs temporary storage") | ||
| juju.deploy( | ||
| charm, | ||
| app=DATABASE_APP_NAME, | ||
| num_units=1, | ||
| config={"profile": "testing"}, | ||
| storage={"temp": "5G,tmpfs"}, | ||
| ) | ||
|
|
||
| # Deploy data-integrator to get credentials. | ||
| if DATA_INTEGRATOR_APP_NAME not in juju.status().apps: | ||
| logger.info("Deploying data-integrator") | ||
| juju.deploy(DATA_INTEGRATOR_APP_NAME, config={"database-name": "test"}) | ||
|
|
||
| # Relate if not already related | ||
| status = juju.status() | ||
| if not status.apps[DATABASE_APP_NAME].relations.get(RELATION_ENDPOINT): | ||
| juju.integrate(DATA_INTEGRATOR_APP_NAME, DATABASE_APP_NAME) | ||
|
|
||
| logger.info("Waiting for both applications to become active") | ||
| juju.wait( | ||
| lambda s: jubilant.all_active(s, DATABASE_APP_NAME, DATA_INTEGRATOR_APP_NAME), | ||
| timeout=TIMEOUT, | ||
| ) | ||
|
|
||
|
|
||
| def test_restart_and_temp_table(juju: jubilant.Juju) -> None: | ||
| """Restart the LXD machine and verify TEMP TABLE creation works afterwards.""" | ||
| unit_name = f"{DATABASE_APP_NAME}/0" | ||
|
|
||
| # Find machine name and restart | ||
| status = juju.status() | ||
| unit_info = status.get_units(unit_name.split("/")[0]).get(unit_name) | ||
| machine_name = None | ||
| if unit_info: | ||
| machine_id = getattr(unit_info, "machine", None) | ||
| if machine_id: | ||
| # Look up the machine object in status and try common attributes that hold the LXD name | ||
| machine_obj = ( | ||
| getattr(status, "machines", {}).get(machine_id) | ||
| if hasattr(status, "machines") | ||
| else None | ||
| ) | ||
| if machine_obj: | ||
| machine_name = getattr(machine_obj, "instance_id", None) | ||
|
|
||
| if machine_name is None: | ||
| raise RuntimeError("Unable to determine LXD machine/container name for unit " + unit_name) | ||
|
|
||
| logger.info(f"Restarting LXD machine {machine_name}") | ||
| subprocess.check_call(["lxc", "restart", machine_name]) | ||
|
|
||
| # Wait for unit to go active/idle again | ||
| logger.info("Waiting for PostgreSQL unit to become active after restart") | ||
| juju.wait( | ||
| lambda s: jubilant.all_active(s, DATABASE_APP_NAME, DATA_INTEGRATOR_APP_NAME), | ||
| delay=30, | ||
| timeout=TIMEOUT, | ||
| ) | ||
|
|
||
| # Obtain credentials via data-integrator action | ||
| creds = get_credentials(juju, f"{DATA_INTEGRATOR_APP_NAME}/0") | ||
| uri = creds[RELATION_ENDPOINT]["uris"] | ||
|
|
||
| # Connect and create a TEMPORARY TABLE | ||
| connection = None | ||
| try: | ||
| connection = psycopg2.connect(uri) | ||
| connection.autocommit = True | ||
| with connection.cursor() as cur: | ||
| cur.execute("CREATE TEMPORARY TABLE test (lines TEXT);") | ||
| finally: | ||
| if connection is not None: | ||
| connection.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| summary: test_tmpfs_restart.py | ||
| environment: | ||
| TEST_MODULE: test_tmpfs_restart.py | ||
| execute: | | ||
| tox run -e integration -- "tests/integration/$TEST_MODULE" --model testing --alluredir="$SPREAD_TASK/allure-results" | ||
| artifacts: | ||
| - allure-results |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Need to be changed to 16.0.1 after canonical/postgresql-single-kernel-library#11 is merged and published.