-
Notifications
You must be signed in to change notification settings - Fork 27
[DPE-6964] Storage pools #941
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
Changes from all commits
0befc70
8dc9fe6
f3f8b63
82529df
e4e08ad
d6f3156
08c2ec9
66a51a4
65f2ea0
5ad939f
08a6450
4a19d91
66829e4
File filter
Filter by extension
Conversations
Jump to
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.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -217,14 +217,14 @@ def __init__(self, *args): | |
| self.framework.observe(self.on.secret_changed, self._on_secret_changed) | ||
| self.framework.observe(self.on[PEER].relation_departed, self._on_peer_relation_departed) | ||
| self.framework.observe(self.on.postgresql_pebble_ready, self._on_postgresql_pebble_ready) | ||
| self.framework.observe(self.on.pgdata_storage_detaching, self._on_pgdata_storage_detaching) | ||
| self.framework.observe(self.on.data_storage_detaching, self._on_pgdata_storage_detaching) | ||
| self.framework.observe(self.on.stop, self._on_stop) | ||
| self.framework.observe(self.on.promote_to_primary_action, self._on_promote_to_primary) | ||
| self.framework.observe(self.on.get_primary_action, self._on_get_primary) | ||
| self.framework.observe(self.on.update_status, self._on_update_status) | ||
|
|
||
| self._certs_path = "/usr/local/share/ca-certificates" | ||
| self._storage_path = self.meta.storages["pgdata"].location | ||
| self._storage_path = self.meta.storages["data"].location | ||
| self.pgdata_path = f"{self._storage_path}/pgdata" | ||
|
|
||
| self.upgrade = PostgreSQLUpgrade( | ||
|
|
@@ -980,11 +980,26 @@ def _create_pgdata(self, container: Container): | |
| self.pgdata_path, permissions=0o750, user=WORKLOAD_OS_USER, group=WORKLOAD_OS_GROUP | ||
| ) | ||
| # Also, fix the permissions from the parent directory. | ||
| container.exec([ | ||
| "chown", | ||
| f"{WORKLOAD_OS_USER}:{WORKLOAD_OS_GROUP}", | ||
| "/var/lib/postgresql/archive", | ||
| ]).wait() | ||
| container.exec([ | ||
| "chown", | ||
| f"{WORKLOAD_OS_USER}:{WORKLOAD_OS_GROUP}", | ||
| self._storage_path, | ||
| ]).wait() | ||
| container.exec([ | ||
| "chown", | ||
| f"{WORKLOAD_OS_USER}:{WORKLOAD_OS_GROUP}", | ||
| "/var/lib/postgresql/logs", | ||
| ]).wait() | ||
| container.exec([ | ||
| "chown", | ||
| f"{WORKLOAD_OS_USER}:{WORKLOAD_OS_GROUP}", | ||
| "/var/lib/postgresql/temp", | ||
| ]).wait() | ||
|
Comment on lines
+983
to
+1002
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. Set ownership of storage volumes folders because on clouds like AWS and GCP, the ownership might be different. 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. Oh testing this on Clouds will surpise us... diffrerent storages on different AZ/NAS/Performance.... we will have fun :-) Can we add AWS test here? can be separate backlog task. |
||
|
|
||
| def _on_postgresql_pebble_ready(self, event: WorkloadEvent) -> None: | ||
| """Event handler for PostgreSQL container on PebbleReadyEvent.""" | ||
|
|
@@ -1129,7 +1144,7 @@ def _initialize_cluster(self, event: WorkloadEvent) -> bool: | |
| extra_user_roles=["pg_monitor"], | ||
| ) | ||
|
|
||
| self.postgresql.set_up_database() | ||
| self.postgresql.set_up_database(temp_location="/var/lib/postgresql/temp") | ||
|
|
||
| access_groups = self.postgresql.list_access_groups() | ||
| if access_groups != set(ACCESS_GROUPS): | ||
|
|
@@ -1463,6 +1478,9 @@ def _on_update_status_early_exit_checks(self, container) -> bool: | |
| self.enable_disable_extensions() | ||
| return True | ||
|
|
||
| logger.error("calling self.fix_leader_annotation()") | ||
| self.fix_leader_annotation() | ||
|
|
||
| logger.debug("on_update_status early exit: Unit is in Blocked/Waiting status") | ||
| return False | ||
| return True | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,7 @@ bootstrap: | |
| - auth-local: trust | ||
| - encoding: UTF8 | ||
| - data-checksums | ||
| - waldir: /var/lib/postgresql/logs | ||
|
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. Mapping the WAL directory to the |
||
| {%- endif %} | ||
| pg_hba: | ||
| - {{ 'hostssl' if enable_tls else 'host' }} all all 0.0.0.0/0 md5 | ||
|
|
@@ -106,6 +107,8 @@ ctl: | |
| {%- endif %} | ||
| pod_ip: '{{ endpoint }}' | ||
| postgresql: | ||
| basebackup: | ||
| - waldir: /var/lib/postgresql/logs | ||
|
Comment on lines
+110
to
+111
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. Mapping the WAL directory to the |
||
| connect_address: '{{ endpoint }}:5432' | ||
| data_dir: {{ storage_path }}/pgdata | ||
| bin_dir: /usr/lib/postgresql/{{ version }}/bin | ||
|
|
@@ -123,6 +126,7 @@ postgresql: | |
| ssl_cert_file: {{ storage_path }}/cert.pem | ||
| ssl_key_file: {{ storage_path }}/key.pem | ||
| {%- endif %} | ||
| temp_tablespaces: temp | ||
|
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. Configure PostgreSQL to use the temp storage for temporary tablespaces. |
||
| {%- if pg_parameters %} | ||
| {%- for key, value in pg_parameters.items() %} | ||
| {{key}}: {{value}} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -Eeuo pipefail | ||
| rm -rf /var/lib/postgresql/archive/* | ||
| rm -rf /var/lib/postgresql/data/pgdata/* | ||
| rm -rf /var/lib/postgresql/logs/* | ||
| rm -rf /var/lib/postgresql/temp/* |
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.
Configure PostgreSQL to use the
tempstorage for temporary tablespaces.