fix k8sres and update e2e tests
This commit is contained in:
		
							parent
							
								
									28275444d3
								
							
						
					
					
						commit
						8da271f0cb
					
				|  | @ -65,6 +65,14 @@ class EndToEndTestCase(unittest.TestCase): | |||
|         ''' | ||||
|         k8s = self.k8s | ||||
| 
 | ||||
|         # enable sidecars in cluster | ||||
|         toggle_sidecar_creation = { | ||||
|             "data": { | ||||
|                "enable_sidecars": "true", | ||||
|             } | ||||
|         } | ||||
|         k8s.update_config(toggle_sidecar_creation) | ||||
| 
 | ||||
|         with open("manifests/complete-postgres-manifest.yaml", 'r+') as f: | ||||
|             pg_manifest = yaml.safe_load(f) | ||||
|             pg_manifest["metadata"]["namespace"] = self.namespace | ||||
|  | @ -182,17 +190,12 @@ class EndToEndTestCase(unittest.TestCase): | |||
| 
 | ||||
|         # update the cluster-wide image of the logical backup pod | ||||
|         image = "test-image-name" | ||||
|         config_map_patch = { | ||||
|         patch_logical_backup_image = { | ||||
|             "data": { | ||||
|                "logical_backup_docker_image": image, | ||||
|             } | ||||
|         } | ||||
|         k8s.api.core_v1.patch_namespaced_config_map("postgres-operator", "default", config_map_patch) | ||||
| 
 | ||||
|         operator_pod = k8s.api.core_v1.list_namespaced_pod( | ||||
|             'default', label_selector="name=postgres-operator").items[0].metadata.name | ||||
|         k8s.api.core_v1.delete_namespaced_pod(operator_pod, "default")  # restart reloads the conf | ||||
|         k8s.wait_for_operator_pod_start() | ||||
|         k8s.update_config(patch_logical_backup_image) | ||||
| 
 | ||||
|         jobs = k8s.get_logical_backup_job().items | ||||
|         actual_image = jobs[0].spec.job_template.spec.template.spec.containers[0].image | ||||
|  | @ -319,6 +322,15 @@ class K8s: | |||
|     def wait_for_logical_backup_job_creation(self): | ||||
|         self.wait_for_logical_backup_job(expected_num_of_jobs=1) | ||||
| 
 | ||||
|     def update_config(self, config_map_patch): | ||||
| 
 | ||||
|         k8s.api.core_v1.patch_namespaced_config_map("postgres-operator", "default", config_map_patch) | ||||
| 
 | ||||
|         operator_pod = k8s.api.core_v1.list_namespaced_pod( | ||||
|             'default', label_selector="name=postgres-operator").items[0].metadata.name | ||||
|         k8s.api.core_v1.delete_namespaced_pod(operator_pod, "default")  # restart reloads the conf | ||||
|         k8s.wait_for_operator_pod_start() | ||||
| 
 | ||||
|     def create_with_kubectl(self, path): | ||||
|         subprocess.run(["kubectl", "create", "-f", path]) | ||||
| 
 | ||||
|  |  | |||
|  | @ -787,11 +787,11 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef | |||
| 		return nil, fmt.Errorf("could not generate resource requirements: %v", err) | ||||
| 	} | ||||
| 
 | ||||
| 	if spec.InitContainers != nil { | ||||
| 	if spec.InitContainers != nil && len(spec.InitContainers) > 0 { | ||||
| 		if c.OpConfig.EnableInitContainers { | ||||
| 			initContainers = spec.InitContainers | ||||
| 		} else { | ||||
| 			return nil, fmt.Errorf("InitContainers specified but globally disabled!") | ||||
| 			return nil, fmt.Errorf("initContainers specified but globally disabled") | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  | @ -881,14 +881,14 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef | |||
| 	} | ||||
| 
 | ||||
| 	// generate sidecar containers
 | ||||
| 	if sideCars != nil { | ||||
| 	if sideCars != nil && len(sideCars) > 0 { | ||||
| 		if c.OpConfig.EnableSidecars { | ||||
| 			if sidecarContainers, err = generateSidecarContainers(sideCars, volumeMounts, defaultResources, | ||||
| 				c.OpConfig.SuperUsername, c.credentialSecretName(c.OpConfig.SuperUsername), c.logger); err != nil { | ||||
| 				return nil, fmt.Errorf("could not generate sidecar containers: %v", err) | ||||
| 			} | ||||
| 		} else { | ||||
| 			return nil, fmt.Errorf("Sidecar containers specified but globally disabled!") | ||||
| 			return nil, fmt.Errorf("sidecar containers specified but globally disabled") | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue