MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / innerArchiveWAL

Method innerArchiveWAL

internal/cnpi/plugin/client/wal.go:42–83  ·  view source on GitHub ↗
(
	ctx context.Context,
	cluster client.Object,
	sourceFileName string,
)

Source from the content-addressed store, hash-verified

40}
41
42func (data *data) innerArchiveWAL(
43 ctx context.Context,
44 cluster client.Object,
45 sourceFileName string,
46) error {
47 contextLogger := log.FromContext(ctx)
48
49 serializedCluster, err := json.Marshal(cluster)
50 if err != nil {
51 return fmt.Errorf("while serializing %s %s/%s to JSON: %w",
52 cluster.GetObjectKind().GroupVersionKind().Kind,
53 cluster.GetNamespace(), cluster.GetName(),
54 err,
55 )
56 }
57
58 for idx := range data.plugins {
59 plugin := data.plugins[idx]
60
61 if !slices.Contains(plugin.WALCapabilities(), wal.WALCapability_RPC_TYPE_ARCHIVE_WAL) {
62 continue
63 }
64
65 pluginLogger := contextLogger.WithValues("pluginName", plugin.Name())
66 request := wal.WALArchiveRequest{
67 ClusterDefinition: serializedCluster,
68 SourceFileName: sourceFileName,
69 }
70
71 pluginLogger.Trace(
72 "Calling ArchiveWAL endpoint",
73 "clusterDefinition", request.ClusterDefinition,
74 "sourceFile", request.SourceFileName)
75 _, err := plugin.WALClient().Archive(ctx, &request)
76 if err != nil {
77 pluginLogger.Error(err, "Error while calling ArchiveWAL, failing")
78 return err
79 }
80 }
81
82 return nil
83}
84
85func (data *data) RestoreWAL(
86 ctx context.Context,

Callers 1

ArchiveWALMethod · 0.95

Calls 8

TraceMethod · 0.80
GetNameMethod · 0.65
WALCapabilitiesMethod · 0.65
NameMethod · 0.65
WALClientMethod · 0.65
GetNamespaceMethod · 0.45
WithValuesMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected