Skip to content

K8SPG-1007: Rename upstream CRDs#1561

Open
egegunes wants to merge 29 commits intomainfrom
crd-rename
Open

K8SPG-1007: Rename upstream CRDs#1561
egegunes wants to merge 29 commits intomainfrom
crd-rename

Conversation

@egegunes
Copy link
Copy Markdown
Contributor

@egegunes egegunes commented Apr 21, 2026

CHANGE DESCRIPTION

Problem:
Re-using upstream CRDs makes it hard to deploy operator in a cluster where upstream operator is already running. This makes it hard to deploy our operator and ensure existing upstream clusters are not affected.

Solution:

  • Rename upstream CRD API group to upstream.pgv2.percona.com

The operator previously owned PostgresCluster under the group postgres-operator.crunchydata.com/v1beta1, and has been renamed to upstream.pgv2.percona.com/v1beta1. Existing running clusters have child objects (StatefulSets, Secrets, PVCs, etc.) whose ownerReferences still point at the old-group parent. PostgresCluster (upstream) controller re-parents those children to the new-group parent and then removes the old parent — without triggering restarts or deletes of the children.

PerconaPGCluster controller iterates through children of PostgresCluster and checks if owner references are updated. This is done only to inform user about the migration state and provide a better experience.

While the migration is in progress, there will be a status condition in PerconaPGCluster object:

    - lastTransitionTime: "2026-04-30T14:09:56Z"
      message: Waiting for owner references to be updated
      observedGeneration: 2
      reason: APIGroupMigrationInProgress
      status: "False"
      type: APIGroupMigration

After migration is completed, condition status will be True and check won't run again:

    - lastTransitionTime: "2026-04-30T14:18:12Z"
      message: All owner references are updated
      observedGeneration: 2
      reason: APIGroupMigrationCompleted
      status: "True"
      type: APIGroupMigration

Operator logs all children objects it checks on Info level. Logger name is APIGroupMigration, you can grep this string to see all operations.

Known limitations

  • Due to K8SPG-1015, cert-manager Issuer objects are not checked and not considered for setting condition to True.

Test cases

  • Installing renamed CRDs shouldn't affect clusters managed by the upstream operator.
  • Running the operator with the same namespace with upstream cluster shouldn't modify anything in the upstream cluster.
  • Running operator on a fresh cluster without legacy CRDs shouldn't start the migration check.
  • The list of children that operator checks need to be reviewed to ensure we are not missing anything.

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PG version?
  • Does the change support oldest and newest supported Kubernetes version?

Copilot AI review requested due to automatic review settings April 21, 2026 06:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

Comment thread hack/create-todo-patch.sh
Comment on lines 35 to +37
python3 -m yq -r \
.spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.customTLSSecret.properties.name.description \
"${clusters_dir}/generated/postgres-operator.crunchydata.com_postgresclusters.yaml"
"${clusters_dir}/generated/upstream.pgv2.percona.com_postgresclusters.yaml"
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.

[shfmt] reported by reviewdog 🐶

Suggested change
python3 -m yq -r \
.spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.customTLSSecret.properties.name.description \
"${clusters_dir}/generated/postgres-operator.crunchydata.com_postgresclusters.yaml"
"${clusters_dir}/generated/upstream.pgv2.percona.com_postgresclusters.yaml"
python3 -m yq -r \
.spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.customTLSSecret.properties.name.description \
"${clusters_dir}/generated/upstream.pgv2.percona.com_postgresclusters.yaml"

Comment thread hack/create-todo-patch.sh
"${clusters_dir}/generated/postgres-operator.crunchydata.com_postgresclusters.yaml"
"${clusters_dir}/generated/upstream.pgv2.percona.com_postgresclusters.yaml"
)
name_desc_without_todo=$(sed 's/ TODO.*//g' <<< "${name_desc_with_todo}")
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.

[shfmt] reported by reviewdog 🐶

Suggested change
name_desc_without_todo=$(sed 's/ TODO.*//g' <<< "${name_desc_with_todo}")
name_desc_without_todo=$(sed 's/ TODO.*//g' <<<"${name_desc_with_todo}")

Comment thread hack/create-todo-patch.sh
[{ op: "remove", path: "/work" }]
' \
"${clusters_dir}/generated/postgres-operator.crunchydata.com_postgresclusters.yaml" > "${clusters_dir}/todos.yaml"
"${clusters_dir}/generated/upstream.pgv2.percona.com_postgresclusters.yaml" > "${clusters_dir}/todos.yaml"
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.

[shfmt] reported by reviewdog 🐶

Suggested change
"${clusters_dir}/generated/upstream.pgv2.percona.com_postgresclusters.yaml" > "${clusters_dir}/todos.yaml"
"${clusters_dir}/generated/upstream.pgv2.percona.com_postgresclusters.yaml" >"${clusters_dir}/todos.yaml"

Comment thread hack/create-todo-patch.sh
[{ op: "remove", path: "/work" }]
' \
"${upgrades_dir}/generated/postgres-operator.crunchydata.com_pgupgrades.yaml" > "${upgrades_dir}/todos.yaml"
"${upgrades_dir}/generated/upstream.pgv2.percona.com_pgupgrades.yaml" > "${upgrades_dir}/todos.yaml"
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.

[shfmt] reported by reviewdog 🐶

Suggested change
"${upgrades_dir}/generated/upstream.pgv2.percona.com_pgupgrades.yaml" > "${upgrades_dir}/todos.yaml"
"${upgrades_dir}/generated/upstream.pgv2.percona.com_pgupgrades.yaml" >"${upgrades_dir}/todos.yaml"

