Re: Adding a pg_servername() function

From: Laetitia Avrot <laetitia(dot)avrot(at)gmail(dot)com>
To: Christoph Moench-Tegeder <cmt(at)burggraben(dot)net>
Cc: GF <phabriz(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Adding a pg_servername() function
Date: 2023-08-10 08:14:46
Message-ID: CAB_COdgPR_oXRt=Sf8V+9V74uaJnuT7MmUr4ySfSRa7B5KQUEA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dear Christoph,

Please find my answers below.

Le mer. 9 août 2023 à 22:05, Christoph Moench-Tegeder <cmt(at)burggraben(dot)net>
a écrit :

> ## GF (phabriz(at)gmail(dot)com):
>
> And now that I checked it: I do have systems with gethostname()
> returning an FQDN, and other systems return the (short) hostname
> only.

The return of gethostname() depends on what has been configured. So, yes
some people will prefer a FQDN while others will prefer a short hostname.
Also, it's a POSIX standard function (see
https://pubs.opengroup.org/onlinepubs/9699919799/), so I don't get why
getting a FQDN or a short name depending on what people set would be a
problem for Postgres while it's not for Linux.

> And it gets worse when you're talking "container" and
> "automatic image deployment". So I believe it's a good thing when
> a database does not expose too much of the OS below it...
>
>
I respectfully disagree. Containers still have a hostname: for example, by
default, docker uses their container id. (see
https://docs.docker.com/network/). In fact, the Open Container Initiative
defines the hostname as a runtime configuration parameter (see
https://github.com/opencontainers/runtime-spec/blob/main/config.md):

> Hostname
>
> - *hostname* (string, OPTIONAL) specifies the container's hostname as
> seen by processes running inside the container. On Linux, for example, this
> will change the hostname in the container
> <https://github.com/opencontainers/runtime-spec/blob/main/glossary.md#container-namespace> UTS
> namespace <http://man7.org/linux/man-pages/man7/namespaces.7.html>.
> Depending on your namespace configuration
> <https://github.com/opencontainers/runtime-spec/blob/main/config-linux.md#namespaces>,
> the container UTS namespace may be the runtime
> <https://github.com/opencontainers/runtime-spec/blob/main/glossary.md#runtime-namespace> UTS
> namespace <http://man7.org/linux/man-pages/man7/namespaces.7.html>.
>
> Example
>
> "hostname": "mrsdalloway"
>
>
Have a nice day,

Lætitia

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Junwang Zhao 2023-08-10 08:18:24 Re: [BackendXidGetPid] only access allProcs when xid matches
Previous Message Ashutosh Bapat 2023-08-10 08:11:03 Re: [BackendXidGetPid] only access allProcs when xid matches