Merge 3e4c42e264 into 1af4c50ed0
				
					
				
			This commit is contained in:
		
						commit
						f323829fc3
					
				|  | @ -494,6 +494,8 @@ spec: | ||||||
|                     type: string |                     type: string | ||||||
|                   standby_port: |                   standby_port: | ||||||
|                     type: string |                     type: string | ||||||
|  |                   standby_primary_slot_name: | ||||||
|  |                     type: string | ||||||
|                 oneOf: |                 oneOf: | ||||||
|                 - required: |                 - required: | ||||||
|                   - s3_wal_path |                   - 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. | 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. | 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`, | Note, that only one of the options (`s3_wal_path`, `gs_wal_path`, | ||||||
| `standby_host`) can be present under the `standby` top-level key. | `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 |   TCP port on which the primary is listening for connections. Patroni will | ||||||
|   use `"5432"` if not set. |   use `"5432"` if not set. | ||||||
| 
 | 
 | ||||||
|  | * **standby_primary_slot_name** | ||||||
|  |   replication slot on the primary. | ||||||
|  | 
 | ||||||
| ## Volume properties | ## Volume properties | ||||||
| 
 | 
 | ||||||
| Those parameters are grouped under the `volume` top-level key and define the | Those parameters are grouped under the `volume` top-level key and define the | ||||||
|  |  | ||||||
|  | @ -927,6 +927,15 @@ spec: | ||||||
|   standby: |   standby: | ||||||
|     standby_host: "acid-minimal-cluster.default" |     standby_host: "acid-minimal-cluster.default" | ||||||
|     standby_port: "5433" |     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: | Note, that the pods and services use the same role labels like for normal clusters: | ||||||
|  |  | ||||||
|  | @ -492,6 +492,8 @@ spec: | ||||||
|                     type: string |                     type: string | ||||||
|                   standby_port: |                   standby_port: | ||||||
|                     type: string |                     type: string | ||||||
|  |                   standby_primary_slot_name: | ||||||
|  |                     type: string | ||||||
|                 oneOf: |                 oneOf: | ||||||
|                 - required: |                 - required: | ||||||
|                   - s3_wal_path |                   - s3_wal_path | ||||||
|  |  | ||||||
|  | @ -14,3 +14,4 @@ spec: | ||||||
|     # s3_wal_path: "s3://mybucket/spilo/acid-minimal-cluster/abcd1234-2a4b-4b2a-8c9c-c1234defg567/wal/14/" |     # s3_wal_path: "s3://mybucket/spilo/acid-minimal-cluster/abcd1234-2a4b-4b2a-8c9c-c1234defg567/wal/14/" | ||||||
|     standby_host: "acid-minimal-cluster.default" |     standby_host: "acid-minimal-cluster.default" | ||||||
|     # standby_port: "5432" |     # standby_port: "5432" | ||||||
|  |     # standby_primary_slot_name: "slot" | ||||||
|  |  | ||||||
|  | @ -766,6 +766,9 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{ | ||||||
| 							"standby_port": { | 							"standby_port": { | ||||||
| 								Type: "string", | 								Type: "string", | ||||||
| 							}, | 							}, | ||||||
|  | 							"standby_primary_slot_name": { | ||||||
|  | 								Type: "string", | ||||||
|  | 							}, | ||||||
| 						}, | 						}, | ||||||
| 						OneOf: []apiextv1.JSONSchemaProps{ | 						OneOf: []apiextv1.JSONSchemaProps{ | ||||||
| 							apiextv1.JSONSchemaProps{Required: []string{"s3_wal_path"}}, | 							apiextv1.JSONSchemaProps{Required: []string{"s3_wal_path"}}, | ||||||
|  |  | ||||||
|  | @ -190,6 +190,7 @@ type StandbyDescription struct { | ||||||
| 	GSWalPath              string `json:"gs_wal_path,omitempty"` | 	GSWalPath              string `json:"gs_wal_path,omitempty"` | ||||||
| 	StandbyHost            string `json:"standby_host,omitempty"` | 	StandbyHost            string `json:"standby_host,omitempty"` | ||||||
| 	StandbyPort            string `json:"standby_port,omitempty"` | 	StandbyPort            string `json:"standby_port,omitempty"` | ||||||
|  | 	StandbyPrimarySlotName string `json:"standby_primary_slot_name,omitempty"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // TLSDescription specs TLS properties
 | // TLSDescription specs TLS properties
 | ||||||
|  |  | ||||||
|  | @ -2192,6 +2192,12 @@ func (c *Cluster) generateStandbyEnvironment(description *acidv1.StandbyDescript | ||||||
| 				Value: description.StandbyPort, | 				Value: description.StandbyPort, | ||||||
| 			}) | 			}) | ||||||
| 		} | 		} | ||||||
|  | 		if description.StandbyPrimarySlotName != "" { | ||||||
|  | 			result = append(result, v1.EnvVar{ | ||||||
|  | 				Name:  "STANDBY_PRIMARY_SLOT_NAME", | ||||||
|  | 				Value: description.StandbyPrimarySlotName, | ||||||
|  | 			}) | ||||||
|  | 		} | ||||||
| 	} else { | 	} else { | ||||||
| 		c.logger.Info("standby cluster streaming from WAL location") | 		c.logger.Info("standby cluster streaming from WAL location") | ||||||
| 		if description.S3WalPath != "" { | 		if description.S3WalPath != "" { | ||||||
|  |  | ||||||
|  | @ -1369,6 +1369,19 @@ func TestStandbyEnv(t *testing.T) { | ||||||
| 			envPos: 1, | 			envPos: 1, | ||||||
| 			envLen: 2, | 			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", | 			subTest: "from remote primary - ignore WAL path", | ||||||
| 			standbyOpts: &acidv1.StandbyDescription{ | 			standbyOpts: &acidv1.StandbyDescription{ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue