Skip to content
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

K8SPG-714: fix panic #1032

Merged
merged 10 commits into from
Jan 30, 2025
Merged

K8SPG-714: fix panic #1032

merged 10 commits into from
Jan 30, 2025

Conversation

pooknull
Copy link
Contributor

@pooknull pooknull commented Jan 28, 2025

https://perconadev.atlassian.net/browse/K8SPG-714

DESCRIPTION

This PR fixes the panic on update to 2.6.0 operator

Also it fixes following issues:

  • handles conflict error on pgbackup status update, which caused following log message: update PGBackup status: Operation cannot be fulfilled on perconapgbackups.pgv2.percona.com \"XXX\": the object has been modified
  • resources not being applied to patroni-version-check pod
  • reduces patroni-version-check pod's terminationGracePeriod to 5
  • fixes percona.com/delete-backup not being removed after backup completion

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?

gkech
gkech previously approved these changes Jan 30, 2025
if !k8serrors.IsNotFound(err) {
return reconcile.Result{}, errors.Wrap(err, "get PostgresCluster")
}
pgCluster = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Commenting only to confirm that I understand this fully. What we want to do with assigning this to nil is effectively to be able to remove the finalizer when RunFinalizer is executed

	if err := f(ctx, obj); err != nil {
		if errors.Is(err, ErrFinalizerPending) {
			return false, nil
		}
		return false, errors.Wrapf(err, "run finalizer %s", finalizer)
	}

	if controllerutil.RemoveFinalizer(obj, finalizer) {
		log.Info("Removing finalizer", "name", finalizer)
		if err := cl.Patch(ctx, obj, client.MergeFrom(orig)); err != nil {
			return false, errors.Wrap(err, "remove finalizers")
		}
	}

and more specifically, when ☝🏽 these are executed, is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are correct. If we don’t set it to nil, the finalizer will fail, preventing its removal. The deleteBackupFinalizer function checks whether pgCluster is nil, and if so, it returns successfully:

func deleteBackupFinalizer(c client.Client, pg *v2.PerconaPGCluster) func(ctx context.Context, pgBackup *v2.PerconaPGBackup) error {
return func(ctx context.Context, pgBackup *v2.PerconaPGBackup) error {
if pg == nil {
return nil
}

Copy link
Contributor

Choose a reason for hiding this comment

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

⭐ thanks!

Copy link
Contributor

@egegunes egegunes left a comment

Choose a reason for hiding this comment

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

please add comments to new code added into files in internal/, it'll be helpful when we do upstream merges

@pooknull pooknull requested a review from egegunes January 30, 2025 14:26
@hors hors requested a review from gkech January 30, 2025 14:34
@JNKPercona
Copy link
Collaborator

Test name Status
custom-extensions passed
custom-tls passed
demand-backup passed
finalizers passed
init-deploy passed
monitoring passed
one-pod passed
operator-self-healing passed
pitr passed
scaling passed
scheduled-backup passed
self-healing passed
sidecars passed
start-from-backup passed
tablespaces passed
telemetry-transfer passed
upgrade-consistency passed
upgrade-minor passed
users passed
We run 19 out of 19

commit: 9fc01f5
image: perconalab/percona-postgresql-operator:PR-1032-9fc01f539

@egegunes egegunes merged commit fdd16c1 into main Jan 30, 2025
17 checks passed
@egegunes egegunes deleted the K8SPG-714 branch January 30, 2025 15:20
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.

4 participants