@@ -17,7 +17,7 @@ import (

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.

[goimports-reviser] reported by reviewdog 🐶

Suggested change
"sigs.k8s.io/controller-runtime/pkg/client"

@@ -18,7 +18,7 @@ import (

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.

[goimports-reviser] reported by reviewdog 🐶

Suggested change
corev1 "k8s.io/api/core/v1"

Comment on lines 16 to 17
"github.com/pkg/errors"

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.

[goimports-reviser] reported by reviewdog 🐶

Suggested change
"github.com/pkg/errors"

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.

[goimports-reviser] reported by reviewdog 🐶

apierrors "k8s.io/apimachinery/pkg/api/errors"
"github.com/pkg/errors"

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.

[goimports-reviser] reported by reviewdog 🐶

@egegunes egegunes changed the title Rename upstream CRDs K8SPG-1007: Rename upstream CRDs Apr 21, 2026
Copilot AI review requested due to automatic review settings April 23, 2026 08:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@@ -0,0 +1,36 @@
apiVersion: kustomize.config.k8s.io/v1beta1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Typo in file name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks, fixed

Copilot AI review requested due to automatic review settings April 24, 2026 09:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@egegunes egegunes marked this pull request as ready for review April 24, 2026 09:26
return reconcile.Result{}, errors.Wrap(err, "get new PostgresCluster")
}

if legacy.GetDeletionTimestamp().IsZero() {
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.

Wondering if this logic can have issues in case something like argocd/etc deletes legacy objects, marking them with deletion timestamp and for edge cases not triggering the logic here. Maybe we can add the finalizers early?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmm not sure if i follow, adding the finalizer is literally the first thing we do

@gkech
Copy link
Copy Markdown
Contributor

gkech commented Apr 27, 2026

We also have a lot of linting suggestions from golangci-lint, we should resolve these as well.

return nil
}
patch := client.MergeFrom(legacy.DeepCopy())
legacy.SetFinalizers(nil)
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 are we removing all the finalizers and not only the one we added with this logic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@egegunes
Copy link
Copy Markdown
Contributor Author

We also have a lot of linting suggestions from golangci-lint, we should resolve these as well.

@gkech they are all existing issues surfaced because I touched every single file from upstream. I don't want to fix them :/

Copilot AI review requested due to automatic review settings April 28, 2026 11:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

Copilot AI review requested due to automatic review settings April 29, 2026 10:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

Copilot AI review requested due to automatic review settings April 30, 2026 15:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

import (
"context"

apierrors "k8s.io/apimachinery/pkg/api/errors"
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.

[goimports-reviser] reported by reviewdog 🐶

Suggested change
apierrors "k8s.io/apimachinery/pkg/api/errors"
"github.com/pkg/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"

"github.com/percona/percona-postgresql-operator/v2/internal/naming"
v2 "github.com/percona/percona-postgresql-operator/v2/pkg/apis/pgv2.percona.com/v2"
"github.com/percona/percona-postgresql-operator/v2/pkg/apis/upstream.pgv2.percona.com/v1beta1"
"github.com/pkg/errors"
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.

[goimports-reviser] reported by reviewdog 🐶

Suggested change
"github.com/pkg/errors"

ObservedGeneration: cr.GetGeneration(),
})
if err != nil {
return errors.Wrap(err, "set status condition to false")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.Wrap(err, "set status condition to false")
return errors.Wrap(err, "set status condition to true")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

legacy.SetGroupVersionKind(LegacyGVK)

if err := r.Client.Get(ctx, types.NamespacedName{Name: cr.Name, Namespace: cr.Namespace}, legacy); err != nil {
return client.IgnoreNotFound(err)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How would this condition work for new clusters when legacy CRD is installed? IIUC, any new PerconaPGCluster will not be created with legacy PostgresCluster object. So according to this logic, it will do an early return here and the new PerconaPGCluster will be stuck with condition APIGroupMigration == False

It won't affect anything, but there will be a misleading condition

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@egegunes egegunes requested a review from mayankshah1607 May 4, 2026 06:49
Copilot AI review requested due to automatic review settings May 4, 2026 07:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@JNKPercona
Copy link
Copy Markdown
Collaborator

Test Name Result Time
backup-enable-disable passed 00:13:42
builtin-extensions passed 00:05:55
cert-manager-tls passed 00:07:32
custom-envs passed 00:18:22
custom-extensions passed 00:14:07
custom-tls passed 00:07:12
database-init-sql passed 00:02:19
demand-backup passed 00:22:07
demand-backup-offline-snapshot passed 00:12:34
dynamic-configuration passed 00:03:26
finalizers passed 00:03:32
init-deploy passed 00:02:38
huge-pages passed 00:02:58
major-upgrade-13-to-14 passed 00:10:52
major-upgrade-14-to-15 passed 00:11:05
major-upgrade-15-to-16 passed 00:11:59
major-upgrade-16-to-17 passed 00:15:26
major-upgrade-17-to-18 passed 00:10:31
ldap passed 00:03:35
ldap-tls passed 00:08:37
monitoring failure 00:06:38
monitoring-pmm3 passed 00:09:26
one-pod passed 00:06:17
operator-self-healing passed 00:10:37
pitr passed 00:12:06
scaling passed 00:04:49
scheduled-backup passed 00:26:26
self-healing passed 00:08:09
sidecars passed 00:02:29
standby-pgbackrest passed 00:18:11
standby-streaming passed 00:12:50
start-from-backup passed 00:11:35
tablespaces passed 00:06:44
telemetry-transfer passed 00:04:24
upgrade-consistency passed 00:06:08
upgrade-minor failure 00:16:38
users passed 00:04:27
Summary Value
Tests Run 37/37
Job Duration 02:23:52
Total Test Time 05:56:41

commit: f0daa58
image: perconalab/percona-postgresql-operator:PR-1561-f0daa5879

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants