add pvc to test + minor changes
This commit is contained in:
		
							parent
							
								
									1ac2decdea
								
							
						
					
					
						commit
						ce8a0d6f5b
					
				| 
						 | 
					@ -866,7 +866,8 @@ func (c *Cluster) syncConnectionPoolerWorker(oldSpec, newSpec *acidv1.Postgresql
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	newAnnotations := c.AnnotationsToPropagate(c.ConnectionPooler[role].Deployment.Annotations)
 | 
						newAnnotations := c.annotationsSet(c.ConnectionPooler[role].Deployment.Annotations)
 | 
				
			||||||
 | 
						newAnnotations = c.AnnotationsToPropagate(newAnnotations)
 | 
				
			||||||
	if newAnnotations != nil {
 | 
						if newAnnotations != nil {
 | 
				
			||||||
		deployment, err = updateConnectionPoolerAnnotations(c.KubeClient, c.ConnectionPooler[role].Deployment, newAnnotations)
 | 
							deployment, err = updateConnectionPoolerAnnotations(c.KubeClient, c.ConnectionPooler[role].Deployment, newAnnotations)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -353,8 +353,9 @@ func (c *Cluster) syncStatefulSet() error {
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		annotations := c.AnnotationsToPropagate(c.Statefulset.Annotations)
 | 
							annotations := c.annotationsSet(c.Statefulset.Annotations)
 | 
				
			||||||
		c.updateStatefulSetAnnotations(c.annotationsSet(annotations))
 | 
							annotations = c.AnnotationsToPropagate(annotations)
 | 
				
			||||||
 | 
							c.updateStatefulSetAnnotations(annotations)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if !podsRollingUpdateRequired && !c.OpConfig.EnableLazySpiloUpgrade {
 | 
							if !podsRollingUpdateRequired && !c.OpConfig.EnableLazySpiloUpgrade {
 | 
				
			||||||
			// even if desired and actual statefulsets match
 | 
								// even if desired and actual statefulsets match
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,13 +17,14 @@ func newFakeK8sAnnotationsClient() (k8sutil.KubernetesClient, *fake.Clientset) {
 | 
				
			||||||
	clientSet := fake.NewSimpleClientset()
 | 
						clientSet := fake.NewSimpleClientset()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return k8sutil.KubernetesClient{
 | 
						return k8sutil.KubernetesClient{
 | 
				
			||||||
		DeploymentsGetter:          clientSet.AppsV1(),
 | 
							DeploymentsGetter:            clientSet.AppsV1(),
 | 
				
			||||||
		EndpointsGetter:            clientSet.CoreV1(),
 | 
							EndpointsGetter:              clientSet.CoreV1(),
 | 
				
			||||||
		PodsGetter:                 clientSet.CoreV1(),
 | 
							PersistentVolumeClaimsGetter: clientSet.CoreV1(),
 | 
				
			||||||
		PodDisruptionBudgetsGetter: clientSet.PolicyV1beta1(),
 | 
							PodsGetter:                   clientSet.CoreV1(),
 | 
				
			||||||
		SecretsGetter:              clientSet.CoreV1(),
 | 
							PodDisruptionBudgetsGetter:   clientSet.PolicyV1beta1(),
 | 
				
			||||||
		ServicesGetter:             clientSet.CoreV1(),
 | 
							SecretsGetter:                clientSet.CoreV1(),
 | 
				
			||||||
		StatefulSetsGetter:         clientSet.AppsV1(),
 | 
							ServicesGetter:               clientSet.CoreV1(),
 | 
				
			||||||
 | 
							StatefulSetsGetter:           clientSet.AppsV1(),
 | 
				
			||||||
	}, clientSet
 | 
						}, clientSet
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,13 +33,13 @@ func TestInheritedAnnotations(t *testing.T) {
 | 
				
			||||||
	client, _ := newFakeK8sAnnotationsClient()
 | 
						client, _ := newFakeK8sAnnotationsClient()
 | 
				
			||||||
	clusterName := "acid-test-cluster"
 | 
						clusterName := "acid-test-cluster"
 | 
				
			||||||
	namespace := "default"
 | 
						namespace := "default"
 | 
				
			||||||
 | 
						annotationValue := "acid"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	annotationKey := "acid"
 | 
					 | 
				
			||||||
	pg := acidv1.Postgresql{
 | 
						pg := acidv1.Postgresql{
 | 
				
			||||||
		ObjectMeta: metav1.ObjectMeta{
 | 
							ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
			Name: clusterName,
 | 
								Name: clusterName,
 | 
				
			||||||
			Annotations: map[string]string{
 | 
								Annotations: map[string]string{
 | 
				
			||||||
				"owned-by": annotationKey,
 | 
									"owned-by": annotationValue,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		Spec: acidv1.PostgresSpec{
 | 
							Spec: acidv1.PostgresSpec{
 | 
				
			||||||
| 
						 | 
					@ -94,6 +95,15 @@ func TestInheritedAnnotations(t *testing.T) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// check pvc annotations
 | 
				
			||||||
 | 
						pvcList, err := cluster.KubeClient.PersistentVolumeClaims(namespace).List(context.TODO(), listOptions)
 | 
				
			||||||
 | 
						assert.NoError(t, err)
 | 
				
			||||||
 | 
						for _, pvc := range pvcList.Items {
 | 
				
			||||||
 | 
							if !(util.MapContains(pvc.ObjectMeta.Annotations, inheritedAnnotations)) {
 | 
				
			||||||
 | 
								t.Errorf("%s: PVC %v not inherited annotations %#v, got %#v", testName, pvc.ObjectMeta.Name, inheritedAnnotations, pvc.ObjectMeta.Annotations)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// check service annotations
 | 
						// check service annotations
 | 
				
			||||||
	svcList, err := cluster.KubeClient.Services(namespace).List(context.TODO(), listOptions)
 | 
						svcList, err := cluster.KubeClient.Services(namespace).List(context.TODO(), listOptions)
 | 
				
			||||||
	assert.NoError(t, err)
 | 
						assert.NoError(t, err)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue