Skip to content
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

net: allow for NetworkManager configuration for NetworkManager net renderer #4450

Closed
wants to merge 1 commit into from

Conversation

ani-sinha
Copy link
Contributor

This is the equivalent of the change made in the following commit for sysconfig renderer but this time it is for network_manager renderer:

67bab5bb804e2346673 ("net: Allow for NetworkManager configuration")

The reasons for making the change has already been outlined in the above commit. When cloud-init configures DNS and produces /etc/resolv.conf, NetworkManager, if enabled, can clobber the above file and could also render it empty. Hence, this change makes cloud-init add a NetworkManager configuration so that it disables management and handling of /etc/resolv.conf by NetworkManager.

Some code refactoring has been performed so as to avoid code duplication. Unit tests have been adjusted accordingly.

LP: #1693251

@ani-sinha ani-sinha changed the title net: allow NetworkManager configuration for NetworkManager net renderer net: allow for NetworkManager configuration for NetworkManager net renderer Sep 21, 2023
@ani-sinha
Copy link
Contributor Author

Our QE is testing this internally. So please feel free to review but do not push it yet.

…nderer

This is the equivalent of the change made in the following commit for sysconfig
renderer but this time it is for network_manager renderer:
67bab5b ("net: Allow for NetworkManager configuration")

The reasons for making the change has already been outlined in the above commit.
When cloud-init configures DNS and produces /etc/resolv.conf, NetworkManager,
if enabled, can clobber the above file and could also render it empty.
Hence, this change makes cloud-init add a NetworkManager configuration so that
it disables management and handling of /etc/resolv.conf by NetworkManager.

Some code refactoring has been performed so as to avoid code duplication.
Unit tests have been adjusted accordingly.

LP: #1693251

Signed-off-by: Ani Sinha <[email protected]>
@ani-sinha
Copy link
Contributor Author

After looking at the sysconfig and NM renderer code deeper and discussing this internally with QE, we found that sysconfig renderer writes DNS information to /etc/resolv.conf but NM renderer does not. When NM renderer is used, the DNS information is directly written into the NM keyfile and NetworkManager is responsible for managing DNS from that point onwards and writing /etc/resolv.conf. There is no need to keep NM out of the loop. Hence, there is no need to write /etc/NetworkManager/conf.d/99-cloud-init.conf from NM renderer. For sysconfig it is necessary to keep NM from touching /etc/resolv.conf separately and overwriting cloud-init generated file. Thus, this PR can be closed.

@ani-sinha ani-sinha closed this Sep 27, 2023
ani-sinha added a commit to ani-sinha/cloud-init that referenced this pull request Oct 17, 2023
…r renderer

It is not necessary for NetworkManager renderer to keep NM out of the loop from
handling DNS. This is unlike sysconfig renderer where we explicitly add
`dns=none` in `/etc/NetworkManager/conf.d/99-cloud-init.conf` NetworkManager
configuration file in order to prevent NetworkManager from handling DNS and
writing /etc/resolv.conf. This is because NetworkManager renderer writes DNS
information in the interface keyfile and does not manipulate /etc/resolv.conf
directly. NetworkManager reads this information from the keyfile and handles
DNS, including managing /etc/resolv.conf. Sysconfig renderer on the other hand
directly writes /etc/resolv.conf directly and hence we need to make sure
NetworkManager is not overwriting the DNS data in /etc/resolv.conf.

Add a comment explaining the difference between the two renderers with regards
to DNS handling. See also GH PR canonical#4450.

Signed-off-by: Ani Sinha <[email protected]>
TheRealFalcon pushed a commit that referenced this pull request Oct 17, 2023
It is not necessary for NetworkManager renderer to keep NM out of the loop from
handling DNS. This is unlike sysconfig renderer where we explicitly add
`dns=none` in `/etc/NetworkManager/conf.d/99-cloud-init.conf` NetworkManager
configuration file in order to prevent NetworkManager from handling DNS and
writing /etc/resolv.conf. This is because NetworkManager renderer writes DNS
information in the interface keyfile and does not manipulate /etc/resolv.conf
directly. NetworkManager reads this information from the keyfile and handles
DNS, including managing /etc/resolv.conf. Sysconfig renderer on the other hand
directly writes /etc/resolv.conf directly and hence we need to make sure
NetworkManager is not overwriting the DNS data in /etc/resolv.conf.

Add a comment explaining the difference between the two renderers with regards
to DNS handling. See also GH PR #4450.

Signed-off-by: Ani Sinha <[email protected]>
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.

2 participants