Skip to content

Conversation

@hors
Copy link
Collaborator

@hors hors commented Oct 5, 2024

K8SPG-648 Powered by Pull Request Badge

CHANGE DESCRIPTION

Problem:
Short explanation of the problem.

Cause:
Short explanation of the root cause of the issue if applicable.

Solution:
Short explanation of the solution we are providing with this PR.

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?
  • 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?

@egegunes egegunes added this to the v2.6.0 milestone Nov 25, 2024
inelpandzic
inelpandzic previously approved these changes Dec 11, 2024
// +kubebuilder:rbac:groups=apps,resources=replicasets,verbs=create;delete;get;list;patch;watch
// +kubebuilder:rbac:groups=pgv2.percona.com,resources=perconapgclusters/finalizers,verbs=update
// +kubebuilder:rbac:groups=batch,resources=jobs,verbs=create;list;update
// +kubebuilder:rbac:groups=pgv2.percona.com,resources=pods,verbs=create;delete
Copy link
Contributor

Choose a reason for hiding this comment

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

do we have pods resource in this api group?

Copy link
Contributor

Choose a reason for hiding this comment

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

}

if err := r.Client.Create(ctx, p); err != nil {
return errors.Wrap(err, "failed to create pod to check patrni version")
Copy link
Contributor

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, "failed to create pod to check patrni version")
return errors.Wrap(err, "failed to create pod to check patroni version")

Copy link
Contributor

Choose a reason for hiding this comment

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

// next cannot be blank. Similar to the "POST /switchover" REST endpoint.
func (exec Executor) ChangePrimaryAndWait(
ctx context.Context, current, next string,
ctx context.Context, current, next string, ver4 bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

i would name this patroniVer4 to be more clear

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@inelpandzic inelpandzic left a comment

Choose a reason for hiding this comment

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

Besides @egegunes comments, this looks good.
@pooknull pls check those comments.

Comment on lines 99 to 107
patroniVerStr, ok := cluster.Annotations[pNaming.ToCrunchyAnnotation(pNaming.AnnotationPatroniVersion)]
if !ok {
return errors.New("patroni version annotation was not found")
}
patroniVer, err := gover.NewVersion(patroniVerStr)
if err != nil {
return errors.Wrap(err, "failed to get patroni ver")
}
patroniVer4 := patroniVer.Compare(gover.Must(gover.NewVersion("4.0.0"))) >= 0
Copy link
Contributor

Choose a reason for hiding this comment

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

i see we do this in multiple places, can we move this logic to a function?

Copy link
Contributor

Choose a reason for hiding this comment

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

also i don't think we should use gover.Must since it'll panic if it can't parse the version

Copy link
Contributor

Choose a reason for hiding this comment

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

// We should use "primary" instead
cmd := []string{"patronictl", "switchover", "--scheduled=now", "--force", "--primary=" + current, "--candidate=" + next}
if !patroniVer4 {
cmd = []string{"patronictl", "switchover", "--scheduled=now", "--force", "--master=" + current, "--candidate=" + next}
Copy link
Contributor

Choose a reason for hiding this comment

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

rather than duplicating the slice, can we do smth like cmd[4] = "--master=" + current?

Copy link
Contributor

Choose a reason for hiding this comment

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

@pooknull pooknull requested a review from egegunes January 7, 2025 11:48
@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: 9fc8f82
image: perconalab/percona-postgresql-operator:PR-921-9fc8f826a

@hors hors requested a review from gkech as a code owner January 13, 2025 13:35
@hors hors merged commit b3d6398 into main Jan 13, 2025
13 of 14 checks passed
@hors hors deleted the K8SPG-648 branch January 13, 2025 13:36
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