Skip to content

Commit f18bb6e

Browse files
committed
Make errors in the cluster list function visible.
Sometimes the operator does not pick up clusters right away when they are created. The change attempts to shed light on the reason behind that.
1 parent 65ef1da commit f18bb6e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/controller/postgresql.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ func (c *Controller) clusterResync(stopCh <-chan struct{}, wg *sync.WaitGroup) {
3030
for {
3131
select {
3232
case <-ticker.C:
33-
_, err := c.clusterListFunc(metav1.ListOptions{ResourceVersion: "0"})
34-
if err != nil {
33+
if _, err := c.clusterListFunc(metav1.ListOptions{ResourceVersion: "0"}); err != nil {
3534
c.logger.Errorf("could not list clusters: %v", err)
3635
}
3736
case <-stopCh:
@@ -52,9 +51,12 @@ func (c *Controller) clusterListFunc(options metav1.ListOptions) (runtime.Object
5251

5352
b, err := req.DoRaw()
5453
if err != nil {
54+
c.logger.Errorf("could not get the list of postgresql CRD objects: %v", err)
5555
return nil, err
5656
}
57-
err = json.Unmarshal(b, &list)
57+
if err = json.Unmarshal(b, &list); err != nil {
58+
c.logger.Warningf("could not unmarshal list of clusters: %v", err)
59+
}
5860

5961
if time.Now().Unix()-atomic.LoadInt64(&c.lastClusterSyncTime) <= int64(c.opConfig.ResyncPeriod.Seconds()) {
6062
return &list, err

0 commit comments

Comments
 (0)