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-704: Allow configuring create_replica_methods #1110

Merged
merged 6 commits into from
Apr 6, 2025
Merged

K8SPG-704: Allow configuring create_replica_methods #1110

merged 6 commits into from
Apr 6, 2025

Conversation

egegunes
Copy link
Contributor

@egegunes egegunes commented Mar 27, 2025

K8SPG-704 Powered by Pull Request Badge

CHANGE DESCRIPTION

Even though we are adding a way to override Patroni configuration in #1108, support team requests a way to permanently configure create_replica_methods through cr.yaml. This PR adds a new field called createReplicaMethods under patroni:

patroni:
  createReplicaMethods:
  - pgbackrest
  - basebackup

Once user applies this configuration, ConfigMaps that store Patroni instance configuration (<pod-name>-config) will be updated by operator but operator won't actually apply the new config to Patroni. It's up to you to run patronictl reload.

Helm PR: percona/percona-helm-charts#510

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?

@egegunes egegunes added this to the 2.7.0 milestone Mar 31, 2025
@egegunes egegunes marked this pull request as ready for review April 2, 2025 14:26
hors
hors previously approved these changes Apr 3, 2025
Comment on lines +588 to +595
// K8SPG-704: Allow overriding create replica methods list
if cluster.Spec.Patroni != nil && len(cluster.Spec.Patroni.CreateReplicaMethods) > 0 {
methods = []string{}
for _, m := range cluster.Spec.Patroni.CreateReplicaMethods {
methods = append(methods, string(m))
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Recommend unit testing this function. In order to better manage the test in future upstream merges, maybe we can just add the following in

	cluster.Spec.Patroni.CreateReplicaMethods = []v1beta1.CreateReplicaMethod{"custom1", "custom2"}
	dataWithCustomMethods, err := instanceYAML(cluster, instance, nil)
	assert.NilError(t, err)
	assert.Equal(t, dataWithCustomMethods, strings.Trim(`
# Generated by postgres-operator. DO NOT EDIT.
# Your changes will not be saved.
bootstrap:
  initdb:
  - data-checksums
  - encoding=UTF8
  - waldir=/pgdata/pg12_wal
  - encryption-key-command=echo test
  method: initdb
kubernetes: {}
postgresql:
  basebackup:
  - waldir=/pgdata/pg12_wal
  create_replica_methods:
  - custom1
  - custom2
  pgpass: /tmp/.pgpass
  use_unix_socket: true
restapi: {}
tags: {}
	`, "\t\n")+"\n")
	

In func TestInstanceYAML(t *testing.T)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JNKPercona
Copy link
Collaborator

Test name Status
custom-extensions passed
custom-tls passed
demand-backup passed
finalizers passed
init-deploy passed
monitoring passed
monitoring-pmm3 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 20 out of 20

commit: e7feb65
image: perconalab/percona-postgresql-operator:PR-1110-e7feb65f4

@hors hors merged commit 677d96a into main Apr 6, 2025
15 checks passed
@hors hors deleted the K8SPG-704 branch April 6, 2025 09:16
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