diff --git a/docs/reference/operator_parameters.md b/docs/reference/operator_parameters.md index 9d4e5fc58..a812c5d9f 100644 --- a/docs/reference/operator_parameters.md +++ b/docs/reference/operator_parameters.md @@ -273,9 +273,9 @@ configuration they are grouped under the `kubernetes` key. * **inherited_annotations** list of annotation keys that can be inherited from the cluster manifest, and - added to each child objects (`Deployment`, `StatefulSet`, `Pod`, `PVCs`, - `PDB`, `Service`, `Endpoints` and `Secrets`) created by the operator. - The default is empty. + added to each child objects (`Deployment`, `StatefulSet`, `Pod`, `PDB` and + `Services`) created by the operator incl. the ones from the connection + pooler deployment. The default is empty. * **pod_role_label** name of the label assigned to the Postgres pods (and services/endpoints) by diff --git a/pkg/cluster/connection_pooler.go b/pkg/cluster/connection_pooler.go index 53c036287..d36aff7f1 100644 --- a/pkg/cluster/connection_pooler.go +++ b/pkg/cluster/connection_pooler.go @@ -334,15 +334,12 @@ func (c *Cluster) generateConnectionPoolerDeployment(connectionPooler *Connectio return nil, err } - annotations := c.annotationsSet(nil) - annotations = c.AnnotationsToPropagate(annotations) - deployment := &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: connectionPooler.Name, Namespace: connectionPooler.Namespace, Labels: c.connectionPoolerLabels(connectionPooler.Role, true).MatchLabels, - Annotations: annotations, + Annotations: c.AnnotationsToPropagate(c.annotationsSet(nil)), // make StatefulSet object its owner to represent the dependency. // By itself StatefulSet is being deleted with "Orphaned" // propagation policy, which means that it's deletion will not @@ -869,8 +866,7 @@ func (c *Cluster) syncConnectionPoolerWorker(oldSpec, newSpec *acidv1.Postgresql } } - newAnnotations := c.annotationsSet(c.ConnectionPooler[role].Deployment.Annotations) - newAnnotations = c.AnnotationsToPropagate(newAnnotations) + newAnnotations := c.AnnotationsToPropagate(c.annotationsSet(c.ConnectionPooler[role].Deployment.Annotations)) if newAnnotations != nil && len(newAnnotations) > 0 { deployment, err = updateConnectionPoolerAnnotations(c.KubeClient, c.ConnectionPooler[role].Deployment, newAnnotations) if err != nil { diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index b5b842053..a585649db 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -1226,9 +1226,9 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef return nil, fmt.Errorf("could not set the pod management policy to the unknown value: %v", c.OpConfig.PodManagementPolicy) } - stsAnnotations := c.annotationsSet(nil) - stsAnnotations = c.AnnotationsToPropagate(stsAnnotations) + stsAnnotations := make(map[string]string) stsAnnotations[rollingUpdateStatefulsetAnnotationKey] = strconv.FormatBool(false) + stsAnnotations = c.AnnotationsToPropagate(c.annotationsSet(nil)) statefulSet := &appsv1.StatefulSet{ ObjectMeta: metav1.ObjectMeta{ diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index 997d6db19..211903689 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -353,9 +353,8 @@ func (c *Cluster) syncStatefulSet() error { } } } - annotations := c.annotationsSet(c.Statefulset.Annotations) - annotations = c.AnnotationsToPropagate(annotations) - c.updateStatefulSetAnnotations(annotations) + + c.updateStatefulSetAnnotations(c.AnnotationsToPropagate(c.annotationsSet(c.Statefulset.Annotations))) if !podsRollingUpdateRequired && !c.OpConfig.EnableLazySpiloUpgrade { // even if desired and actual statefulsets match @@ -420,7 +419,11 @@ func (c *Cluster) AnnotationsToPropagate(annotations map[string]string) map[stri } } - return annotations + if len(annotations) > 0 { + return annotations + } + + return nil } // checkAndSetGlobalPostgreSQLConfiguration checks whether cluster-wide API parameters