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

Add dns config #1875

Merged
Merged

Conversation

joaoantoniocardoso
Copy link
Member

@joaoantoniocardoso joaoantoniocardoso commented Jul 15, 2023

Closes #1871


Demonstration:

dns_menu_demonstration.mp4

image

image

@joaoantoniocardoso joaoantoniocardoso force-pushed the add_dns_config branch 10 times, most recently from 96896c7 to 3d122f7 Compare July 20, 2023 20:15
This is a workaround to make the container's `resolv.conf` synchronized
with the host's `resolv.conf`. To do that, we disallow docker from
managing the container's DNS nameservers by unmounting the container's
`/etc/resolv.conf`, and soft linking it to the binded host's
`/etc/resolv.conf`.  So for this to work, the container's
`/etc/resolv.conf.host` file should be binded (read-only) to the host's
`/etc/resolv.conf`, for our system, it's configured in
`bootstrap/startup.json.default`, and a patch is added in
`core/tools/blueos_startup_update` so systems with older bootstrap
versions can also work with it.

One detail is that because docker uses `mount` to bind the host's file
to the container's file, if the file-descriptor of the file changes, the
bind will be lost. To prevent this, the file being binded must be a hard
link to the actual `/etc/resolv.conf`, and that hard link file is the
one being binded. This hard link is being done in
`core/tools/blueos_startup_update` as `/etc/resolv.conf.host`.

To briefly understand why it is
necessary, when the docker starts a container, it generates the
container `/etc/resolv.conf` based on the host's one, or some docker
configuration, however, during the container's lifetime, if the host's
DNS configuration changes, the container's DNS doesn't follow it, making
the container (possibly) unable to resolve DNSs correctly, failing the
BlueOS Helper's internet connection check. By syncing the container's
resolv.conf with the host's one, we make sure the container's DNS
configuration follows the host's changes, thus, ensuring the container
is able to resolve DNSs correctly.
… tabbed container with both Interface Priority and Dns Configuraiton
def file_exists(file_name: str) -> bool:
command = f'sudo test -e "{file_name}"'
output = run_command(command, True)
print(output)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is these prints for debug ?

Copy link
Member Author

@joaoantoniocardoso joaoantoniocardoso Jul 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, they allow us to inspect what happened on the Linux side

Copy link
Member

@patrickelectric patrickelectric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bravo-applause

@patrickelectric patrickelectric merged commit 4c76144 into bluerobotics:master Jul 21, 2023
5 checks passed
@joaoantoniocardoso joaoantoniocardoso deleted the add_dns_config branch July 24, 2023 12:12
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.

Can't resolv DNS from inside the docker, wrong /etc/resolv.conf setup
2 participants