do not create endpoints when use config maps (#1760)
* do not create endpoints when use config maps * delete cluster objects with 'leader' suffix Co-authored-by: Евграфов Александр Александрович <aevgrafov@cmx.ru>
This commit is contained in:
		
							parent
							
								
									7e92fa6cb0
								
							
						
					
					
						commit
						30f2ba6525
					
				|  | @ -43,7 +43,7 @@ var ( | |||
| 	alphaNumericRegexp    = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9]*$") | ||||
| 	databaseNameRegexp    = regexp.MustCompile("^[a-zA-Z_][a-zA-Z0-9_]*$") | ||||
| 	userRegexp            = regexp.MustCompile(`^[a-z0-9]([-_a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-_a-z0-9]*[a-z0-9])?)*$`) | ||||
| 	patroniObjectSuffixes = []string{"config", "failover", "sync"} | ||||
| 	patroniObjectSuffixes = []string{"config", "failover", "sync", "leader"} | ||||
| ) | ||||
| 
 | ||||
| // Config contains operator-wide clients and configuration used from a cluster. TODO: remove struct duplication.
 | ||||
|  | @ -258,6 +258,7 @@ func (c *Cluster) Create() error { | |||
| 
 | ||||
| 	for _, role := range []PostgresRole{Master, Replica} { | ||||
| 
 | ||||
| 		if !c.patroniKubernetesUseConfigMaps() { | ||||
| 			if c.Endpoints[role] != nil { | ||||
| 				return fmt.Errorf("%s endpoint already exists in the cluster", role) | ||||
| 			} | ||||
|  | @ -271,6 +272,7 @@ func (c *Cluster) Create() error { | |||
| 				c.logger.Infof("endpoint %q has been successfully created", util.NameFromMeta(ep.ObjectMeta)) | ||||
| 				c.eventRecorder.Eventf(c.GetReference(), v1.EventTypeNormal, "Endpoints", "Endpoint %q has been successfully created", util.NameFromMeta(ep.ObjectMeta)) | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		if c.Services[role] != nil { | ||||
| 			return fmt.Errorf("service already exists in the cluster") | ||||
|  | @ -1576,8 +1578,9 @@ func (c *Cluster) deletePatroniClusterObjects() error { | |||
| 
 | ||||
| 	if !c.patroniKubernetesUseConfigMaps() { | ||||
| 		actionsList = append(actionsList, c.deletePatroniClusterEndpoints) | ||||
| 	} | ||||
| 	} else { | ||||
| 		actionsList = append(actionsList, c.deletePatroniClusterServices, c.deletePatroniClusterConfigMaps) | ||||
| 	} | ||||
| 
 | ||||
| 	c.logger.Debugf("removing leftover Patroni objects (endpoints / services and configmaps)") | ||||
| 	for _, deleter := range actionsList { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue