Azure / iotedgedev

The Azure IoT Edge Dev Tool greatly simplifies your Azure IoT Edge development process. It has everything you need to get started and helps with your day-to-day Edge development.
https://aka.ms/iotedgedev
Other
160 stars 70 forks source link

Could not initialize module runtime #484

Closed jimbobbennett closed 2 years ago

jimbobbennett commented 3 years ago

Steps to Reproduce:

  1. Use macOS with Docker desktop 3.5
  2. Follow the steps in https://github.com/Azure/iotedgedev/tree/master/docker/runtime to run the IoT edge module

Expected:

It should work

Actual:

The container gives an error and stops:

agent:
  name: "edgeAgent"
  type: "docker"
  env: {}
  config:
    image: "mcr.microsoft.com/azureiotedge-agent:1.1"
    auth: {}
hostname: "edgehub"
connect:
  management_uri: "http://host.docker.internal:15580"
  workload_uri: "http://host.docker.internal:15581"
listen:
  management_uri: "http://172.17.0.2:15580"
  workload_uri: "http://172.17.0.2:15581"
homedir: "/var/lib/iotedge"
moby_runtime:
  docker_uri: "/var/run/docker.sock"
  network: "azure-iot-edge"
=> running iotedge daemon
<6>2021-06-24T23:19:22Z [INFO] - Starting Azure IoT Edge Security Daemon
<6>2021-06-24T23:19:22Z [INFO] - Version - 1.1.3
<6>2021-06-24T23:19:22Z [INFO] - Using config file: /etc/iotedge/config.yaml
<6>2021-06-24T23:19:22Z [INFO] - Configuring /var/lib/iotedge as the home directory.
<6>2021-06-24T23:19:22Z [INFO] - Configuring certificates...
<6>2021-06-24T23:19:22Z [INFO] - Transparent gateway certificates not found, operating in quick start mode...
<6>2021-06-24T23:19:22Z [INFO] - Finished configuring provisioning environment variables and certificates.
<6>2021-06-24T23:19:22Z [INFO] - Initializing hsm...
<6>2021-06-24T23:19:22Z [INFO] (/project/edgelet/hsm-sys/azure-iot-hsm-c/src/hsm_log.c:log_init:41) Initialized logging
<6>2021-06-24T23:19:22Z [INFO] (/project/edgelet/hsm-sys/azure-iot-hsm-c/src/edge_hsm_client_store.c:generate_edge_hsm_certificates_if_needed:1629) Load status 1. Regenerating owner and device CA certs and keys
<6>2021-06-24T23:19:22Z [INFO] (/project/edgelet/hsm-sys/azure-iot-hsm-c/src/edge_pki_openssl.c:generate_rsa_key:346) Generating RSA key of length 4096
<6>2021-06-24T23:19:23Z [INFO] (/project/edgelet/hsm-sys/azure-iot-hsm-c/src/edge_pki_openssl.c:generate_rsa_key:346) Generating RSA key of length 4096
<3>2021-06-24T23:19:23Z [ERR!] (/project/edgelet/hsm-sys/azure-iot-hsm-c/src/hsm_utils.c:read_file_into_buffer_impl:167) Could not open file for reading /var/lib/iotedge/hsm/enc_keys/edgelet-masterWt5mT2xpO72EPKlt2Tt0Sq4uJCrMvfl2rzzKRB3pnyo_.enc.key. Errno 2 'No such file or directory'
<6>2021-06-24T23:19:23Z [INFO] (/project/edgelet/hsm-sys/azure-iot-hsm-c/src/edge_hsm_client_store.c:load_encryption_key_from_file:818) Could not read encryption key from file.  No key file exists or is invalid or permission error.
<6>2021-06-24T23:19:23Z [INFO] - Finished initializing hsm.
<6>2021-06-24T23:19:23Z [INFO] - Provisioning edge device...
<6>2021-06-24T23:19:23Z [INFO] - Starting provisioning edge device via manual mode using a device connection string...
<6>2021-06-24T23:19:23Z [INFO] - Manually provisioning device "fruit-quality-detector-edge" in hub "iot-for-beginners.azure-devices.net"
<6>2021-06-24T23:19:23Z [INFO] - Finished provisioning edge device.
<6>2021-06-24T23:19:23Z [INFO] - Initializing the module runtime...
<6>2021-06-24T23:19:23Z [INFO] - Initializing module runtime...
<6>2021-06-24T23:19:23Z [INFO] - Using runtime network id azure-iot-edge
<4>2021-06-24T23:19:23Z [WARN] - Could not initialize module runtime
<4>2021-06-24T23:19:23Z [WARN] -    caused by: Container runtime error
<4>2021-06-24T23:19:23Z [WARN] -    caused by: error trying to connect: Connection refused (os error 111)
<3>2021-06-24T23:19:23Z [ERR!] - The daemon could not start up successfully: Could not initialize module runtime
<3>2021-06-24T23:19:23Z [ERR!] -    caused by: Could not initialize module runtime
<3>2021-06-24T23:19:23Z [ERR!] -    caused by: Container runtime error
<3>2021-06-24T23:19:23Z [ERR!] -    caused by: error trying to connect: Connection refused (os error 111)

This is the same as #467, but reopening as it's still an issue.

@marianan - you asked on that issue to share the config.yaml. This cannot be accessed as the container stops with the given error.

@cindydeng1998 - you mention the Quickstart. I've tried this, but I get errors as it's an AMD64 container and I'm using an Apple Silicon Mac. When I run iotedgedev init it can't retrieve my connection string, then I get set faults:

Step 4/12 : RUN dotnet restore
 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
 ---> Running in 492f5b3ec6ca
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault
ERROR: The command '/bin/sh -c dotnet restore' returned a non-zero code: 139
marianan commented 3 years ago

@jimbobbennett thanks for reporting this issue. We are still tracking in our backlog root causing and fixing issue #467. To confirm that it is the same problem, could you try the workaround in #467 and let us know if that resolves the symptoms you are observing?

jimbobbennett commented 3 years ago

@marianan - I can't, the workaround is to roll back Docker to 2.1, but I am using Apple Silicon, and this isn't supported with that version.

marianan commented 3 years ago

@jimbobbennett I see, thanks for your response. In that case I am assuming that this is a different issue and I am filing it separately. It is in our backlog. We will update this thread with our findings.

marianan commented 2 years ago

@jimbobbennett in your scenario you are trying to get an IoT Edge device inside a docker container. While we work out the specific compatibility issues between Docker and Mac here, i am curious if any of these other tools can unblock your scenario:

  1. Setup a VM/physical device/container using https://github.com/Azure/iot-edge-config
  2. IoT Edge runtime simulator - https://github.com/Azure/iotedgehubdev
  3. IoT Edge runtime in docker container - https://github.com/toolboc/azure-iot-edge-device-container
marianan commented 2 years ago

Moving forward, we are no longer going to support this functionality, so I am closing this issue. For more details, please see https://github.com/Azure/iotedgedev/pull/525.