move backward compatible check and update test
This commit is contained in:
		
							parent
							
								
									29c41ff62c
								
							
						
					
					
						commit
						6437b39fec
					
				|  | @ -120,15 +120,6 @@ func (p *Postgresql) UnmarshalJSON(data []byte) error { | |||
| 		tmp2.Spec.ClusterName = clusterName | ||||
| 	} | ||||
| 
 | ||||
| 	if tmp2.Spec.InitContainersOld != nil && tmp2.Spec.InitContainers == nil { | ||||
| 		tmp2.Spec.InitContainers = tmp2.Spec.InitContainersOld | ||||
| 		tmp2.Spec.InitContainersOld = nil | ||||
| 	} | ||||
| 	if tmp2.Spec.PodPriorityClassNameOld != "" && tmp2.Spec.PodPriorityClassName == "" { | ||||
| 		tmp2.Spec.PodPriorityClassName = tmp2.Spec.PodPriorityClassNameOld | ||||
| 		tmp2.Spec.PodPriorityClassNameOld = "" | ||||
| 	} | ||||
| 
 | ||||
| 	*p = tmp2 | ||||
| 
 | ||||
| 	return nil | ||||
|  |  | |||
|  | @ -263,7 +263,7 @@ var unmarshalCluster = []struct { | |||
| 						"log_statement":   "all", | ||||
| 					}, | ||||
| 				}, | ||||
| 				PodPriorityClassName: "spilo-pod-priority", | ||||
| 				PodPriorityClassNameOld: "spilo-pod-priority", | ||||
| 				Volume: Volume{ | ||||
| 					Size:         "5Gi", | ||||
| 					StorageClass: "SSD", | ||||
|  | @ -316,7 +316,7 @@ var unmarshalCluster = []struct { | |||
| 			}, | ||||
| 			Error: "", | ||||
| 		}, | ||||
| 		marshal: []byte(`{"kind":"Postgresql","apiVersion":"acid.zalan.do/v1","metadata":{"name":"acid-testcluster1","creationTimestamp":null},"spec":{"postgresql":{"version":"9.6","parameters":{"log_statement":"all","max_connections":"10","shared_buffers":"32MB"}},"podPriorityClassName":"spilo-pod-priority","volume":{"size":"5Gi","storageClass":"SSD", "subPath": "subdir"},"patroni":{"initdb":{"data-checksums":"true","encoding":"UTF8","locale":"en_US.UTF-8"},"pg_hba":["hostssl all all 0.0.0.0/0 md5","host    all all 0.0.0.0/0 md5"],"ttl":30,"loop_wait":10,"retry_timeout":10,"maximum_lag_on_failover":33554432,"slots":{"permanent_logical_1":{"database":"foo","plugin":"pgoutput","type":"logical"}}},"resources":{"requests":{"cpu":"10m","memory":"50Mi"},"limits":{"cpu":"300m","memory":"3000Mi"}},"teamId":"ACID","allowedSourceRanges":["127.0.0.1/32"],"numberOfInstances":2,"users":{"zalando":["superuser","createdb"]},"maintenanceWindows":["Mon:01:00-06:00","Sat:00:00-04:00","05:00-05:15"],"clone":{"cluster":"acid-batman"}},"status":{"PostgresClusterStatus":""}}`), | ||||
| 		marshal: []byte(`{"kind":"Postgresql","apiVersion":"acid.zalan.do/v1","metadata":{"name":"acid-testcluster1","creationTimestamp":null},"spec":{"postgresql":{"version":"9.6","parameters":{"log_statement":"all","max_connections":"10","shared_buffers":"32MB"}},"pod_priority_class_name":"spilo-pod-priority","volume":{"size":"5Gi","storageClass":"SSD", "subPath": "subdir"},"patroni":{"initdb":{"data-checksums":"true","encoding":"UTF8","locale":"en_US.UTF-8"},"pg_hba":["hostssl all all 0.0.0.0/0 md5","host    all all 0.0.0.0/0 md5"],"ttl":30,"loop_wait":10,"retry_timeout":10,"maximum_lag_on_failover":33554432,"slots":{"permanent_logical_1":{"database":"foo","plugin":"pgoutput","type":"logical"}}},"resources":{"requests":{"cpu":"10m","memory":"50Mi"},"limits":{"cpu":"300m","memory":"3000Mi"}},"teamId":"ACID","allowedSourceRanges":["127.0.0.1/32"],"numberOfInstances":2,"users":{"zalando":["superuser","createdb"]},"maintenanceWindows":["Mon:01:00-06:00","Sat:00:00-04:00","05:00-05:15"],"clone":{"cluster":"acid-batman"}},"status":{"PostgresClusterStatus":""}}`), | ||||
| 		err:     nil}, | ||||
| 	// example with teamId set in input
 | ||||
| 	{ | ||||
|  |  | |||
|  | @ -801,6 +801,28 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*v1beta1.State | |||
| 		return nil, fmt.Errorf("s3_wal_path is empty for standby cluster") | ||||
| 	} | ||||
| 
 | ||||
| 	// backward compatible check for InitContainers
 | ||||
| 	if spec.InitContainersOld != nil { | ||||
| 		msg := "Manifest parameter init_containers is deprecated." | ||||
| 		if spec.InitContainers == nil { | ||||
| 			c.logger.Warningf("%s Consider using initContainers instead.", msg) | ||||
| 			spec.InitContainers = spec.InitContainersOld | ||||
| 		} else { | ||||
| 			c.logger.Warningf("%s Only value from initContainers is used", msg) | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	// backward compatible check for PodPriorityClassName
 | ||||
| 	if spec.PodPriorityClassNameOld != "" { | ||||
| 		msg := "Manifest parameter pod_priority_class_name is deprecated." | ||||
| 		if spec.PodPriorityClassName == "" { | ||||
| 			c.logger.Warningf("%s Consider using podPriorityClassName instead.", msg) | ||||
| 			spec.PodPriorityClassName = spec.PodPriorityClassNameOld | ||||
| 		} else { | ||||
| 			c.logger.Warningf("%s Only value from podPriorityClassName is used", msg) | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	spiloConfiguration, err := generateSpiloJSONConfiguration(&spec.PostgresqlParam, &spec.Patroni, c.OpConfig.PamRoleName, c.logger) | ||||
| 	if err != nil { | ||||
| 		return nil, fmt.Errorf("could not generate Spilo JSON configuration: %v", err) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue