Skip to content

K8SPG-730: add .status.observedGeneration for PerconaPGCluster #1199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18345,6 +18345,9 @@ spec:
items:
type: string
type: array
observedGeneration:
format: int64
type: integer
patroniVersion:
type: string
pgbouncer:
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/pgv2.percona.com_perconapgclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18752,6 +18752,9 @@ spec:
items:
type: string
type: array
observedGeneration:
format: int64
type: integer
patroniVersion:
type: string
pgbouncer:
Expand Down
3 changes: 3 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19049,6 +19049,9 @@ spec:
items:
type: string
type: array
observedGeneration:
format: int64
type: integer
patroniVersion:
type: string
pgbouncer:
Expand Down
3 changes: 3 additions & 0 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19049,6 +19049,9 @@ spec:
items:
type: string
type: array
observedGeneration:
format: int64
type: integer
patroniVersion:
type: string
pgbouncer:
Expand Down
3 changes: 3 additions & 0 deletions deploy/cw-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19049,6 +19049,9 @@ spec:
items:
type: string
type: array
observedGeneration:
format: int64
type: integer
patroniVersion:
type: string
pgbouncer:
Expand Down
2 changes: 2 additions & 0 deletions percona/controller/pgcluster/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ func (r *PGClusterReconciler) updateStatus(ctx context.Context, cr *v2.PerconaPG

cluster.Status.State = r.getState(cr, &cluster.Status, status)

cluster.Status.ObservedGeneration = cluster.Generation

updateConditions(cluster, status)

return r.Client.Status().Update(ctx, cluster)
Expand Down
6 changes: 6 additions & 0 deletions percona/controller/pgcluster/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ var _ = Describe("PG Cluster status", Ordered, func() {
Expect(cr.Status.Postgres.Ready).Should(Equal(int32(3)))
Expect(cr.Status.Postgres.Size).Should(Equal(int32(4)))
Expect(cr.Status.Postgres.InstanceSets).Should(HaveLen(2))
Expect(cr.Status.ObservedGeneration).Should(Equal(int64(1)))
Expect(cr.Status.Postgres.InstanceSets).Should(ContainElement(gs.MatchFields(gs.IgnoreExtras, gs.Fields{
"Name": Equal("instance1"),
"Ready": Equal(int32(0)),
Expand Down Expand Up @@ -138,6 +139,7 @@ var _ = Describe("PG Cluster status", Ordered, func() {
return err == nil
}, time.Second*15, time.Millisecond*250).Should(BeTrue())

Expect(cr.Status.ObservedGeneration).Should(Equal(int64(1)))
Expect(cr.Status.PGBouncer.Ready).Should(Equal(int32(0)))
Expect(cr.Status.PGBouncer.Size).Should(Equal(int32(1)))
})
Expand Down Expand Up @@ -294,6 +296,7 @@ var _ = Describe("PG Cluster status", Ordered, func() {
return err == nil
}, time.Second*15, time.Millisecond*250).Should(BeTrue())
Expect(cr.Status.Host).Should(Equal(pgBouncerSVC.Name + "." + ns + ".svc"))
Expect(cr.Status.ObservedGeneration).Should(Equal(int64(2)))
})
})

Expand Down Expand Up @@ -330,6 +333,8 @@ var _ = Describe("PG Cluster status", Ordered, func() {
return err == nil
}, time.Second*15, time.Millisecond*250).Should(BeTrue())
Expect(cr.Status.Host).Should(Equal("22.22.22.22"))

Expect(cr.Status.ObservedGeneration).Should(Equal(int64(3)))
})
})
})
Expand Down Expand Up @@ -393,6 +398,7 @@ var _ = Describe("PG Cluster status", Ordered, func() {

condition := meta.FindStatusCondition(cr.Status.Conditions, pNaming.ConditionClusterIsReadyForBackup)
Expect(condition.Status).Should(Equal(metav1.ConditionFalse))
Expect(cr.Status.ObservedGeneration).Should(Equal(int64(1)))
})
})

Expand Down
7 changes: 6 additions & 1 deletion pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ type PerconaPGClusterStatus struct {
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=status
Conditions []metav1.Condition `json:"conditions,omitempty"`

// +optional
// +operator-sdk:csv:customresourcedefinitions:type=status
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

type Backups struct {
Expand Down Expand Up @@ -823,7 +827,8 @@ func (p PGInstanceSetSpec) ToCrunchy() crunchyv1beta1.PostgresInstanceSetSpec {
VolumeMounts: p.VolumeMounts,
SecurityContext: p.SecurityContext,
TablespaceVolumes: p.TablespaceVolumes,
InitContainer: p.InitContainer}
InitContainer: p.InitContainer,
}
}

type ServiceExpose struct {
Expand Down
Loading