Skip to content

Commit 4a863d2

Browse files
FxKusdudoladov
authored andcommitted
Avoid orphaned objects on delete (#654)
* Make setSpec function work correctly when updating cluster status fails
1 parent fd6a245 commit 4a863d2

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

pkg/cluster/cluster.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ func (c *Cluster) setStatus(status string) {
164164
}
165165

166166
// we cannot do a full scale update here without fetching the previous manifest (as the resourceVersion may differ),
167-
// however, we could do patch without it. In the future, once /status subresource is there (starting Kubernets 1.11)
167+
// however, we could do patch without it. In the future, once /status subresource is there (starting Kubernetes 1.11)
168168
// we should take advantage of it.
169169
newspec, err := c.KubeClient.AcidV1ClientSet.AcidV1().Postgresqls(c.clusterNamespace()).Patch(c.Name, types.MergePatchType, patch, "status")
170170
if err != nil {
171171
c.logger.Errorf("could not update status: %v", err)
172+
// return as newspec is empty, see PR654
173+
return
172174
}
173175
// update the spec, maintaining the new resourceVersion.
174176
c.setSpec(newspec)

pkg/cluster/util.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func (c *Cluster) waitStatefulsetPodsReady() error {
365365
c.setProcessName("waiting for the pods of the statefulset")
366366
// TODO: wait for the first Pod only
367367
if err := c.waitStatefulsetReady(); err != nil {
368-
return fmt.Errorf("statuful set error: %v", err)
368+
return fmt.Errorf("stateful set error: %v", err)
369369
}
370370

371371
// TODO: wait only for master

pkg/util/k8sutil/k8sutil.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func ResourceNotFound(err error) bool {
8282
return apierrors.IsNotFound(err)
8383
}
8484

85-
// NewFromConfig create Kubernets Interface using REST config
85+
// NewFromConfig create Kubernetes Interface using REST config
8686
func NewFromConfig(cfg *rest.Config) (KubernetesClient, error) {
8787
kubeClient := KubernetesClient{}
8888

0 commit comments

Comments
 (0)