Skip to content

Commit 945f72e

Browse files
authored
Allow for startup to proceed even if status subresource is missing
We have a guard to only allow a cluster to be started up if we know that it is in a shut down state. However, there appears to be cases independentof the Operator where the pgclusters.crunchydata.com "status" subresource is missing, which would cause that guard to be too aggressive. This change allows for the condition that there is no state registered in the status subresource, which allows for the start up to proceed regardless. Issue: [ch10811]
1 parent 5e2a551 commit 945f72e

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

internal/controller/pgcluster/pgclustercontroller.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,21 @@ func (c *Controller) onUpdate(oldObj, newObj interface{}) {
191191
// if the 'shutdown' parameter in the pgcluster update shows that the cluster should be either
192192
// shutdown or started but its current status does not properly reflect that it is, then
193193
// proceed with the logic needed to either shutdown or start the cluster
194+
//
195+
// we do need to check if the status has info in it. There have been cases
196+
// where the entire status has been removed that could be external to the
197+
// operator itself. In the case of checking that the state is in a shutdown
198+
// phase, we also want to check if the status is completely empty. If it is,
199+
// we will proceed with the shutdown.
194200
if newcluster.Spec.Shutdown && newcluster.Status.State != crv1.PgclusterStateShutdown {
195-
_ = clusteroperator.ShutdownCluster(c.Client, *newcluster)
201+
if err := clusteroperator.ShutdownCluster(c.Client, *newcluster); err != nil {
202+
log.Error(err)
203+
}
196204
} else if !newcluster.Spec.Shutdown &&
197-
newcluster.Status.State == crv1.PgclusterStateShutdown {
198-
_ = clusteroperator.StartupCluster(c.Client, *newcluster)
205+
(newcluster.Status.State == crv1.PgclusterStateShutdown || newcluster.Status.State == "") {
206+
if err := clusteroperator.StartupCluster(c.Client, *newcluster); err != nil {
207+
log.Error(err)
208+
}
199209
}
200210

201211
// check to see if autofail setting has been changed. If set to "true", it

0 commit comments

Comments
 (0)