From dd2381174c7000f3ac29df96d16555b11599ff16 Mon Sep 17 00:00:00 2001 From: Rafia Sabih Date: Mon, 27 Apr 2020 17:07:35 +0200 Subject: [PATCH] Corrections - set the type of the new configuration parameter to be array of strings - propagate the annotations to statefulset at sync --- pkg/apis/acid.zalan.do/v1/crds.go | 4 ++-- pkg/cluster/k8sres.go | 13 ------------- pkg/cluster/sync.go | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/pkg/apis/acid.zalan.do/v1/crds.go b/pkg/apis/acid.zalan.do/v1/crds.go index 272dae900..090b83821 100644 --- a/pkg/apis/acid.zalan.do/v1/crds.go +++ b/pkg/apis/acid.zalan.do/v1/crds.go @@ -838,8 +838,8 @@ var OperatorConfigCRDResourceValidation = apiextv1beta1.CustomResourceValidation }, }, "statefulset_propagate_annotations": { - Type: "object", - AdditionalProperties: &apiextv1beta1.JSONSchemaPropsOrBool{ + Type: "array", + Items: &apiextv1beta1.JSONSchemaPropsOrArray{ Schema: &apiextv1beta1.JSONSchemaProps{ Type: "string", }, diff --git a/pkg/cluster/k8sres.go b/pkg/cluster/k8sres.go index 0440098bd..914ebb8ad 100644 --- a/pkg/cluster/k8sres.go +++ b/pkg/cluster/k8sres.go @@ -1150,18 +1150,6 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef annotations = make(map[string]string) - ToPropagateAnnotations := c.OpConfig.StatefulsetPropAnnotations - if ToPropagateAnnotations != nil { - PgCRDAnnotations := c.Postgresql.ObjectMeta.GetAnnotations() - for _, anno := range ToPropagateAnnotations { - for k, v := range PgCRDAnnotations { - if k == anno { - annotations[k] = v - } - } - } - } - statefulSet := &appsv1.StatefulSet{ ObjectMeta: metav1.ObjectMeta{ Name: c.statefulSetName(), @@ -1545,7 +1533,6 @@ func (c *Cluster) generateService(role PostgresRole, spec *acidv1.PostgresSpec) }, Spec: serviceSpec, } - c.logger.Warningln("Rafia get service annotations", service.GetObjectMeta) return service } diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index 43173102b..7209fa86d 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -330,6 +330,20 @@ func (c *Cluster) syncStatefulSet() error { } } } + ToPropagateAnnotations := c.OpConfig.StatefulsetPropAnnotations + PgCRDAnnotations := c.Postgresql.ObjectMeta.GetAnnotations() + annotations := make(map[string]string) + + if ToPropagateAnnotations != nil && PgCRDAnnotations != nil { + for _, anno := range ToPropagateAnnotations { + for k, v := range PgCRDAnnotations { + if k == anno { + annotations[k] = v + } + } + } + c.updateStatefulSetAnnotations(annotations) + } } // Apply special PostgreSQL parameters that can only be set via the Patroni API.