Why ignore new name server if 3 name servers exists

Bug #1892447 reported by Pengpeng Sun
24
This bug affects 3 people
Affects Status Importance Assigned to Milestone
cloud-init (Ubuntu)
Triaged
Medium
Unassigned

Bug Description

Hi team,

This might be a question which has been asked by someone else, but I did NOT find related bugs by searching.

See https://github.com/canonical/cloud-init/blob/master/cloudinit/distros/parsers/resolv_conf.py#L83, new name server(s) will be ignored if 3 name servers already exists, I know the max number is 3 for name servers. But why not replace the existing name servers by new ones?

Thanks,
Pengpeng

Revision history for this message
Paride Legovini (paride) wrote :

Hi Pengpeng,

I think it boils down to arbitrary choice: we either need to discard the head or the tail of the list, and the current implementation discards the tail. I think the most common way to order nameservers is by decreasing priority, so the current implementation is the least surprising to me.

Do you have a specific reason to ask for the other way around?

Thanks!

Paride

Changed in cloud-init (Ubuntu):
status: New → Incomplete
Revision history for this message
Pengpeng Sun (pengpengs) wrote :

emm...I see the new name servers are appended to the current name servers list. https://github.com/canonical/cloud-init/blob/master/cloudinit/distros/parsers/resolv_conf.py#L79

So the new name servers are always in the tail, if there are already 3 current name servers exist, then any new name servers will be discarded.

In our scenario, new name servers sent to cloud-init by OVF datasource, but the result is inconsistent, depends on how many name servers exist before power-on.

If change the implementation to append the current name servers to the new name servers, then the current name servers are in the tail, then keep the first 3 of the list. In such way, new name servers can be always set.

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for cloud-init (Ubuntu) because there has been no activity for 60 days.]

Changed in cloud-init (Ubuntu):
status: Incomplete → Expired
Revision history for this message
Scott Moser (smoser) wrote :

I set back to 'New', Pengpeng's comment does make sense.

cloudinit/net/sysconfig.py's render_network_state calls _render_dns.
_render_dns then will load the existing file if it is present.

So the end result is that if we have a "stale" version of
/etc/resolv.conf on the system, then the dns servers provided in
networking configuration get appended to that list.

That does seem wrong, and results in the desired networking configuration
not being applied.

Changed in cloud-init (Ubuntu):
status: Expired → New
Revision history for this message
Paride Legovini (paride) wrote :

Hi,

I agree: the "stale" resolv.conf may disrupt the nameserver configuration, and do it in a way that depends on the number of nameservers listed there.

Adding the /etc/resolv.conf nameservers to the *tail* of the nameserver list (trimmed to 3 entries) may be the most sensible thing to do.

Dan Watkins (oddbloke)
Changed in cloud-init (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Aman Kumar Sinha (amansi26) wrote :

Hi Paride,

We are hitting this on RHEL as well

Revision history for this message
Pengpeng Sun (pengpengs) wrote :

We are still hitting this issue on RHEL, I would draft a fix in a PR.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.