This commit is contained in:
Ayoub Mrini 2025-10-21 15:03:12 +02:00 committed by GitHub
commit f323829fc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 45 additions and 4 deletions

View File

@ -494,6 +494,8 @@ spec:
type: string
standby_port:
type: string
standby_primary_slot_name:
type: string
oneOf:
- required:
- s3_wal_path

View File

@ -1348,6 +1348,7 @@ the `STANDBY_` prefix for Spilo to find the backups and WAL files to stream.
Alternatively, standby clusters can also stream from a remote primary cluster.
You have to specify the host address. Port is optional and defaults to 5432.
Moreover, you can also specify a replication slot of the primary.
Note, that only one of the options (`s3_wal_path`, `gs_wal_path`,
`standby_host`) can be present under the `standby` top-level key.

View File

@ -473,6 +473,9 @@ if the `standby` key is present.
TCP port on which the primary is listening for connections. Patroni will
use `"5432"` if not set.
* **standby_primary_slot_name**
replication slot on the primary.
## Volume properties
Those parameters are grouped under the `volume` top-level key and define the

View File

@ -927,6 +927,15 @@ spec:
standby:
standby_host: "acid-minimal-cluster.default"
standby_port: "5433"
standby_primary_slot_name: "slot"
```
If needed, one can also specify the slot on the primary to use for replication.
```yaml
spec:
standby:
standby_primary_slot_name: "slot"
```
Note, that the pods and services use the same role labels like for normal clusters:

View File

@ -492,6 +492,8 @@ spec:
type: string
standby_port:
type: string
standby_primary_slot_name:
type: string
oneOf:
- required:
- s3_wal_path

View File

@ -14,3 +14,4 @@ spec:
# s3_wal_path: "s3://mybucket/spilo/acid-minimal-cluster/abcd1234-2a4b-4b2a-8c9c-c1234defg567/wal/14/"
standby_host: "acid-minimal-cluster.default"
# standby_port: "5432"
# standby_primary_slot_name: "slot"

View File

@ -766,6 +766,9 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
"standby_port": {
Type: "string",
},
"standby_primary_slot_name": {
Type: "string",
},
},
OneOf: []apiextv1.JSONSchemaProps{
apiextv1.JSONSchemaProps{Required: []string{"s3_wal_path"}},

View File

@ -186,10 +186,11 @@ type Patroni struct {
// StandbyDescription contains remote primary config or s3/gs wal path
type StandbyDescription struct {
S3WalPath string `json:"s3_wal_path,omitempty"`
GSWalPath string `json:"gs_wal_path,omitempty"`
StandbyHost string `json:"standby_host,omitempty"`
StandbyPort string `json:"standby_port,omitempty"`
S3WalPath string `json:"s3_wal_path,omitempty"`
GSWalPath string `json:"gs_wal_path,omitempty"`
StandbyHost string `json:"standby_host,omitempty"`
StandbyPort string `json:"standby_port,omitempty"`
StandbyPrimarySlotName string `json:"standby_primary_slot_name,omitempty"`
}
// TLSDescription specs TLS properties

View File

@ -2192,6 +2192,12 @@ func (c *Cluster) generateStandbyEnvironment(description *acidv1.StandbyDescript
Value: description.StandbyPort,
})
}
if description.StandbyPrimarySlotName != "" {
result = append(result, v1.EnvVar{
Name: "STANDBY_PRIMARY_SLOT_NAME",
Value: description.StandbyPrimarySlotName,
})
}
} else {
c.logger.Info("standby cluster streaming from WAL location")
if description.S3WalPath != "" {

View File

@ -1369,6 +1369,19 @@ func TestStandbyEnv(t *testing.T) {
envPos: 1,
envLen: 2,
},
{
subTest: "from remote primary with slot",
standbyOpts: &acidv1.StandbyDescription{
StandbyHost: "remote-primary",
StandbyPrimarySlotName: "slot",
},
env: v1.EnvVar{
Name: "STANDBY_PRIMARY_SLOT_NAME",
Value: "slot",
},
envPos: 1,
envLen: 2,
},
{
subTest: "from remote primary - ignore WAL path",
standbyOpts: &acidv1.StandbyDescription{