Skip to content

Commit 8cdc982

Browse files
committed
Add observedGeneration field to status of postgresql resource
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
1 parent fffb532 commit 8cdc982

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

pkg/apis/acid.zalan.do/v1/postgresql_type.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ type UserFlags []string
301301
// PostgresStatus contains status of the PostgreSQL cluster (running, creation failed etc.)
302302
type PostgresStatus struct {
303303
PostgresClusterStatus string `json:"PostgresClusterStatus"`
304+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
304305
}
305306

306307
// ConnectionPooler Options for connection pooler

pkg/cluster/cluster.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ func (c *Cluster) Create() (err error) {
275275
currentStatus := c.Status.DeepCopy()
276276
pg := c.Postgresql.DeepCopy()
277277
pg.Status.PostgresClusterStatus = acidv1.ClusterStatusRunning
278+
pg.Status.ObservedGeneration = pgCreateStatus.Generation
278279

279280
if err != nil {
280281
c.logger.Warningf("cluster created failed: %v", err)
@@ -998,6 +999,7 @@ func (c *Cluster) Update(oldSpec, newSpec *acidv1.Postgresql) error {
998999
defer func() {
9991000
currentStatus := newSpec.Status.DeepCopy()
10001001
newSpec.Status.PostgresClusterStatus = acidv1.ClusterStatusRunning
1002+
newSpec.Status.ObservedGeneration = newSpec.Generation
10011003

10021004
if updateFailed {
10031005
newSpec.Status.PostgresClusterStatus = acidv1.ClusterStatusUpdateFailed

pkg/cluster/sync.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error {
4444
c.setSpec(newSpec)
4545

4646
defer func() {
47+
// update observedGeneration to reflect that the latest spec
48+
// was processed
49+
newSpec.Status.ObservedGeneration = newSpec.Generation
4750
if err != nil {
4851
c.logger.Warningf("error while syncing cluster state: %v", err)
4952
newSpec.Status.PostgresClusterStatus = acidv1.ClusterStatusSyncFailed

0 commit comments

Comments
 (0)