mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-01 02:02:02 +02:00
Support standby replication from GS (GCS) (#1446)
* Add support for manual gs_wal_path in standby * Remove separate standby version configuration * Remove setting standby path via cluster/uid/version Picking up the version doesn't work reliably without making changes to Spilo. It's clearer to just specify the full S3/GS bucket path. Co-authored-by: Felix Kunde <felix-kunde@gmx.de>
This commit is contained in:
co-authored by
Felix Kunde
parent
1ed16fadca
commit
def9e1d688
@@ -649,12 +649,14 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
|
||||
Type: "integer",
|
||||
},
|
||||
"standby": {
|
||||
Type: "object",
|
||||
Required: []string{"s3_wal_path"},
|
||||
Type: "object",
|
||||
Properties: map[string]apiextv1.JSONSchemaProps{
|
||||
"s3_wal_path": {
|
||||
Type: "string",
|
||||
},
|
||||
"gs_wal_path": {
|
||||
Type: "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
"teamId": {
|
||||
|
||||
@@ -166,6 +166,7 @@ type Patroni struct {
|
||||
// StandbyDescription contains s3 wal path
|
||||
type StandbyDescription struct {
|
||||
S3WalPath string `json:"s3_wal_path,omitempty"`
|
||||
GSWalPath string `json:"gs_wal_path,omitempty"`
|
||||
}
|
||||
|
||||
// TLSDescription specs TLS properties
|
||||
|
||||
+30
-10
@@ -1058,8 +1058,9 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
|
||||
sort.Slice(customPodEnvVarsList,
|
||||
func(i, j int) bool { return customPodEnvVarsList[i].Name < customPodEnvVarsList[j].Name })
|
||||
|
||||
if spec.StandbyCluster != nil && spec.StandbyCluster.S3WalPath == "" {
|
||||
return nil, fmt.Errorf("s3_wal_path is empty for standby cluster")
|
||||
if spec.StandbyCluster != nil && spec.StandbyCluster.S3WalPath == "" &&
|
||||
spec.StandbyCluster.GSWalPath == "" {
|
||||
return nil, fmt.Errorf("one of s3_wal_path or gs_wal_path must be set for standby cluster")
|
||||
}
|
||||
|
||||
// backward compatible check for InitContainers
|
||||
@@ -1874,17 +1875,36 @@ func (c *Cluster) generateCloneEnvironment(description *acidv1.CloneDescription)
|
||||
func (c *Cluster) generateStandbyEnvironment(description *acidv1.StandbyDescription) []v1.EnvVar {
|
||||
result := make([]v1.EnvVar, 0)
|
||||
|
||||
if description.S3WalPath == "" {
|
||||
if description.S3WalPath == "" && description.GSWalPath == "" {
|
||||
return nil
|
||||
}
|
||||
// standby with S3, find out the bucket to setup standby
|
||||
msg := "Standby from S3 bucket using custom parsed S3WalPath from the manifest %s "
|
||||
c.logger.Infof(msg, description.S3WalPath)
|
||||
|
||||
result = append(result, v1.EnvVar{
|
||||
Name: "STANDBY_WALE_S3_PREFIX",
|
||||
Value: description.S3WalPath,
|
||||
})
|
||||
if description.S3WalPath != "" {
|
||||
// standby with S3, find out the bucket to setup standby
|
||||
msg := "Standby from S3 bucket using custom parsed S3WalPath from the manifest %s "
|
||||
c.logger.Infof(msg, description.S3WalPath)
|
||||
|
||||
result = append(result, v1.EnvVar{
|
||||
Name: "STANDBY_WALE_S3_PREFIX",
|
||||
Value: description.S3WalPath,
|
||||
})
|
||||
} else if description.GSWalPath != "" {
|
||||
msg := "Standby from GS bucket using custom parsed GSWalPath from the manifest %s "
|
||||
c.logger.Infof(msg, description.GSWalPath)
|
||||
|
||||
envs := []v1.EnvVar{
|
||||
{
|
||||
Name: "STANDBY_WALE_GS_PREFIX",
|
||||
Value: description.GSWalPath,
|
||||
},
|
||||
{
|
||||
Name: "STANDBY_GOOGLE_APPLICATION_CREDENTIALS",
|
||||
Value: c.OpConfig.GCPCredentials,
|
||||
},
|
||||
}
|
||||
result = append(result, envs...)
|
||||
|
||||
}
|
||||
|
||||
result = append(result, v1.EnvVar{Name: "STANDBY_METHOD", Value: "STANDBY_WITH_WALE"})
|
||||
result = append(result, v1.EnvVar{Name: "STANDBY_WAL_BUCKET_SCOPE_PREFIX", Value: ""})
|
||||
|
||||
Reference in New Issue
Block a user