spilo icon indicating copy to clipboard operation
spilo copied to clipboard

allow to use application name for upgrade

Open sylvainOL opened this issue 10 months ago • 7 comments

Instead of using replica IP address, allow to use replica name in case IP address is not reliable (like when using a service mesh).

This trigger is controller by using an environment variable (USE_APPLICATION_NAME_IN_UPGRADE) and default behavior is the previous one.

closes zalando/postgres-operator#1629

sylvainOL avatar Sep 05 '23 07:09 sylvainOL

Hello @hughcapet, is there any chances to review it?

Thanks!

sylvainOL avatar Oct 05 '23 12:10 sylvainOL

Hello @jopadi @idanovinda @hughcapet @Jan-M @sdudoladov,

Can you tell me what you think of this PR?

it would help a lot when postgres is used on top of service mesh such as istio

thanks!

sylvainOL avatar Nov 06 '23 08:11 sylvainOL

why not query both fields, and then try depending on env var to use the application name or fall back to ip. i am not such a big fan of templating those parts of sql queries.

Jan-M avatar Nov 06 '23 08:11 Jan-M

But yes, we will keep an eye on this, if this helps in service mesh world we should help you.

Jan-M avatar Nov 06 '23 08:11 Jan-M

Hello @Jan-M,

first thanks for quick reply!

why not query both fields, and then try depending on env var to use the application name or fall back to ip. i am not such a big fan of templating those parts of sql queries.

I'm not (at all) an expert of SQL (and SQL in python) ^_^ so I did the best I could :)

I'm not sure on how to retrieve the values after the requests:

I should propose something like this and it would work?:

        streaming = {a: l for a, l in self.postgresql.query(
            ("SELECT client_addr, application_name, pg_catalog.pg_{0}_{1}_diff(pg_catalog.pg_current_{0}_{1}(),"
             " COALESCE(replay_{1}, '0/0'))::bigint FROM pg_catalog.pg_stat_replication")
            .format(self.postgresql.wal_name, self.postgresql.lsn_name))}

        def ensure_replica_state(member):
            ip = member.conn_kwargs().get('host')
            lag = streaming.get(ip)
            if os.getenv('USE_APPLICATION_NAME_IN_UPGRADE'):
                lag = streaming.get(member.name)
            if lag is None:
                return logger.error('Member %s is not streaming from the primary', member.name)

sylvainOL avatar Nov 06 '23 08:11 sylvainOL

hi @Jan-M,

I tried to apply your comment on the PR :)

sylvainOL avatar Dec 05 '23 09:12 sylvainOL

Another issue we are seeing with istio is that when the COPY TO PROGRAM is executed for rsync it is sending the the istio 127.0.0.6 ip for PRIMARY_IP

greyt75 avatar Mar 19 '24 19:03 greyt75