minor changes
This commit is contained in:
parent
ec0d8f8aec
commit
f6212da046
|
|
@ -334,12 +334,15 @@ 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: c.annotationsSet(map[string]string{}),
|
||||
Annotations: annotations,
|
||||
// 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
|
||||
|
|
@ -868,7 +871,7 @@ func (c *Cluster) syncConnectionPoolerWorker(oldSpec, newSpec *acidv1.Postgresql
|
|||
|
||||
newAnnotations := c.annotationsSet(c.ConnectionPooler[role].Deployment.Annotations)
|
||||
newAnnotations = c.AnnotationsToPropagate(newAnnotations)
|
||||
if newAnnotations != nil {
|
||||
if newAnnotations != nil && len(newAnnotations) > 0 {
|
||||
deployment, err = updateConnectionPoolerAnnotations(c.KubeClient, c.ConnectionPooler[role].Deployment, newAnnotations)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -1226,7 +1226,7 @@ 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(map[string]string{})
|
||||
stsAnnotations := c.annotationsSet(nil)
|
||||
stsAnnotations = c.AnnotationsToPropagate(stsAnnotations)
|
||||
stsAnnotations[rollingUpdateStatefulsetAnnotationKey] = strconv.FormatBool(false)
|
||||
|
||||
|
|
@ -1531,7 +1531,7 @@ func (c *Cluster) generateSingleUserSecret(namespace string, pgUser spec.PgUser)
|
|||
Name: c.credentialSecretName(username),
|
||||
Namespace: namespace,
|
||||
Labels: c.labelsSet(true),
|
||||
Annotations: c.annotationsSet(map[string]string{}),
|
||||
Annotations: c.annotationsSet(nil),
|
||||
},
|
||||
Type: v1.SecretTypeOpaque,
|
||||
Data: map[string][]byte{
|
||||
|
|
@ -1652,10 +1652,9 @@ func (c *Cluster) generateServiceAnnotations(role PostgresRole, spec *acidv1.Pos
|
|||
func (c *Cluster) generateEndpoint(role PostgresRole, subsets []v1.EndpointSubset) *v1.Endpoints {
|
||||
endpoints := &v1.Endpoints{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: c.endpointName(role),
|
||||
Namespace: c.Namespace,
|
||||
Labels: c.roleLabelsSet(true, role),
|
||||
Annotations: c.annotationsSet(map[string]string{}),
|
||||
Name: c.endpointName(role),
|
||||
Namespace: c.Namespace,
|
||||
Labels: c.roleLabelsSet(true, role),
|
||||
},
|
||||
}
|
||||
if len(subsets) > 0 {
|
||||
|
|
@ -1812,7 +1811,7 @@ func (c *Cluster) generatePodDisruptionBudget() *policybeta1.PodDisruptionBudget
|
|||
Name: c.podDisruptionBudgetName(),
|
||||
Namespace: c.Namespace,
|
||||
Labels: c.labelsSet(true),
|
||||
Annotations: c.annotationsSet(map[string]string{}),
|
||||
Annotations: c.annotationsSet(nil),
|
||||
},
|
||||
Spec: policybeta1.PodDisruptionBudgetSpec{
|
||||
MinAvailable: &minAvailable,
|
||||
|
|
@ -1935,7 +1934,7 @@ func (c *Cluster) generateLogicalBackupJob() (*batchv1beta1.CronJob, error) {
|
|||
Name: c.getLogicalBackupJobName(),
|
||||
Namespace: c.Namespace,
|
||||
Labels: c.labelsSet(true),
|
||||
Annotations: c.annotationsSet(map[string]string{}),
|
||||
Annotations: c.annotationsSet(nil),
|
||||
},
|
||||
Spec: batchv1beta1.CronJobSpec{
|
||||
Schedule: schedule,
|
||||
|
|
|
|||
|
|
@ -403,11 +403,10 @@ func (c *Cluster) AnnotationsToPropagate(annotations map[string]string) map[stri
|
|||
annotations = make(map[string]string)
|
||||
}
|
||||
|
||||
toPropagateAnnotations := c.OpConfig.DownscalerAnnotations
|
||||
pgCRDAnnotations := c.Postgresql.ObjectMeta.GetAnnotations()
|
||||
pgCRDAnnotations := c.ObjectMeta.Annotations
|
||||
|
||||
if toPropagateAnnotations != nil && pgCRDAnnotations != nil {
|
||||
for _, anno := range toPropagateAnnotations {
|
||||
if pgCRDAnnotations != nil {
|
||||
for _, anno := range c.OpConfig.DownscalerAnnotations {
|
||||
for k, v := range pgCRDAnnotations {
|
||||
matched, err := regexp.MatchString(anno, k)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -277,17 +277,18 @@ func (c *Cluster) annotationsSet(annotations map[string]string) map[string]strin
|
|||
if annotations == nil {
|
||||
annotations = make(map[string]string)
|
||||
}
|
||||
|
||||
pgCRDAnnotations := c.ObjectMeta.Annotations
|
||||
|
||||
// allow to inherit certain labels from the 'postgres' object
|
||||
if spec, err := c.GetSpec(); err == nil {
|
||||
for k, v := range spec.ObjectMeta.Annotations {
|
||||
if pgCRDAnnotations != nil {
|
||||
for k, v := range pgCRDAnnotations {
|
||||
for _, match := range c.OpConfig.InheritedAnnotations {
|
||||
if k == match {
|
||||
annotations[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
c.logger.Warningf("could not get the list of InheritedAnnoations for cluster %q: %v", c.Name, err)
|
||||
}
|
||||
|
||||
if len(annotations) > 0 {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func TestInheritedAnnotations(t *testing.T) {
|
|||
cluster.Create()
|
||||
|
||||
// test annotationsSet function
|
||||
inheritedAnnotations := cluster.annotationsSet(map[string]string{})
|
||||
inheritedAnnotations := cluster.annotationsSet(nil)
|
||||
|
||||
listOptions := metav1.ListOptions{
|
||||
LabelSelector: cluster.labelsSet(false).String(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue