Azure / meta-iotedge

Yocto layer for Azure IoT Edge
MIT License
53 stars 59 forks source link

Container Connectivity checks fails to connect to iothub #157

Closed hurtadosanti closed 7 months ago

hurtadosanti commented 7 months ago

Describe the bug After configuring iotedge on a new image, the connectivity checks fail for the <name>.azure-devices.net on ports 5671 and 443. The host and a standard container can resolve <name>>.azure-devices.net successfully. However, within a container based on the image: mcr.microsoft.com/azureiotedge-agent:1.4 the fqdn cannot be resolved.

To Reproduce Steps to reproduce the behavior:

  1. Go to Azure IoT hub and create a new device
  2. On the device run iotedge config mp --connection-string "connection string"
  3. Apply the configuration iotedge config apply -c '/etc/aziot/config.toml'
  4. Run iotedge check
  5. See error

Expected behavior Most of the checks should have succeeded and the device should have a Runtime Response different than NA.

Logs

Connectivity checks
-------------------
√ container on the default network can connect to upstream AMQP port - OK
√ container on the default network can connect to upstream HTTPS / WebSockets port - OK
× container on the IoT Edge module network can connect to upstream AMQP port - Error
    Container on the azure-iot-edge network could not connect to <hub-name>.azure-devices.net:5671
× container on the IoT Edge module network can connect to upstream HTTPS / WebSockets port - Error
    Container on the azure-iot-edge network could not connect to <hub-name>.azure-devices.net:443

Build System (please complete the following information):

Target System (please complete the following information):

Additional context

From inside the container the /etc/resolv.conf contains:

/etc/resolv.conf
search localdomain
nameserver 127.0.0.11
options ndots:0
hurtadosanti commented 7 months ago

I resolved the issue by adding the missing kernel modules to support the nat translation. I used the script https://github.com/moby/moby/blob/master/contrib/check-config.sh from the Moby project to identify and address the specific modules needed for the kernel, I based my work on this https://git.yoctoproject.org/meta-virtualization/tree/recipes-kernel/linux/linux-yocto/docker.cfg?h=kirkstone.

Additionally, I consulted the yocto documentation https://docs.yoctoproject.org/4.0.16/kernel-dev/common.html#configuring-the-kernel to append the linux-yocto kernel fragment for the qemu kernel settings.

Furthermore, the documentation shared by @TheYoctoJester at the Mender hub was invaluable in this context, https://hub.mender.io/t/adding-docker-and-docker-compose-to-a-yocto-build/6078.