Merge pull request #295 from zalando-incubator/continue_on_delete_errors

Avoid terminating delete on errors.
This commit is contained in:
zerg-junior 2018-05-22 10:44:43 +02:00 committed by GitHub
commit e6d12b3480
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 13 deletions

View File

@ -628,44 +628,42 @@ func (c *Cluster) Update(oldSpec, newSpec *spec.Postgresql) error {
// DCS, reuses the master's endpoint to store the leader related metadata. If we remove the endpoint
// before the pods, it will be re-created by the current master pod and will remain, obstructing the
// creation of the new cluster with the same name. Therefore, the endpoints should be deleted last.
func (c *Cluster) Delete() error {
func (c *Cluster) Delete() {
c.mu.Lock()
defer c.mu.Unlock()
if err := c.deleteStatefulSet(); err != nil {
return fmt.Errorf("could not delete statefulset: %v", err)
c.logger.Warningf("could not delete statefulset: %v", err)
}
for _, obj := range c.Secrets {
if delete, user := c.shouldDeleteSecret(obj); !delete {
c.logger.Infof("not removing secret %q for the system user %q", obj.GetName(), user)
c.logger.Warningf("not removing secret %q for the system user %q", obj.GetName(), user)
continue
}
if err := c.deleteSecret(obj); err != nil {
return fmt.Errorf("could not delete secret: %v", err)
c.logger.Warningf("could not delete secret: %v", err)
}
}
if err := c.deletePodDisruptionBudget(); err != nil {
return fmt.Errorf("could not delete pod disruption budget: %v", err)
c.logger.Warningf("could not delete pod disruption budget: %v", err)
}
for _, role := range []PostgresRole{Master, Replica} {
if err := c.deleteEndpoint(role); err != nil {
return fmt.Errorf("could not delete %s endpoint: %v", role, err)
c.logger.Warningf("could not delete %s endpoint: %v", role, err)
}
if err := c.deleteService(role); err != nil {
return fmt.Errorf("could not delete %s service: %v", role, err)
c.logger.Warningf("could not delete %s service: %v", role, err)
}
}
if err := c.deletePatroniClusterObjects(); err != nil {
return fmt.Errorf("could not remove leftover patroni objects; %v", err)
c.logger.Warningf("could not remove leftover patroni objects; %v", err)
}
return nil
}
// ReceivePodEvent is called back by the controller in order to add the cluster's pod event to the queue.

View File

@ -230,9 +230,7 @@ func (c *Controller) processEvent(event spec.ClusterEvent) {
teamName := strings.ToLower(cl.Spec.TeamID)
c.curWorkerCluster.Store(event.WorkerID, cl)
if err := cl.Delete(); err != nil {
lg.Errorf("could not delete cluster: %v", err)
}
cl.Delete()
func() {
defer c.clustersMu.Unlock()