|
43 | 43 | alphaNumericRegexp = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9]*$") |
44 | 44 | databaseNameRegexp = regexp.MustCompile("^[a-zA-Z_][a-zA-Z0-9_]*$") |
45 | 45 | userRegexp = regexp.MustCompile(`^[a-z0-9]([-_a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-_a-z0-9]*[a-z0-9])?)*$`) |
46 | | - patroniObjectSuffixes = []string{"config", "failover", "sync"} |
| 46 | + patroniObjectSuffixes = []string{"config", "failover", "sync", "leader"} |
47 | 47 | ) |
48 | 48 |
|
49 | 49 | // Config contains operator-wide clients and configuration used from a cluster. TODO: remove struct duplication. |
@@ -258,18 +258,20 @@ func (c *Cluster) Create() error { |
258 | 258 |
|
259 | 259 | for _, role := range []PostgresRole{Master, Replica} { |
260 | 260 |
|
261 | | - if c.Endpoints[role] != nil { |
262 | | - return fmt.Errorf("%s endpoint already exists in the cluster", role) |
263 | | - } |
264 | | - if role == Master { |
265 | | - // replica endpoint will be created by the replica service. Master endpoint needs to be created by us, |
266 | | - // since the corresponding master service does not define any selectors. |
267 | | - ep, err = c.createEndpoint(role) |
268 | | - if err != nil { |
269 | | - return fmt.Errorf("could not create %s endpoint: %v", role, err) |
| 261 | + if !c.patroniKubernetesUseConfigMaps() { |
| 262 | + if c.Endpoints[role] != nil { |
| 263 | + return fmt.Errorf("%s endpoint already exists in the cluster", role) |
| 264 | + } |
| 265 | + if role == Master { |
| 266 | + // replica endpoint will be created by the replica service. Master endpoint needs to be created by us, |
| 267 | + // since the corresponding master service does not define any selectors. |
| 268 | + ep, err = c.createEndpoint(role) |
| 269 | + if err != nil { |
| 270 | + return fmt.Errorf("could not create %s endpoint: %v", role, err) |
| 271 | + } |
| 272 | + c.logger.Infof("endpoint %q has been successfully created", util.NameFromMeta(ep.ObjectMeta)) |
| 273 | + c.eventRecorder.Eventf(c.GetReference(), v1.EventTypeNormal, "Endpoints", "Endpoint %q has been successfully created", util.NameFromMeta(ep.ObjectMeta)) |
270 | 274 | } |
271 | | - c.logger.Infof("endpoint %q has been successfully created", util.NameFromMeta(ep.ObjectMeta)) |
272 | | - c.eventRecorder.Eventf(c.GetReference(), v1.EventTypeNormal, "Endpoints", "Endpoint %q has been successfully created", util.NameFromMeta(ep.ObjectMeta)) |
273 | 275 | } |
274 | 276 |
|
275 | 277 | if c.Services[role] != nil { |
@@ -1576,8 +1578,9 @@ func (c *Cluster) deletePatroniClusterObjects() error { |
1576 | 1578 |
|
1577 | 1579 | if !c.patroniKubernetesUseConfigMaps() { |
1578 | 1580 | actionsList = append(actionsList, c.deletePatroniClusterEndpoints) |
| 1581 | + } else { |
| 1582 | + actionsList = append(actionsList, c.deletePatroniClusterServices, c.deletePatroniClusterConfigMaps) |
1579 | 1583 | } |
1580 | | - actionsList = append(actionsList, c.deletePatroniClusterServices, c.deletePatroniClusterConfigMaps) |
1581 | 1584 |
|
1582 | 1585 | c.logger.Debugf("removing leftover Patroni objects (endpoints / services and configmaps)") |
1583 | 1586 | for _, deleter := range actionsList { |
|
0 commit comments