[pmg-devel] [RFC pmg-api 2/4] PMG::Config: refactor dns info collection

Stoiko Ivanov s.ivanov at proxmox.com
Tue Nov 12 17:35:58 CET 2019


On Tue, 12 Nov 2019 16:45:41 +0100
Dominik Csapak <d.csapak at proxmox.com> wrote:

> On 11/12/19 3:16 PM, Stoiko Ivanov wrote:
> > Create a sub for gathering dns info of the current node (hostname, domainname,
> > fqdn) - so we can reuse it.
> > 
> > Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
> > ---
> >   src/PMG/Config.pm | 30 +++++++++++++++++++++---------
> >   1 file changed, 21 insertions(+), 9 deletions(-)
> > 
> > diff --git a/src/PMG/Config.pm b/src/PMG/Config.pm
> > index 4634bd5..4cbc520 100755
> > --- a/src/PMG/Config.pm
> > +++ b/src/PMG/Config.pm
> > @@ -1175,13 +1175,31 @@ PVE::INotify::register_file('transport', $transport_map_filename,
> >   
> >   # config file generation using templates
> >   
> > +sub get_host_dns_info {
> > +    my ($self) = @_;
> > +
> > +    my $dnsinfo = {};
> > +    my $nodename = PVE::INotify::nodename();
> > +
> > +    $dnsinfo->{hostname} = $nodename;
> > +    my $resolv = PVE::INotify::read_file('resolvconf');
> > +
> > +    my $domain = $resolv->{search} // 'localdomain';
> > +    $dnsinfo->{domain} = $domain;
> > +
> > +    $dnsinfo->{fqdn} = "$nodename.$domain";
> > +
> > +    return $dnsinfo;  
> 
> maybe it would make sense to use PVE::Tools::get_fqdn here?
> (altough it has different semantics)
does sound rather good to me! - I found it a bit odd to read
/etc/resolv.conf for the domain name (and was not aware of 
PVE::Tools::get_fqdn).
Changing that would also fix https://bugzilla.proxmox.com/show_bug.cgi?id=1745

The drawback is that could break some currently working setups:
* those that have their domain-name set in resolv.conf, but
  no fitting entry in /etc/hosts (or DNS).
* those that have multiple interfaces configured and the first one's ip does
  not point to the proper hostname

Both of these should not occur if you've either installed from the ISO
or installed debian without too much changing. my gut-feeling is also
that there are also rather few setups out there that would be hit by
this - additionally repairing those should be straight forward with
an entry in '/etc/hosts'

Still am not sure that I'm not missing something here - but if not
I would probably change that for the v2.


> 
> but we can do this later still..
> 
> _______________________________________________
> pmg-devel mailing list
> pmg-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
> 




More information about the pmg-devel mailing list