From 451fe44ed437cc91e174637b37be7cedcdf4ef00 Mon Sep 17 00:00:00 2001
From: Felix Kunde <felix-kunde@gmx.de>
Date: Mon, 26 Aug 2019 18:07:22 +0200
Subject: [PATCH] fix source of problem and some typos

---
 pkg/cluster/cluster.go       | 4 +++-
 pkg/cluster/util.go          | 2 +-
 pkg/controller/postgresql.go | 8 --------
 pkg/util/k8sutil/k8sutil.go  | 2 +-
 4 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go
index e8eed15c..bf9542a4 100644
--- a/pkg/cluster/cluster.go
+++ b/pkg/cluster/cluster.go
@@ -164,11 +164,13 @@ func (c *Cluster) setStatus(status string) {
 	}
 
 	// we cannot do a full scale update here without fetching the previous manifest (as the resourceVersion may differ),
-	// however, we could do patch without it. In the future, once /status subresource is there (starting Kubernets 1.11)
+	// however, we could do patch without it. In the future, once /status subresource is there (starting Kubernetes 1.11)
 	// we should take advantage of it.
 	newspec, err := c.KubeClient.AcidV1ClientSet.AcidV1().Postgresqls(c.clusterNamespace()).Patch(c.Name, types.MergePatchType, patch, "status")
 	if err != nil {
 		c.logger.Errorf("could not update status: %v", err)
+		// return as newspec is empty, see PR654
+		return
 	}
 	// update the spec, maintaining the new resourceVersion.
 	c.setSpec(newspec)
diff --git a/pkg/cluster/util.go b/pkg/cluster/util.go
index 5b531cc9..e97cfdd1 100644
--- a/pkg/cluster/util.go
+++ b/pkg/cluster/util.go
@@ -365,7 +365,7 @@ func (c *Cluster) waitStatefulsetPodsReady() error {
 	c.setProcessName("waiting for the pods of the statefulset")
 	// TODO: wait for the first Pod only
 	if err := c.waitStatefulsetReady(); err != nil {
-		return fmt.Errorf("statuful set error: %v", err)
+		return fmt.Errorf("stateful set error: %v", err)
 	}
 
 	// TODO: wait only for master
diff --git a/pkg/controller/postgresql.go b/pkg/controller/postgresql.go
index 8e5303b2..dc082ffa 100644
--- a/pkg/controller/postgresql.go
+++ b/pkg/controller/postgresql.go
@@ -258,14 +258,6 @@ func (c *Controller) processEvent(event ClusterEvent) {
 		}
 		lg.Infoln("deletion of the cluster started")
 
-		// HACK if a delete happens too soon, cl fields are empty
-		// thus, pods, logical backup jobs and headless service will not get deleted
-		// see issues 551, 218
-		if cl.Name == "" {
-			cl.Name = clusterName.Name
-			cl.Namespace = clusterName.Namespace
-		}
-
 		teamName := strings.ToLower(cl.Spec.TeamID)
 
 		c.curWorkerCluster.Store(event.WorkerID, cl)
diff --git a/pkg/util/k8sutil/k8sutil.go b/pkg/util/k8sutil/k8sutil.go
index 66b51dd1..4f1edcb0 100644
--- a/pkg/util/k8sutil/k8sutil.go
+++ b/pkg/util/k8sutil/k8sutil.go
@@ -82,7 +82,7 @@ func ResourceNotFound(err error) bool {
 	return apierrors.IsNotFound(err)
 }
 
-// NewFromConfig create Kubernets Interface using REST config
+// NewFromConfig create Kubernetes Interface using REST config
 func NewFromConfig(cfg *rest.Config) (KubernetesClient, error) {
 	kubeClient := KubernetesClient{}
 
-- 
GitLab