Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit088c103

Browse files
committed
Merge branch '152-clone-configuration' into 'master'
fix: clone configuration issues (#152)- create unix-socket directories and adjust start configuration- generate superuser password for PostgreSQL- remove unnecessary configuration variables(pgDataSubdir)See merge request postgres-ai/database-lab!149
2 parents5bb1019 +e9c1208 commit088c103

File tree

14 files changed

+87
-76
lines changed

14 files changed

+87
-76
lines changed

‎configs/config.example.logical_generic.yml‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,6 @@ provision:
5555
# Do not edit this.
5656
mode:"local"
5757

58-
# Subdir where PGDATA located relative to the pool root dir.
59-
# It is a part of global.dataDir, *with* leading slashes.
60-
# If PGDATA is supposed to be in global.dataDir and this is the mount point,
61-
# then use "/" in pgDataSubdir.
62-
# Otherwise, use the final part (everything except the mount point), with leading slash.
63-
# Example:
64-
# dataDir (PostgreSQL data directory): /var/lib/dblab/data
65-
# pgDataSubdir: /pgdata
66-
# -- in this case, we assume that the mount point is: /var/lib/dblab
67-
# Note, that, despite the fact that it always begins with "/",
68-
# it is a relative path. Default: "/".
69-
pgDataSubdir:"/"
70-
7158
# Database username that will be used for Postgres management connections.
7259
# This user must exist.
7360
# The password is not needed – it will be set automatically.

‎configs/config.example.logical_rds.yml‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,6 @@ provision:
5555
# Do not edit this.
5656
mode:"local"
5757

58-
# Subdir where PGDATA located relative to the pool root dir.
59-
# It is a part of global.dataDir, *with* leading slashes.
60-
# If PGDATA is supposed to be in global.dataDir and this is the mount point,
61-
# then use "/" in pgDataSubdir.
62-
# Otherwise, use the final part (everything except the mount point), with leading slash.
63-
# Example:
64-
# dataDir (PostgreSQL data directory): /var/lib/dblab/data
65-
# pgDataSubdir: /pgdata
66-
# -- in this case, we assume that the mount point is: /var/lib/dblab
67-
# Note, that, despite the fact that it always begins with "/",
68-
# it is a relative path. Default: "/".
69-
pgDataSubdir:"/"
70-
7158
# Database username that will be used for Postgres management connections.
7259
# This user must exist.
7360
# The password is not needed – it will be set automatically.

‎configs/config.example.physical_generic.yml‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,6 @@ provision:
5555
# Do not edit this.
5656
mode:"local"
5757

58-
# Subdir where PGDATA located relative to the pool root dir.
59-
# It is a part of global.dataDir, *with* leading slashes.
60-
# If PGDATA is supposed to be in global.dataDir and this is the mount point,
61-
# then use "/" in pgDataSubdir.
62-
# Otherwise, use the final part (everything except the mount point), with leading slash.
63-
# Example:
64-
# dataDir (PostgreSQL data directory): /var/lib/dblab/data
65-
# pgDataSubdir: /pgdata
66-
# -- in this case, we assume that the mount point is: /var/lib/dblab
67-
# Note, that, despite the fact that it always begins with "/",
68-
# it is a relative path. Default: "/".
69-
pgDataSubdir:"/"
70-
7158
# Database username that will be used for Postgres management connections.
7259
# This user must exist.
7360
# The password is not needed – it will be set automatically.

‎configs/config.example.physical_walg.yml‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,6 @@ provision:
5555
# Do not edit this.
5656
mode:"local"
5757

58-
# Subdir where PGDATA located relative to the pool root dir.
59-
# It is a part of global.dataDir, *with* leading slashes.
60-
# If PGDATA is supposed to be in global.dataDir and this is the mount point,
61-
# then use "/" in pgDataSubdir.
62-
# Otherwise, use the final part (everything except the mount point), with leading slash.
63-
# Example:
64-
# dataDir (PostgreSQL data directory): /var/lib/dblab/data
65-
# pgDataSubdir: /pgdata
66-
# -- in this case, we assume that the mount point is: /var/lib/dblab
67-
# Note, that, despite the fact that it always begins with "/",
68-
# it is a relative path. Default: "/".
69-
pgDataSubdir:"/"
70-
7158
# Database username that will be used for Postgres management connections.
7259
# This user must exist.
7360
# The password is not needed – it will be set automatically.

‎go.mod‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ require (
2525
github.com/robfig/cron/v3v3.0.1
2626
github.com/rs/xidv1.2.1
2727
github.com/sergi/go-diffv1.1.0
28+
github.com/sethvargo/go-passwordv0.2.0
2829
github.com/shirou/gopsutilv2.20.7+incompatible
2930
github.com/sirupsen/logrusv1.4.2
3031
github.com/stretchr/testifyv1.5.1

‎go.sum‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0
8484
github.com/russross/blackfriday/v2v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
8585
github.com/sergi/go-diffv1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
8686
github.com/sergi/go-diffv1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
87+
github.com/sethvargo/go-passwordv0.2.0 h1:BTDl4CC/gjf/axHMaDQtw507ogrXLci6XRiLc7i/UHI=
88+
github.com/sethvargo/go-passwordv0.2.0/go.mod h1:Ym4Mr9JXLBycr02MFuVQ/0JHidNetSgbzutTr3zsYXE=
8789
github.com/shirou/gopsutilv2.20.7+incompatible h1:Ymv4OD12d6zm+2yONe39VSmp2XooJe8za7ngOLW/o/w=
8890
github.com/shirou/gopsutilv2.20.7+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
8991
github.com/shurcooL/sanitized_anchor_namev1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=

‎pkg/retrieval/engine/postgres/initialize/logical/dump.go‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/docker/docker/api/types/network"
2121
"github.com/docker/docker/client"
2222
"github.com/pkg/errors"
23+
"github.com/sethvargo/go-password/password"
2324

2425
dblabCfg"gitlab.com/postgres-ai/database-lab/pkg/config"
2526
"gitlab.com/postgres-ai/database-lab/pkg/log"
@@ -224,7 +225,12 @@ func (d *DumpJob) Run(ctx context.Context) (err error) {
224225
returnerrors.Wrap(err,"failed to build container host config")
225226
}
226227

227-
cont,err:=d.dockerClient.ContainerCreate(ctx,d.buildContainerConfig(),hostConfig,&network.NetworkingConfig{},
228+
pwd,err:=password.Generate(tools.PasswordLength,tools.PasswordMinDigits,tools.PasswordMinSymbols,false,true)
229+
iferr!=nil {
230+
returnerrors.Wrap(err,"failed to generate PostgreSQL password")
231+
}
232+
233+
cont,err:=d.dockerClient.ContainerCreate(ctx,d.buildContainerConfig(pwd),hostConfig,&network.NetworkingConfig{},
228234
d.dumpContainerName(),
229235
)
230236
iferr!=nil {
@@ -328,9 +334,9 @@ func (d *DumpJob) performDumpCommand(ctx context.Context, cmdOutput io.Writer, c
328334
returnnil
329335
}
330336

331-
func (d*DumpJob)getEnvironmentVariables() []string {
337+
func (d*DumpJob)getEnvironmentVariables(passwordstring) []string {
332338
envs:= []string{
333-
"POSTGRES_HOST_AUTH_METHOD=trust",
339+
"POSTGRES_PASSWORD="+password,
334340
}
335341

336342
// Avoid initialization of PostgreSQL directory in case of preparing of a dump.
@@ -346,10 +352,10 @@ func (d *DumpJob) getEnvironmentVariables() []string {
346352
returnenvs
347353
}
348354

349-
func (d*DumpJob)buildContainerConfig()*container.Config {
355+
func (d*DumpJob)buildContainerConfig(passwordstring)*container.Config {
350356
return&container.Config{
351357
Labels:map[string]string{"label":tools.DBLabControlLabel},
352-
Env:d.getEnvironmentVariables(),
358+
Env:d.getEnvironmentVariables(password),
353359
Image:d.DockerImage,
354360
Healthcheck:health.GetConfig(),
355361
}

‎pkg/retrieval/engine/postgres/initialize/logical/restore.go‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/docker/docker/api/types/network"
1818
"github.com/docker/docker/client"
1919
"github.com/pkg/errors"
20+
"github.com/sethvargo/go-password/password"
2021

2122
dblabCfg"gitlab.com/postgres-ai/database-lab/pkg/config"
2223
"gitlab.com/postgres-ai/database-lab/pkg/log"
@@ -124,8 +125,13 @@ func (r *RestoreJob) Run(ctx context.Context) (err error) {
124125
returnerrors.Wrap(err,"failed to build container host config")
125126
}
126127

128+
pwd,err:=password.Generate(tools.PasswordLength,tools.PasswordMinDigits,tools.PasswordMinSymbols,false,true)
129+
iferr!=nil {
130+
returnerrors.Wrap(err,"failed to generate PostgreSQL password")
131+
}
132+
127133
cont,err:=r.dockerClient.ContainerCreate(ctx,
128-
r.buildContainerConfig(),
134+
r.buildContainerConfig(pwd),
129135
hostConfig,
130136
&network.NetworkingConfig{},
131137
r.restoreContainerName(),
@@ -194,12 +200,12 @@ func (r *RestoreJob) Run(ctx context.Context) (err error) {
194200
returnnil
195201
}
196202

197-
func (r*RestoreJob)buildContainerConfig()*container.Config {
203+
func (r*RestoreJob)buildContainerConfig(passwordstring)*container.Config {
198204
return&container.Config{
199205
Labels:map[string]string{"label":tools.DBLabControlLabel},
200206
Env: []string{
201207
"PGDATA="+r.globalCfg.DataDir,
202-
"POSTGRES_HOST_AUTH_METHOD=trust",
208+
"POSTGRES_PASSWORD="+password,
203209
},
204210
Image:r.RestoreOptions.DockerImage,
205211
Healthcheck:health.GetConfig(),

‎pkg/retrieval/engine/postgres/initialize/physical/physical.go‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/docker/docker/api/types/network"
2323
"github.com/docker/docker/client"
2424
"github.com/pkg/errors"
25+
"github.com/sethvargo/go-password/password"
2526

2627
dblabCfg"gitlab.com/postgres-ai/database-lab/pkg/config"
2728
"gitlab.com/postgres-ai/database-lab/pkg/log"
@@ -245,8 +246,13 @@ func (r *RestoreJob) startContainer(ctx context.Context, containerName string) (
245246
return"",errors.Wrap(err,"failed to build container host config")
246247
}
247248

249+
pwd,err:=password.Generate(tools.PasswordLength,tools.PasswordMinDigits,tools.PasswordMinSymbols,false,true)
250+
iferr!=nil {
251+
return"",errors.Wrap(err,"failed to generate PostgreSQL password")
252+
}
253+
248254
syncInstance,err:=r.dockerClient.ContainerCreate(ctx,
249-
r.buildContainerConfig(),
255+
r.buildContainerConfig(pwd),
250256
hostConfig,
251257
&network.NetworkingConfig{},
252258
containerName,
@@ -345,9 +351,9 @@ func (r *RestoreJob) runSyncInstance(ctx context.Context) error {
345351
returnnil
346352
}
347353

348-
func (r*RestoreJob)getEnvironmentVariables() []string {
354+
func (r*RestoreJob)getEnvironmentVariables(passwordstring) []string {
349355
envVariables:=append([]string{
350-
"POSTGRES_HOST_AUTH_METHOD=trust",
356+
"POSTGRES_PASSWORD="+password,
351357
"PGDATA="+r.globalCfg.DataDir,
352358
},r.restorer.GetEnvVariables()...)
353359

@@ -358,10 +364,10 @@ func (r *RestoreJob) getEnvironmentVariables() []string {
358364
returnenvVariables
359365
}
360366

361-
func (r*RestoreJob)buildContainerConfig()*container.Config {
367+
func (r*RestoreJob)buildContainerConfig(passwordstring)*container.Config {
362368
return&container.Config{
363369
Labels:map[string]string{"label":tools.DBLabControlLabel},
364-
Env:r.getEnvironmentVariables(),
370+
Env:r.getEnvironmentVariables(password),
365371
Image:r.DockerImage,
366372
}
367373
}

‎pkg/retrieval/engine/postgres/initialize/snapshot/physical.go‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/docker/docker/client"
2626
"github.com/pkg/errors"
2727
"github.com/robfig/cron/v3"
28+
"github.com/sethvargo/go-password/password"
2829

2930
dblabCfg"gitlab.com/postgres-ai/database-lab/pkg/config"
3031
"gitlab.com/postgres-ai/database-lab/pkg/log"
@@ -327,9 +328,14 @@ func (p *PhysicalInitial) promoteInstance(ctx context.Context, clonePath string)
327328
returnerrors.Wrap(err,"failed to scan image pulling response")
328329
}
329330

331+
pwd,err:=password.Generate(tools.PasswordLength,tools.PasswordMinDigits,tools.PasswordMinSymbols,false,true)
332+
iferr!=nil {
333+
returnerrors.Wrap(err,"failed to generate PostgreSQL password")
334+
}
335+
330336
// Run promotion container.
331337
cont,err:=p.dockerClient.ContainerCreate(ctx,
332-
p.buildContainerConfig(clonePath,promoteImage),
338+
p.buildContainerConfig(clonePath,promoteImage,pwd),
333339
hostConfig,
334340
&network.NetworkingConfig{},
335341
p.promoteContainerName(),
@@ -463,12 +469,12 @@ func (p *PhysicalInitial) adjustRecoveryConfiguration(pgVersion, clonePGDataDir
463469
returnnil
464470
}
465471

466-
func (p*PhysicalInitial)buildContainerConfig(clonePath,promoteImagestring)*container.Config {
472+
func (p*PhysicalInitial)buildContainerConfig(clonePath,promoteImage,passwordstring)*container.Config {
467473
return&container.Config{
468474
Labels:map[string]string{"label":tools.DBLabControlLabel},
469475
Env: []string{
470476
"PGDATA="+clonePath,
471-
"POSTGRES_HOST_AUTH_METHOD=trust",
477+
"POSTGRES_PASSWORD="+password,
472478
},
473479
Image:promoteImage,
474480
Healthcheck:health.GetConfig(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp