@@ -205,15 +205,14 @@ func startupCommand(
205
205
version := fmt .Sprint (cluster .Spec .PostgresVersion )
206
206
walDir := WALDirectory (cluster , instance )
207
207
208
- // If the user requests tablespaces, we want to create and chmod the directories
208
+ // If the user requests tablespaces, we want to make sure the directories exist with the
209
+ // correct owner and permissions.
209
210
tablespaceCmd := ""
210
211
if util .DefaultMutableFeatureGate .Enabled (util .TablespaceVolumes ) && instance .TablespaceVolumes != nil {
211
212
// This command checks if a dir exists and if not, creates it;
212
213
// if the dir does exist, then we `recreate` it to make sure the owner is correct;
213
214
// but if the dir exists with the wrong owner and is not writeable, we error.
214
215
// This is the same behavior we use for the main PGDATA directory.
215
- // The path for tablespaces volumes is /tablespaces/NAME/data
216
- // -- the `data` path is added so that we can arrange the permissions.
217
216
checkInstallRecreateCmd := strings .Join ([]string {
218
217
`if [[ ! -e "${tablespace_dir}" || -O "${tablespace_dir}" ]]; then` ,
219
218
`install --directory --mode=0700 "${tablespace_dir}"` ,
@@ -224,6 +223,8 @@ func startupCommand(
224
223
}, "\n " )
225
224
226
225
for _ , tablespace := range instance .TablespaceVolumes {
226
+ // The path for tablespaces volumes is /tablespaces/NAME/data
227
+ // -- the `data` path is added so that we can arrange the permissions.
227
228
tablespaceCmd = tablespaceCmd + "\n tablespace_dir=/tablespaces/" + tablespace .Name + "/data" + "\n " +
228
229
checkInstallRecreateCmd
229
230
}
0 commit comments