Improve the extra labels function.
This commit is contained in:
		
							parent
							
								
									d3531edd11
								
							
						
					
					
						commit
						5538d0ec71
					
				| 
						 | 
					@ -78,22 +78,22 @@ func needReplicaConnectionPoolerWorker(spec *acidv1.PostgresSpec) bool {
 | 
				
			||||||
// have e.g. different `application` label, so that recreatePod operation will
 | 
					// have e.g. different `application` label, so that recreatePod operation will
 | 
				
			||||||
// not interfere with it (it lists all the pods via labels, and if there would
 | 
					// not interfere with it (it lists all the pods via labels, and if there would
 | 
				
			||||||
// be no difference, it will recreate also pooler pods).
 | 
					// be no difference, it will recreate also pooler pods).
 | 
				
			||||||
func (c *Cluster) connectionPoolerLabels(role PostgresRole, spiloRole bool) *metav1.LabelSelector {
 | 
					func (c *Cluster) connectionPoolerLabels(role PostgresRole, addExtraLabels bool) *metav1.LabelSelector {
 | 
				
			||||||
	connectionPoolerLabels := c.labelsSet(false)
 | 
						poolerLabels := c.labelsSet(addExtraLabels)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	extraLabels := map[string]string{
 | 
						// TODO should be config values
 | 
				
			||||||
		"connection-pooler": c.connectionPoolerName(role),
 | 
						poolerLabels["application"] = "db-connection-pooler"
 | 
				
			||||||
		"application":       "db-connection-pooler",
 | 
						poolerLabels["connection-pooler"] = c.connectionPoolerName(role)
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if spiloRole {
 | 
						if addExtraLabels {
 | 
				
			||||||
 | 
							extraLabels := map[string]string{}
 | 
				
			||||||
		extraLabels["spilo-role"] = string(role)
 | 
							extraLabels["spilo-role"] = string(role)
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	connectionPoolerLabels = labels.Merge(connectionPoolerLabels, extraLabels)
 | 
							poolerLabels = labels.Merge(poolerLabels, extraLabels)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return &metav1.LabelSelector{
 | 
						return &metav1.LabelSelector{
 | 
				
			||||||
		MatchLabels:      connectionPoolerLabels,
 | 
							MatchLabels:      poolerLabels,
 | 
				
			||||||
		MatchExpressions: nil,
 | 
							MatchExpressions: nil,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue