[DPE-7584] Fix temp tablespace permissions#1137
[DPE-7584] Fix temp tablespace permissions#1137marceloneppel wants to merge 2 commits into16/edgefrom
Conversation
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 16/edge #1137 +/- ##
========================================
Coverage 64.57% 64.57%
========================================
Files 17 17
Lines 4325 4325
Branches 667 667
========================================
Hits 2793 2793
Misses 1351 1351
Partials 181 181 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
| if temp_location is not None: | ||
| # Fix permissions on the temporary tablespace location when a reboot happens and tmpfs is being used. | ||
| user = pwd.getpwnam("_daemon_") | ||
| os.chown(temp_location, uid=user.pw_uid, gid=user.pw_gid) |
There was a problem hiding this comment.
Should _change_owner() be moved to lib and used to avoid duplicates?
There was a problem hiding this comment.
I believe it's a good idea. I'd change it a bit and create a different Python file (and also move it to the single kernel library repo) to contain utilities related to the filesystem, and keep this library containing only things related to the database connection and interaction.
There was a problem hiding this comment.
I moved the _change_owner() function to the single kernel lib on canonical/postgresql-single-kernel-library#10.
| # Fix permissions on the temporary tablespace location when a reboot happens and tmpfs is being used. | ||
| user = pwd.getpwnam("_daemon_") | ||
| os.chown(temp_location, uid=user.pw_uid, gid=user.pw_gid) | ||
| os.chmod(temp_location, 0o700) |
There was a problem hiding this comment.
Good catch. I'm checking and testing a consistent approach in all the places where the permissions are specific.
There was a problem hiding this comment.
We'll need to change it to 700 everywhere, to be consistent. As we're always accessing the directories as the owner, there is no need to have permissions for the group to access them.
|
Superseeded by canonical/postgresql-single-kernel-library#10. |
Issue
When using
tmpfsfor thetempstorage, if we reboot the host machine, and later, after the charm starts again, it's not possible to create temporary objects, like temporary tables.The reason is that after the reboot, the storage is mounted with wrong ownership and permissions (owned by
rootinstead of_daemon_and with permissions set to755instead of700).Solution
Fix the permissions when the charm starts again.
I'll create a follow-up PR in the single kernel library repo to port those changes.
Checklist