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

add the possibility to create a standby cluster that streams from a remote primary #1544

Closed
wants to merge 2 commits into from

Conversation

machine424
Copy link
Contributor

@machine424 machine424 commented Jun 30, 2021

Hello,

I don't know if we should add any tests for this. -> I'll add some unit tests (DONE)

Still need to adjust the user's doc.

Do without the blocking point in here: #804

We suppose both clusters have the same standby's password for now.

pkg/cluster/k8sres.go Outdated Show resolved Hide resolved
pkg/cluster/k8sres.go Outdated Show resolved Hide resolved
@machine424
Copy link
Contributor Author

I ping you @FxKu as you've started reviewing the other PR

@machine424 machine424 marked this pull request as ready for review July 7, 2021 19:22
@machine424
Copy link
Contributor Author

@Jan-M maybe?

manifests/postgresql.crd.yaml Outdated Show resolved Hide resolved
pkg/cluster/k8sres.go Show resolved Hide resolved
@offzale
Copy link

offzale commented Sep 29, 2021

@machine424 thanks for the work! This is a great patroni feature you're bringing here, looking forward to it. Are you planning to continue working on it?

@machine424
Copy link
Contributor Author

Hello @FxKu and @offzale

I just figured out I never pushed my changes. I've just rebased.

Before adjusting the user's doc, we'll need, in another PR I think, to add support of Services for spilo-role: standby_leader Pods, (as standby_leader Patroni doesn't manage the Endpoint as master does).

As a workaround (we run this machine424@02c415a on prod since july 2021), we create an extra Service that points to spilo-role: standby_leader.


* **s3_wal_path**
the url to S3 bucket containing the WAL archive of the remote primary.
Optional, but `s3_wal_path` or `gs_wal_path` is required.
Required when the `standby` section is present even when `standby_host` is set.
Copy link
Member

@FxKu FxKu Mar 21, 2022

Choose a reason for hiding this comment

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

Hm, it should not be required if host or gs_wal_path is set. We can work with oneOf in the CRD schema validation, I think.

              standby:
                type: object
                properties:
                  s3_wal_path:
                    type: string
                  gs_wal_path:
                    type: string
                  standby_host:
                    type: string
                  standby_port:
                    type: string
                oneOf:
                - required:
                  - s3_wal_path
                - required:
                  - gs_wal_path 
                - required:
                  - standby_host

spec.StandbyCluster.GSWalPath == "" {
return nil, fmt.Errorf("one of s3_wal_path or gs_wal_path must be set for standby cluster")
if spec.StandbyCluster != nil {
if spec.StandbyCluster.S3WalPath == "" && spec.StandbyCluster.GSWalPath == "" && spec.StandbyCluster.StandbyHost == "" {
Copy link
Member

Choose a reason for hiding this comment

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

when one of the three options is required, I guess this extra if would be obsolete then

envPos: 0,
},
{
subTest: "from remote primary",
Copy link
Member

Choose a reason for hiding this comment

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

could add here that this also tests host taking precedence over wal path setting. Maybe make it an extra test with right comment.

@FxKu
Copy link
Member

FxKu commented Mar 21, 2022

Thanks @machine424. Would be happy to merge it for the next release. Have a look at my comments. There seems to be one conflict left.

@FxKu FxKu added this to the 1.8 milestone Mar 21, 2022
@FxKu
Copy link
Member

FxKu commented Mar 25, 2022

@machine424 can you resolve the conflict and reflect my comments?

@machine424
Copy link
Contributor Author

Hello @FxKu,

I've started looking at this but I discovered you already took care of it here #1830 Thanks and sorry I didn't had time before.

Should I open an issue for the limitation I talked about in #1544 (comment)? (of document it?) I'd try to address it when I have time.

You can close this PR when you want.

@FxKu
Copy link
Member

FxKu commented Apr 1, 2022

@machine424 thanks for getting back. Regarding the extra service: Is it necessary?I know that the operator just labels the standby leader pod / service / endpoint as master.

@machine424
Copy link
Contributor Author

Yes, the operator will create two services for the standby cluster: service with no selectors and service-repl with spilo-role: replica as a selector.

The standby cluster Pod will not edit the Endpoints of service because it does't have the maqter role.
And will not be represented by service-repl because it has the label spilo-role: standby_leader.

Am I wrong?

@FxKu FxKu closed this in #1830 Apr 4, 2022
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.

None yet

3 participants