Skip to content

feat: enable replica mode on an existing cluster - #4261

Merged
mnencia merged 22 commits into
mainfrom
dev/3796
Apr 24, 2024
Merged

mnencia merged 22 commits into
mainfrom
dev/3796

Conversation

@armru

@armru armru commented Apr 9, 2024 •

Copy link
Copy Markdown
Member

Enable demotion of a primary cluster to a replica cluster by setting .spec.replica.enabled to true. This enhancement facilitates manual orchestration of a data center switchover without the need to re-clone the former primary.

Closes #3796

@github-actions github-actions Bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.21 labels Apr 9, 2024
@github-actions

github-actions Bot commented Apr 9, 2024

Copy link
Copy Markdown
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@github-actions

github-actions Bot commented Apr 9, 2024

Copy link
Copy Markdown
Contributor

Build Error! No Linked Issue found. Please link an issue or mention it in the body using #<issue_id>

@armru

armru commented Apr 9, 2024

Copy link
Copy Markdown
Member Author

/test limit=local

@github-actions

github-actions Bot commented Apr 9, 2024

Copy link
Copy Markdown
Contributor

@armru armru changed the title wip: enable replica on an existing cluster wip: allow replica to be set on existing clusters Apr 9, 2024
@gbartolini gbartolini changed the title wip: allow replica to be set on existing clusters feat: enable replica mode on an existing cluster Apr 9, 2024
@gbartolini

Copy link
Copy Markdown
Contributor

I tested it locally and it works. I think we still need to address: #3796 (comment)

@gbartolini

Copy link
Copy Markdown
Contributor

I tested it locally and it works. I think we still need to address: #3796 (comment)

Ignore my comment about pause, as recovery_target_action is a fixed option.

@gbartolini gbartolini left a comment

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.

Did not check the code. I tested the feature and works as expected.

@armru
armru force-pushed the dev/3796 branch 2 times, most recently from 73a75ed to 3f79cd0 Compare April 10, 2024 07:53
@armru armru removed backport-requested ◀️ This pull request should be backported to all supported releases release-1.21 labels Apr 11, 2024
@armru

armru commented Apr 11, 2024

Copy link
Copy Markdown
Member Author

/test limit=local

@github-actions

Copy link
Copy Markdown
Contributor

@armru

armru commented Apr 11, 2024

Copy link
Copy Markdown
Member Author

/test limit=local

@github-actions

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot added the ok to merge 👌 This PR can be merged label Apr 11, 2024
@armru

armru commented Apr 15, 2024

Copy link
Copy Markdown
Member Author

/test limit=local

@github-actions

Copy link
Copy Markdown
Contributor

@armru armru added the risk 💥 Risk/Compliance label Apr 15, 2024

// reconcileInstance sets PostgreSQL instance parameters to current values
func (r *InstanceReconciler) reconcileInstance(cluster *apiv1.Cluster) {
detectRequiresDesignatedPrimaryTransition := func() bool {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This function is encapsulated here because this is the only place where the calculation should happen, and calling it elsewhere could lead to non-deterministic results and potential disasters

@leonardoce

Copy link
Copy Markdown
Contributor

E2e tests are green

armru and others added 20 commits April 24, 2024 07:22
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
@mnencia mnencia added the do not backport This PR must not be backported - it will be in the next minor release label Apr 24, 2024
This patch allows hibernated clusters to be rehydrated as replica
clusters. This is a step toward implementing a data center switchover
workflow.

Before starting up PostgreSQL, the old primary instance is immediately
demoted. `pg_rewind` is not executed.

Signed-off-by: Leonardo Cecchi <[email protected]>
@mnencia
mnencia merged commit ebd476b into main Apr 24, 2024
@mnencia
mnencia deleted the dev/3796 branch April 24, 2024 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not backport This PR must not be backported - it will be in the next minor release ok to merge 👌 This PR can be merged risk 💥 Risk/Compliance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Enable replica mode on an existing cluster

4 participants