Skip to content

Improving Postgres CR Status with Additional Details#2714

Closed
RavinaChidambaram wants to merge 6 commits into
zalando:masterfrom
RavinaChidambaram:status-changes
Closed

Improving Postgres CR Status with Additional Details#2714
RavinaChidambaram wants to merge 6 commits into
zalando:masterfrom
RavinaChidambaram:status-changes

Conversation

@RavinaChidambaram

Copy link
Copy Markdown

Fixes #2669

Following things have been added:

  • Added observedGeneration
  • Added conditions of type ReconciliationSuccessful and Ready
  • Added numberOfInstances and labelSelector for scale subresource
  • Added scale subresource configuration in the CRD
  • postgresClusterStatus is still part of the CRD

Detailed example flow:
Conditions are updated everytime there is a change in PostgresClusterStatus. And if the cluster is running successfully, the status looks like:

status:
  conditions:
  - lastTransitionTime: "2024-08-02T12:33:34Z"
    status: "True"
    type: ReconciliationSuccessful
  - lastTransitionTime: "2024-08-02T12:33:34Z"
    status: "True"
    type: Ready
  labelSelector: cluster-name=acid-minimal-cluster
  numberOfInstances: 3
  observedGeneration: 4
  postgresClusterStatus: Running

If there is a transition from Running state to a failed state, type ReconciliationSuccessful will be false.
When a failed case (Create failed,Update failed, Sync failed) is encountered, the error message will be printed in the message in conditions

status:
  conditions:
  - lastTransitionTime: "2024-08-02T13:05:38Z"
    message: 'could not create master endpoint: could not create master endpoint:
      endpoints "acid-minimal-cluster-test-1" already exists'
    reason: CreateFailed
    status: "False"
    type: ReconciliationSuccessful
  - lastTransitionTime: "2024-08-02T13:05:38Z"
    status: "False"
    type: Ready
  labelSelector: cluster-name=acid-minimal-cluster
  numberOfInstances: 0
  postgresClusterStatus: CreateFailed

Signed-off-by: RavinaChidambaram  <cravina.19@gmail.com>
Signed-off-by: RavinaChidambaram <cravina.19@gmail.com>
@RavinaChidambaram

Copy link
Copy Markdown
Author

Hi @FxKu , Is there any update on this PR?

@FxKu

FxKu commented Aug 23, 2024

Copy link
Copy Markdown
Contributor

I had to concentrate on the 1.13.0 release. But we will definitely include it in the next release in autumn. This is a great addition. I have to focus on some internal projects for the next weeks, but still, I hope to find some time in between to review.

@FxKu

FxKu commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

@RavinaChidambaram can you fix the failing unit test so e2e pipeline can run? There are places where we logged the status assuming it's just a string. Now that it has become a struct you either have to change to %#v when formatting the log lines or specify the PostgresClusterStatus field.

Comment thread pkg/apis/acid.zalan.do/v1/crds.go Outdated
Comment thread pkg/apis/acid.zalan.do/v1/postgresql_type.go
Comment thread pkg/apis/acid.zalan.do/v1/postgresql_type.go Outdated
type Condition struct {
Type ConditionType `json:"type" description:"type of status condition"`
Status v1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"`
LastTransitionTime VolatileTime `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why use an extra type and not just metav1.Time?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly to avoid semantic check inequality with metav1.time, with a wrapper around metav1.time there won't be a semantic inequality even if the times are different but everything else in the CR is same, this could be handy while writing unit tests or e2e tests I think

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FxKu , Is this okay?

Comment thread pkg/cluster/cluster.go Outdated
Comment thread pkg/util/k8sutil/k8sutil.go Outdated
@FxKu

FxKu commented Aug 27, 2024

Copy link
Copy Markdown
Contributor

As half of my comments target the scale subresource, I would suggest to remove it from here and create a separate PR for it. Then you could concentrate only on the status and we get it merged quicker.

Have you tried to run code-generation. I think, the generated code has to get updated with the new status structure.

Signed-off-by: RavinaChidambaram <cravina.19@gmail.com>
@RavinaChidambaram

Copy link
Copy Markdown
Author

I have made changes to fix the unit tests and successfully ran code-generation, unit tests and e2e test downstream.
Kindly review the changes and if you still think it's necessary to create a new branch for scale subresource addition, I will proceed with it.

Signed-off-by: RavinaChidambaram <cravina.19@gmail.com>
@RavinaChidambaram

Copy link
Copy Markdown
Author

Hi @FxKu , any updates?

@FxKu

FxKu commented Oct 30, 2024

Copy link
Copy Markdown
Contributor

@RavinaChidambaram sorry for not coming back sooner. I see that you did not reflect all my comments. I also do wonder if we have to change the code logic and move the SetPostgresCRDStatus into another package so that the signature can remain the same (clusterName spec.NamespacedName, status string) and we will the other fields inside this function? Because, right now we have so many code lines changed and as far as I can see:

  • NumberOfInstances
  • LabelSelector
  • ObservedGeneration
  • Conditions

would always be constructed in the same way. WDYT?

@FxKu FxKu modified the milestones: 1.14.0, 1.15.0 Nov 11, 2024
@RavinaChidambaram

RavinaChidambaram commented Nov 18, 2024

Copy link
Copy Markdown
Author

I think I have made all the changes that you mentioned, except for the metav1.time. And I have mentioned the reason for using that in the thread itself. Kindly let me know what you think about that.
Regarding keeping the SetPostgresCRDStatus signature unchanged, I agree - we can move the construction of fields like NumberOfInstances, LabelSelector, ObservedGeneration, and Conditions into the function itself. And I am working on implementing the same.

@FxKu FxKu moved this from Open Questions to Waiting for review in Postgres Operator Jul 15, 2025
@zalando-robot

Copy link
Copy Markdown

Cannot start a pipeline due to:

No accountable user for this pipeline: no Zalando employee associated to this GitHub username

Click on pipeline status check Details link below for more information.

@RavinaChidambaram

Copy link
Copy Markdown
Author

Hi @FxKu ,
As suggested, the construction of the status fields has been moved into the function itself.
But this required adding two new parameters to the function SetPostgresCRDStatus - clusterNameLabel and message.

@FxKu FxKu modified the milestones: 1.15.0, 1.16.0 Oct 14, 2025
@FxKu

FxKu commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

superceded by #3006

@FxKu FxKu closed this Jun 29, 2026
@github-project-automation github-project-automation Bot moved this from Waiting for review to Done in Postgres Operator Jun 29, 2026
@FxKu FxKu modified the milestones: 2.0.0, wishlist Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Improving Postgres CR Status with Additional Details

3 participants