add pvc to test + minor changes

This commit is contained in:
Felix Kunde 2020-12-07 18:34:00 +01:00
parent 1ac2decdea
commit ce8a0d6f5b
3 changed files with 24 additions and 12 deletions

View File

@ -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 {
deployment, err = updateConnectionPoolerAnnotations(c.KubeClient, c.ConnectionPooler[role].Deployment, newAnnotations)
if err != nil {

View File

@ -353,8 +353,9 @@ func (c *Cluster) syncStatefulSet() error {
}
}
}
annotations := c.AnnotationsToPropagate(c.Statefulset.Annotations)
c.updateStatefulSetAnnotations(c.annotationsSet(annotations))
annotations := c.annotationsSet(c.Statefulset.Annotations)
annotations = c.AnnotationsToPropagate(annotations)
c.updateStatefulSetAnnotations(annotations)
if !podsRollingUpdateRequired && !c.OpConfig.EnableLazySpiloUpgrade {
// even if desired and actual statefulsets match

View File

@ -17,13 +17,14 @@ func newFakeK8sAnnotationsClient() (k8sutil.KubernetesClient, *fake.Clientset) {
clientSet := fake.NewSimpleClientset()
return k8sutil.KubernetesClient{
DeploymentsGetter: clientSet.AppsV1(),
EndpointsGetter: clientSet.CoreV1(),
PodsGetter: clientSet.CoreV1(),
PodDisruptionBudgetsGetter: clientSet.PolicyV1beta1(),
SecretsGetter: clientSet.CoreV1(),
ServicesGetter: clientSet.CoreV1(),
StatefulSetsGetter: clientSet.AppsV1(),
DeploymentsGetter: clientSet.AppsV1(),
EndpointsGetter: clientSet.CoreV1(),
PersistentVolumeClaimsGetter: clientSet.CoreV1(),
PodsGetter: clientSet.CoreV1(),
PodDisruptionBudgetsGetter: clientSet.PolicyV1beta1(),
SecretsGetter: clientSet.CoreV1(),
ServicesGetter: clientSet.CoreV1(),
StatefulSetsGetter: clientSet.AppsV1(),
}, clientSet
}
@ -32,13 +33,13 @@ func TestInheritedAnnotations(t *testing.T) {
client, _ := newFakeK8sAnnotationsClient()
clusterName := "acid-test-cluster"
namespace := "default"
annotationValue := "acid"
annotationKey := "acid"
pg := acidv1.Postgresql{
ObjectMeta: metav1.ObjectMeta{
Name: clusterName,
Annotations: map[string]string{
"owned-by": annotationKey,
"owned-by": annotationValue,
},
},
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
svcList, err := cluster.KubeClient.Services(namespace).List(context.TODO(), listOptions)
assert.NoError(t, err)