minor changes
This commit is contained in:
		
							parent
							
								
									ec0d8f8aec
								
							
						
					
					
						commit
						f6212da046
					
				| 
						 | 
					@ -334,12 +334,15 @@ func (c *Cluster) generateConnectionPoolerDeployment(connectionPooler *Connectio
 | 
				
			||||||
		return nil, err
 | 
							return nil, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						annotations := c.annotationsSet(nil)
 | 
				
			||||||
 | 
						annotations = c.AnnotationsToPropagate(annotations)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	deployment := &appsv1.Deployment{
 | 
						deployment := &appsv1.Deployment{
 | 
				
			||||||
		ObjectMeta: metav1.ObjectMeta{
 | 
							ObjectMeta: metav1.ObjectMeta{
 | 
				
			||||||
			Name:        connectionPooler.Name,
 | 
								Name:        connectionPooler.Name,
 | 
				
			||||||
			Namespace:   connectionPooler.Namespace,
 | 
								Namespace:   connectionPooler.Namespace,
 | 
				
			||||||
			Labels:      c.connectionPoolerLabels(connectionPooler.Role, true).MatchLabels,
 | 
								Labels:      c.connectionPoolerLabels(connectionPooler.Role, true).MatchLabels,
 | 
				
			||||||
			Annotations: c.annotationsSet(map[string]string{}),
 | 
								Annotations: annotations,
 | 
				
			||||||
			// make StatefulSet object its owner to represent the dependency.
 | 
								// make StatefulSet object its owner to represent the dependency.
 | 
				
			||||||
			// By itself StatefulSet is being deleted with "Orphaned"
 | 
								// By itself StatefulSet is being deleted with "Orphaned"
 | 
				
			||||||
			// propagation policy, which means that it's deletion will not
 | 
								// 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.annotationsSet(c.ConnectionPooler[role].Deployment.Annotations)
 | 
				
			||||||
	newAnnotations = c.AnnotationsToPropagate(newAnnotations)
 | 
						newAnnotations = c.AnnotationsToPropagate(newAnnotations)
 | 
				
			||||||
	if newAnnotations != nil {
 | 
						if newAnnotations != nil && len(newAnnotations) > 0 {
 | 
				
			||||||
		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 {
 | 
				
			||||||
			return nil, err
 | 
								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)
 | 
							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 = c.AnnotationsToPropagate(stsAnnotations)
 | 
				
			||||||
	stsAnnotations[rollingUpdateStatefulsetAnnotationKey] = strconv.FormatBool(false)
 | 
						stsAnnotations[rollingUpdateStatefulsetAnnotationKey] = strconv.FormatBool(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1531,7 +1531,7 @@ func (c *Cluster) generateSingleUserSecret(namespace string, pgUser spec.PgUser)
 | 
				
			||||||
			Name:        c.credentialSecretName(username),
 | 
								Name:        c.credentialSecretName(username),
 | 
				
			||||||
			Namespace:   namespace,
 | 
								Namespace:   namespace,
 | 
				
			||||||
			Labels:      c.labelsSet(true),
 | 
								Labels:      c.labelsSet(true),
 | 
				
			||||||
			Annotations: c.annotationsSet(map[string]string{}),
 | 
								Annotations: c.annotationsSet(nil),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		Type: v1.SecretTypeOpaque,
 | 
							Type: v1.SecretTypeOpaque,
 | 
				
			||||||
		Data: map[string][]byte{
 | 
							Data: map[string][]byte{
 | 
				
			||||||
| 
						 | 
					@ -1655,7 +1655,6 @@ func (c *Cluster) generateEndpoint(role PostgresRole, subsets []v1.EndpointSubse
 | 
				
			||||||
			Name:      c.endpointName(role),
 | 
								Name:      c.endpointName(role),
 | 
				
			||||||
			Namespace: c.Namespace,
 | 
								Namespace: c.Namespace,
 | 
				
			||||||
			Labels:    c.roleLabelsSet(true, role),
 | 
								Labels:    c.roleLabelsSet(true, role),
 | 
				
			||||||
			Annotations: c.annotationsSet(map[string]string{}),
 | 
					 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(subsets) > 0 {
 | 
						if len(subsets) > 0 {
 | 
				
			||||||
| 
						 | 
					@ -1812,7 +1811,7 @@ func (c *Cluster) generatePodDisruptionBudget() *policybeta1.PodDisruptionBudget
 | 
				
			||||||
			Name:        c.podDisruptionBudgetName(),
 | 
								Name:        c.podDisruptionBudgetName(),
 | 
				
			||||||
			Namespace:   c.Namespace,
 | 
								Namespace:   c.Namespace,
 | 
				
			||||||
			Labels:      c.labelsSet(true),
 | 
								Labels:      c.labelsSet(true),
 | 
				
			||||||
			Annotations: c.annotationsSet(map[string]string{}),
 | 
								Annotations: c.annotationsSet(nil),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		Spec: policybeta1.PodDisruptionBudgetSpec{
 | 
							Spec: policybeta1.PodDisruptionBudgetSpec{
 | 
				
			||||||
			MinAvailable: &minAvailable,
 | 
								MinAvailable: &minAvailable,
 | 
				
			||||||
| 
						 | 
					@ -1935,7 +1934,7 @@ func (c *Cluster) generateLogicalBackupJob() (*batchv1beta1.CronJob, error) {
 | 
				
			||||||
			Name:        c.getLogicalBackupJobName(),
 | 
								Name:        c.getLogicalBackupJobName(),
 | 
				
			||||||
			Namespace:   c.Namespace,
 | 
								Namespace:   c.Namespace,
 | 
				
			||||||
			Labels:      c.labelsSet(true),
 | 
								Labels:      c.labelsSet(true),
 | 
				
			||||||
			Annotations: c.annotationsSet(map[string]string{}),
 | 
								Annotations: c.annotationsSet(nil),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		Spec: batchv1beta1.CronJobSpec{
 | 
							Spec: batchv1beta1.CronJobSpec{
 | 
				
			||||||
			Schedule:          schedule,
 | 
								Schedule:          schedule,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -403,11 +403,10 @@ func (c *Cluster) AnnotationsToPropagate(annotations map[string]string) map[stri
 | 
				
			||||||
		annotations = make(map[string]string)
 | 
							annotations = make(map[string]string)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	toPropagateAnnotations := c.OpConfig.DownscalerAnnotations
 | 
						pgCRDAnnotations := c.ObjectMeta.Annotations
 | 
				
			||||||
	pgCRDAnnotations := c.Postgresql.ObjectMeta.GetAnnotations()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if toPropagateAnnotations != nil && pgCRDAnnotations != nil {
 | 
						if pgCRDAnnotations != nil {
 | 
				
			||||||
		for _, anno := range toPropagateAnnotations {
 | 
							for _, anno := range c.OpConfig.DownscalerAnnotations {
 | 
				
			||||||
			for k, v := range pgCRDAnnotations {
 | 
								for k, v := range pgCRDAnnotations {
 | 
				
			||||||
				matched, err := regexp.MatchString(anno, k)
 | 
									matched, err := regexp.MatchString(anno, k)
 | 
				
			||||||
				if err != nil {
 | 
									if err != nil {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -277,17 +277,18 @@ func (c *Cluster) annotationsSet(annotations map[string]string) map[string]strin
 | 
				
			||||||
	if annotations == nil {
 | 
						if annotations == nil {
 | 
				
			||||||
		annotations = make(map[string]string)
 | 
							annotations = make(map[string]string)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pgCRDAnnotations := c.ObjectMeta.Annotations
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// allow to inherit certain labels from the 'postgres' object
 | 
						// allow to inherit certain labels from the 'postgres' object
 | 
				
			||||||
	if spec, err := c.GetSpec(); err == nil {
 | 
						if pgCRDAnnotations != nil {
 | 
				
			||||||
		for k, v := range spec.ObjectMeta.Annotations {
 | 
							for k, v := range pgCRDAnnotations {
 | 
				
			||||||
			for _, match := range c.OpConfig.InheritedAnnotations {
 | 
								for _, match := range c.OpConfig.InheritedAnnotations {
 | 
				
			||||||
				if k == match {
 | 
									if k == match {
 | 
				
			||||||
					annotations[k] = v
 | 
										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 {
 | 
						if len(annotations) > 0 {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -67,7 +67,7 @@ func TestInheritedAnnotations(t *testing.T) {
 | 
				
			||||||
	cluster.Create()
 | 
						cluster.Create()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// test annotationsSet function
 | 
						// test annotationsSet function
 | 
				
			||||||
	inheritedAnnotations := cluster.annotationsSet(map[string]string{})
 | 
						inheritedAnnotations := cluster.annotationsSet(nil)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	listOptions := metav1.ListOptions{
 | 
						listOptions := metav1.ListOptions{
 | 
				
			||||||
		LabelSelector: cluster.labelsSet(false).String(),
 | 
							LabelSelector: cluster.labelsSet(false).String(),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue