Skip to content

Add PAT/NAT config #455

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add PAT/NAT config #455

wants to merge 1 commit into from

Conversation

nabbar
Copy link
Contributor

@nabbar nabbar commented Mar 9, 2018

Hello,

First, thanks a lot for your work.

I needed to use a NAT / PAT configuration for postgres instances managed by the keeper. Also, I allowed myself to modify the code a bit to allow these features.

I named the flag as "advertise" which are optional flags.
This advertise flag are added for listening pg address and listening pg port.

The flags are managed as :

  • If the listening is not set, it will use the advertise value.
  • If the advertise is not set, it will use the listening value.
  • if no one (advertise and listening) are not set, the keeper will return an error.

I hope this code will be consistent with your idea of the project.
I tried to make as few changes as possible but with the greatest flexibility possible.

Regards,

Nicolas.

@nabbar
Copy link
Contributor Author

nabbar commented Mar 9, 2018

Sorry, i forget to squash my commit...

@sgotti
Copy link
Member

sgotti commented Mar 9, 2018

@nabbar Thanks a lot of your PR! I will be able to deeply review it in the next week.

Sorry, i forget to squash my commit...

Don't worry, you can squash it later after the review or when you prefer.

@nabbar
Copy link
Contributor Author

nabbar commented Mar 9, 2018

git squash done

Copy link
Member

@sgotti sgotti left a comment

Choose a reason for hiding this comment

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

@nabbar Initial review, overall it looks good. I have some doubts on the changed behaviour (see comments).

We'll need some changes to the integration tests to also test that options. My idea will be:


if p.pgListenAddress != "*" {
lst = []string{"127.0.0.1"}
}
Copy link
Member

Choose a reason for hiding this comment

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

just noticed that listening on localhost is probably not needed anymore by the stolon keeper since we use unix sockets. Perhaps it's useful for people doing local connections (local backups scripts etc...) so we could keep it to avoid possible regression.

Copy link
Contributor Author

@nabbar nabbar Mar 15, 2018

Choose a reason for hiding this comment

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

yes i think so, but I wanted to keep as much functionality as possible.
If your are agree, I will remove it :)

if cfg.pgAdvertiseAddress == "" && cfg.pgListenAddress == "" {
die("--pg-listen-address and/or --pg-advertise-address is required")
} else if cfg.pgListenAddress == "" {
cfg.pgListenAddress = "*"
Copy link
Member

Choose a reason for hiding this comment

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

I'll prefer the user to always specifiy the listen address and not default to '*' when not specified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oki, no problem, I'm quizzing myself for a while about the default values to apply.

cfg.pgPort = cfg.pgAdvertisePort
} else if cfg.pgAdvertisePort == "" {
cfg.pgAdvertisePort = cfg.pgPort
}
Copy link
Member

Choose a reason for hiding this comment

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

This looks strange since if pgPort is not specified it'll be set to advertise port and if pgAdvertisePort is not specified it'll be set to pgPort. But pgPort has a default to 5432 so it'll probably never happen.

I'll prefer to keep the original behavior and just set pgAdvertisePort to pgPort when pgAdvertisePort is not specified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, no problem :)

if ip == nil {
log.Warnf("provided --pgListenAddress %q: is not an ip address but a hostname. This will be advertized to the other components and may have undefined behaviors if resolved differently by other hosts", cfg.pgListenAddress)
log.Warnf("provided --pg-advertise-address %q: is not an ip address but a hostname. This will be advertized to the other components and may have undefined behaviors if resolved differently by other hosts", cfg.pgAdvertiseAddress)
Copy link
Member

Choose a reason for hiding this comment

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

The log can look strange to an user if it hasn't provided pgAdvertiseAddress. Perhaps to could be change to
PGAdvertiseAddress: %q: ... and when setting pgAdvertiseAddress to pgListenAddress logging that we are setting PGAdvertiseAddress to PGListenAddress.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes as following previous comment, I think this must be change to apply correct message.

@nabbar
Copy link
Contributor Author

nabbar commented Mar 15, 2018

I will do this fix, this WE or next week.
I keep you inform when i was ready.

The advertise address:port will be publish in the keeper information to be used by client, sentinel, proxy, ctl or other keeper.
The listening address/port will be used only for postgres instance configuration.

Fix :
  - localhost not need for listenAddress postgres instance
  - check init flag : listenaddress must be explicit, advertise listen address will use listenaddres if not specified
  - check init flag : use specified flag for warn/error message
  - check init flag : don't touch init pgport and just set advertise pg port if not specified
@sgotti
Copy link
Member

sgotti commented Mar 27, 2018

@nabbar Is it ready? If you want I can help you to write the tests.

@nabbar
Copy link
Contributor Author

nabbar commented Mar 30, 2018

Hello,

Sorry, I am little busy this days...
@sgotti If you have time to update the test, It could be great if you have time for it :)

Thanks in advance

@daMupfel
Copy link
Contributor

daMupfel commented Oct 30, 2018

Hi,

Is there any reason this was never finished, it seems to be a valuable addition to stolon? Is there anything i could do to push this?

Regards David

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.

3 participants