Merge 3e4c42e264 into 1af4c50ed0
				
					
				
			This commit is contained in:
		
						commit
						f323829fc3
					
				|  | @ -494,6 +494,8 @@ spec: | |||
|                     type: string | ||||
|                   standby_port: | ||||
|                     type: string | ||||
|                   standby_primary_slot_name: | ||||
|                     type: string | ||||
|                 oneOf: | ||||
|                 - required: | ||||
|                   - s3_wal_path | ||||
|  |  | |||
|  | @ -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. | ||||
| 
 | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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: | ||||
|  |  | |||
|  | @ -492,6 +492,8 @@ spec: | |||
|                     type: string | ||||
|                   standby_port: | ||||
|                     type: string | ||||
|                   standby_primary_slot_name: | ||||
|                     type: string | ||||
|                 oneOf: | ||||
|                 - required: | ||||
|                   - s3_wal_path | ||||
|  |  | |||
|  | @ -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" | ||||
|  |  | |||
|  | @ -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"}}, | ||||
|  |  | |||
|  | @ -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
 | ||||
|  |  | |||
|  | @ -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 != "" { | ||||
|  |  | |||
|  | @ -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{ | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue