@@ -254,10 +254,17 @@ func (c *Cluster) Create() (err error) {
254
254
)
255
255
256
256
defer func () {
257
+ var pgUpdatedStatus * acidv1.Postgresql
257
258
if err == nil {
258
- c .KubeClient .SetPostgresCRDStatus (c .clusterName (), acidv1 .ClusterStatusRunning ) //TODO: are you sure it's running?
259
+ pgUpdatedStatus , err = c .KubeClient .SetPostgresCRDStatus (c .clusterName (), acidv1 .ClusterStatusRunning ) //TODO: are you sure it's running?
259
260
} else {
260
- c .KubeClient .SetPostgresCRDStatus (c .clusterName (), acidv1 .ClusterStatusAddFailed )
261
+ pgUpdatedStatus , err = c .KubeClient .SetPostgresCRDStatus (c .clusterName (), acidv1 .ClusterStatusAddFailed )
262
+ }
263
+ if err != nil {
264
+ c .logger .Warningf ("could not set cluster status: %v" , err )
265
+ }
266
+ if pgUpdatedStatus != nil {
267
+ c .setSpec (pgUpdatedStatus )
261
268
}
262
269
}()
263
270
@@ -790,6 +797,7 @@ func (c *Cluster) addFinalizer() error {
790
797
791
798
// update the spec, maintaining the new resourceVersion
792
799
c .setSpec (newSpec )
800
+
793
801
return nil
794
802
}
795
803
@@ -838,10 +846,20 @@ func (c *Cluster) Update(oldSpec, newSpec *acidv1.Postgresql) error {
838
846
c .setSpec (newSpec )
839
847
840
848
defer func () {
849
+ var (
850
+ pgUpdatedStatus * acidv1.Postgresql
851
+ err error
852
+ )
841
853
if updateFailed {
842
- c .KubeClient .SetPostgresCRDStatus (c .clusterName (), acidv1 .ClusterStatusUpdateFailed )
854
+ pgUpdatedStatus , err = c .KubeClient .SetPostgresCRDStatus (c .clusterName (), acidv1 .ClusterStatusUpdateFailed )
843
855
} else {
844
- c .KubeClient .SetPostgresCRDStatus (c .clusterName (), acidv1 .ClusterStatusRunning )
856
+ pgUpdatedStatus , err = c .KubeClient .SetPostgresCRDStatus (c .clusterName (), acidv1 .ClusterStatusRunning )
857
+ }
858
+ if err != nil {
859
+ c .logger .Warningf ("could not set cluster status: %v" , err )
860
+ }
861
+ if pgUpdatedStatus != nil {
862
+ c .setSpec (pgUpdatedStatus )
845
863
}
846
864
}()
847
865
0 commit comments