Skip to content

Commit b00706b

Browse files
committed
fix: ensure restore configuration points to manager wal-restore
Signed-off-by: Armando Ruocco <[email protected]>
1 parent c639af1 commit b00706b

File tree

1 file changed

+11
-31
lines changed

1 file changed

+11
-31
lines changed

internal/cnpgi/restore/restore.go

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ import (
44
"context"
55
"errors"
66
"fmt"
7-
"os"
8-
"os/exec"
9-
"path"
10-
"strings"
11-
127
"github.com/cloudnative-pg/barman-cloud/pkg/api"
138
barmanArchiver "github.com/cloudnative-pg/barman-cloud/pkg/archiver"
149
barmanCapabilities "github.com/cloudnative-pg/barman-cloud/pkg/capabilities"
@@ -17,6 +12,7 @@ import (
1712
barmanCredentials "github.com/cloudnative-pg/barman-cloud/pkg/credentials"
1813
barmanRestorer "github.com/cloudnative-pg/barman-cloud/pkg/restorer"
1914
cnpgv1 "github.com/cloudnative-pg/cloudnative-pg/api/v1"
15+
"github.com/cloudnative-pg/cloudnative-pg/pkg/postgres"
2016
"github.com/cloudnative-pg/cloudnative-pg/pkg/utils"
2117
"github.com/cloudnative-pg/cnpg-i-machinery/pkg/pluginhelper/decoder"
2218
restore "github.com/cloudnative-pg/cnpg-i/pkg/restore/job"
@@ -25,6 +21,9 @@ import (
2521
"github.com/cloudnative-pg/machinery/pkg/log"
2622
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2723
"k8s.io/apimachinery/pkg/types"
24+
"os"
25+
"os/exec"
26+
"path"
2827
"sigs.k8s.io/controller-runtime/pkg/client"
2928

3029
barmancloudv1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
@@ -152,10 +151,7 @@ func (impl JobHookImpl) Restore(
152151
}
153152
}
154153

155-
config, err := getRestoreWalConfig(ctx, backup, &recoveryObjectStore.Spec.Configuration)
156-
if err != nil {
157-
return nil, err
158-
}
154+
config := getRestoreWalConfig()
159155

160156
contextLogger.Info("sending restore response", "config", config, "env", env)
161157
return &restore.RestoreResponse{
@@ -336,33 +332,17 @@ func (impl JobHookImpl) restoreCustomWalDir(ctx context.Context) (bool, error) {
336332
// getRestoreWalConfig obtains the content to append to `custom.conf` allowing PostgreSQL
337333
// to complete the WAL recovery from the object storage and then start
338334
// as a new primary
339-
func getRestoreWalConfig(
340-
ctx context.Context,
341-
backup *cnpgv1.Backup,
342-
barmanConfiguration *cnpgv1.BarmanObjectStoreConfiguration,
343-
) (string, error) {
344-
var err error
345-
346-
cmd := []string{barmanCapabilities.BarmanCloudWalRestore}
347-
if backup.Status.EndpointURL != "" {
348-
cmd = append(cmd, "--endpoint-url", backup.Status.EndpointURL)
349-
}
350-
cmd = append(cmd, backup.Status.DestinationPath)
351-
cmd = append(cmd, backup.Status.ServerName)
352-
353-
cmd, err = barmanCommand.AppendCloudProviderOptionsFromConfiguration(ctx, cmd, barmanConfiguration)
354-
if err != nil {
355-
return "", err
356-
}
357-
358-
cmd = append(cmd, "%f", "%p")
335+
func getRestoreWalConfig() string {
336+
restoreCmd := fmt.Sprintf(
337+
"/controller/manager wal-restore --log-destination %s/%s.json %%f %%p",
338+
postgres.LogPath, postgres.LogFileName)
359339

360340
recoveryFileContents := fmt.Sprintf(
361341
"recovery_target_action = promote\n"+
362342
"restore_command = '%s'\n",
363-
strings.Join(cmd, " "))
343+
restoreCmd)
364344

365-
return recoveryFileContents, nil
345+
return recoveryFileContents
366346
}
367347

368348
// loadBackupObjectFromExternalCluster generates an in-memory Backup structure given a reference to

0 commit comments

Comments
 (0)