Skip to content

Commit 090aaac

Browse files
committed
Merge branch '152-snapshot-customization' into 'master'
fix: allow to use custom Docker images for data promotion, add preprocessing runner (#152) See merge request postgres-ai/database-lab!167
2 parents afdbbac + b2ce7a3 commit 090aaac

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

configs/config.example.physical_generic.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ retrieval:
153153
# Promote PGDATA after data fetching.
154154
promote: true
155155

156+
# Custom Docker image for data promotion.
157+
dockerImage: "postgresai/sync-instance:12"
158+
156159
# It is possible to define a pre-precessing script. For example, "/tmp/scripts/custom.sh".
157160
# Default: empty string (no pre-processing defined).
158161
# This can be used for scrubbing eliminating PII data, to define data masking, etc.

configs/config.example.physical_walg.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ retrieval:
142142
# Promote PGDATA after data fetching.
143143
promote: true
144144

145+
# Custom Docker image for data promotion.
146+
dockerImage: "postgresai/sync-instance:12"
147+
145148
# It is possible to define a pre-precessing script. For example, "/tmp/scripts/custom.sh".
146149
# Default: empty string (no pre-processing defined).
147150
# This can be used for scrubbing eliminating PII data, to define data masking, etc.

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type PhysicalInitial struct {
7070
// PhysicalOptions describes options for a physical initialization job.
7171
type PhysicalOptions struct {
7272
Promote bool `yaml:"promote"`
73+
DockerImage string `yaml:"dockerImage"`
7374
PreprocessingScript string `yaml:"preprocessingScript"`
7475
Configs map[string]string `yaml:"configs"`
7576
Scheduler *Scheduler `yaml:"scheduler"`
@@ -329,7 +330,10 @@ func (p *PhysicalInitial) promoteInstance(ctx context.Context, clonePath string)
329330
return errors.Wrap(err, "failed to build container host config")
330331
}
331332

332-
promoteImage := fmt.Sprintf("postgresai/sync-instance:%s", pgVersion)
333+
promoteImage := p.options.DockerImage
334+
if promoteImage == "" {
335+
promoteImage = fmt.Sprintf("postgresai/sync-instance:%s", pgVersion)
336+
}
333337

334338
if err := tools.PullImage(ctx, p.dockerClient, promoteImage); err != nil {
335339
return errors.Wrap(err, "failed to scan image pulling response")

pkg/retrieval/engine/postgres/snapshot/snapshot.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ package snapshot
88
import (
99
"fmt"
1010
"os"
11-
"os/exec"
1211
"strings"
1312

1413
"github.com/pkg/errors"
1514

1615
"gitlab.com/postgres-ai/database-lab/pkg/log"
1716
"gitlab.com/postgres-ai/database-lab/pkg/retrieval/dbmarker"
17+
"gitlab.com/postgres-ai/database-lab/pkg/services/provision/runners"
1818
)
1919

2020
func extractDataStateAt(dbMarker *dbmarker.Marker) string {
@@ -31,12 +31,12 @@ func extractDataStateAt(dbMarker *dbmarker.Marker) string {
3131
}
3232

3333
func runPreprocessingScript(preprocessingScript string) error {
34-
commandOutput, err := exec.Command("bash", preprocessingScript).Output()
34+
commandOutput, err := runners.NewLocalRunner(false).Run(preprocessingScript)
3535
if err != nil {
3636
return errors.Wrap(err, "failed to run custom script")
3737
}
3838

39-
log.Msg(string(commandOutput))
39+
log.Msg(commandOutput)
4040

4141
return nil
4242
}

0 commit comments

Comments
 (0)