Skip to content

Commit 406e069

Browse files
committed
Set data directory group permissions during bootstrap
Immediately after bootstrap, the data directory lacks group permissions when the storage provider ignores fsGroup. The startup container resets group permissions correctly, so pod restart works around this. Issue: PGO-300 See: c7842e7
1 parent 2e01842 commit 406e069

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

internal/patroni/config.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,11 @@ func instanceYAML(
552552
} else {
553553

554554
initdb := []string{
555+
// Pod "securityContext.fsGroup" ensures processes and filesystems agree on a GID.
556+
// Group access ensures processes can access data regardless of their UID.
557+
// NOTE: The "--allow-group-access" option was introduced in PostgreSQL v11.
558+
"allow-group-access",
559+
555560
// Enable checksums on data pages to help detect corruption of
556561
// storage that would otherwise be silent. This also enables
557562
// "wal_log_hints" which is a prerequisite for using `pg_rewind`.
@@ -568,7 +573,7 @@ func instanceYAML(
568573
"data-checksums",
569574
"encoding=UTF8",
570575

571-
// NOTE(cbandy): The "--waldir" option was introduced in PostgreSQL v10.
576+
// NOTE: The "--waldir" option was introduced in PostgreSQL v10.
572577
"waldir=" + postgres.WALDirectory(cluster, instance),
573578
}
574579

internal/patroni/config_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ func TestInstanceYAML(t *testing.T) {
685685
# Your changes will not be saved.
686686
bootstrap:
687687
initdb:
688+
- allow-group-access
688689
- data-checksums
689690
- encoding=UTF8
690691
- waldir=/pgdata/pg12_wal
@@ -708,6 +709,7 @@ tags: {}
708709
# Your changes will not be saved.
709710
bootstrap:
710711
initdb:
712+
- allow-group-access
711713
- data-checksums
712714
- encoding=UTF8
713715
- waldir=/pgdata/pg12_wal
@@ -747,6 +749,7 @@ tags: {}
747749
# Your changes will not be saved.
748750
bootstrap:
749751
initdb:
752+
- allow-group-access
750753
- data-checksums
751754
- encoding=UTF8
752755
- waldir=/pgdata/pg12_wal

0 commit comments

Comments
 (0)