Skip to content

K8SPG-782 assign patroni version to status when patroni label is configured through the cr option #1165

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
Jun 16, 2025
Merged
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
25 changes: 25 additions & 0 deletions percona/controller/pgcluster/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,31 @@ func (r *PGClusterReconciler) reconcilePatroniVersionCheck(ctx context.Context,

if patroniVersion, ok := cr.Annotations[pNaming.AnnotationCustomPatroniVersion]; ok {
cr.Annotations[pNaming.AnnotationPatroniVersion] = patroniVersion

patroniVersionUpdateFunc := func() error {
cluster := &v2.PerconaPGCluster{}
if err := r.Client.Get(ctx, types.NamespacedName{
Name: cr.Name,
Namespace: cr.Namespace,
}, cluster); err != nil {
return errors.Wrap(err, "get PerconaPGCluster")
}

orig := cluster.DeepCopy()

cluster.Status.PatroniVersion = patroniVersion

if err := r.Client.Status().Patch(ctx, cluster.DeepCopy(), client.MergeFrom(orig)); err != nil {
return errors.Wrap(err, "failed to patch patroni version")
}
return nil
}

// To ensure that the update was done given that conflicts can be caused by
// other code making unrelated updates to the same resource at the same time.
if err := retry.RetryOnConflict(retry.DefaultRetry, patroniVersionUpdateFunc); err != nil {
return errors.Wrap(err, "failed to patch patroni version")
}
return nil
}

Expand Down
Loading