Azure / iot-hub-device-update

Device Update for IoT Hub agent
MIT License
51 stars 36 forks source link

Failed parse of JSON file in Rpi4 device #604

Closed manojrampur closed 2 months ago

manojrampur commented 4 months ago

Hi Team,

I have built a Yocto Kirkstone Image for Rpi4 device using IotEdge Runtime and the device update-agent, I can see that IoTEdge runtime is active and running but deviceupdate-agent is not in an active state.

Expected Behavior

When we configure the deviceupdate-agent with a connection string in /adu/du-config.json and creating the du-diagnostics-config.json with required details, It should show the deviceupdate-agent status as active and running.

Current Behavior

I created the deviceupdate-agent with a connection string in /adu/du-config.json and also created the du-diagnostics-config.json with the required details, but when I restarted and checked the status of the deviceupdate-agent, it was not in an active state.

Below is the du-config.json file:

{
  "schemaVersion": "1.0",
  "aduShellTrustedUsers": [
    "adu",
    "do"
  ],
  "iotHubProtocol": "mqtt",
  "manufacturer": "Contoso",
  "model": "Video",
  "agents": [
    {
      "name": "main",
      "runas": "adu",
      "connectionSource": {
        "connectionType": "string",
        "connectionData": "<Connection String>"
       },
      "manufacturer": "Contoso",
      "model": "Video"
    }
  ]
}

Device Information

Host OS [e.g. Ubuntu 18.04, Windows Server IoT 2019]: Yocto Kirkstone Linux OS Architecture [e.g. amd64, arm32, arm64]: arm64 Provisioning Method: module provisioning with Azure identity service *DU Agent Version: 1.0.1

Logs

systemctl status deviceupdate-agent

deviceupdate-agent.service - Device Update Agent daemon. Loaded: loaded (/lib/systemd/system/deviceupdate-agent.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Wed 2024-02-07 11:36:40 UTC; 4s ago Process: 16404 ExecStart=/usr/bin/AducIotAgent -l 0 -e (code=exited, status=1/FAILURE) Main PID: 16404 (code=exited, status=1/FAILURE)

journalctl -u deviceupdate-agent | tail -30

Feb 07 11:35:26 raspberrypi4-64 systemd[1]: deviceupdate-agent.service: Main process exited, code=exited, status=1/FAILURE Feb 07 11:35:26 raspberrypi4-64 systemd[1]: deviceupdate-agent.service: Failed with result 'exit-code'. Feb 07 11:35:31 raspberrypi4-64 systemd[1]: deviceupdate-agent.service: Scheduled restart job, restart counter is at 4588. Feb 07 11:35:31 raspberrypi4-64 systemd[1]: Stopped Device Update Agent daemon.. Feb 07 11:35:31 raspberrypi4-64 systemd[1]: Started Device Update Agent daemon.. Feb 07 11:35:31 raspberrypi4-64 AducIotAgent[16387]: 2024-02-07T11:35:31.8445Z 16387[16387] [E] Failed parse of JSON file: /adu/du-config.json [ADUC_ConfigInfo_Init] Feb 07 11:35:31 raspberrypi4-64 AducIotAgent[16387]: 2024-02-07T11:35:31.8446Z 16387[16387] [E] Cannot read configuration file. [RunAsDesiredUser] Feb 07 11:35:31 raspberrypi4-64 AducIotAgent[16387]: WARNING: Cannot create a folder for logging file. ('/adu/logs')WARNING: Unable to start file logger. (Log folder: /adu/logs) Feb 07 11:35:31 raspberrypi4-64 AducIotAgent[16387]: 2024-02-07T11:35:31.8447Z 16387[16387] [I] Agent exited with code 1 [main] Feb 07 11:35:31 raspberrypi4-64 AducIotAgent[16387]: 2024-02-07T11:35:31.8447Z 16387[16387] [I] Agent is shutting down with signal 0. [ShutdownAgent] Feb 07 11:35:31 raspberrypi4-64 AducIotAgent[16387]: 2024-02-07T11:35:31.8447Z 16387[16387] [I] De-initializing command listener thread [UninitializeCommandListenerThread] Feb 07 11:35:31 raspberrypi4-64 AducIotAgent[16387]: 2024-02-07T11:35:31.8447Z 16387[16387] [I] ADUC agent stopping [AzureDeviceUpdateCoreInterface_Destroy] Feb 07 11:35:31 raspberrypi4-64 AducIotAgent[16387]: Error: Time:Wed Feb 7 11:35:31 2024 File:/usr/src/debug/azure-iot-sdk-c/1.0+gitAUTOINC+021212f84f-r0/git/c-utility/adapters/tlsio_openssl.c Func:openssl_static_locks_uninstall Line:595 Locks already uninstalled Feb 07 11:35:31 raspberrypi4-64 systemd[1]: deviceupdate-agent.service: Main process exited, code=exited, status=1/FAILURE Feb 07 11:35:31 raspberrypi4-64 systemd[1]: deviceupdate-agent.service: Failed with result 'exit-code'.

Additional Information

Please provide any additional information that may be helpful in understanding the issue.

jw-msft commented 4 months ago

Feb 07 11:35:31 raspberrypi4-64 AducIotAgent[16387]: 2024-02-07T11:35:31.8445Z 16387[16387] [E] Failed parse of JSON file: /adu/du-config.json [ADUC_ConfigInfo_Init]

Feb 07 11:35:31 raspberrypi4-64 AducIotAgent[16387]: 2024-02-07T11:35:31.8446Z 16387[16387] [E] Cannot read configuration file. [RunAsDesiredUser]

Feb 07 11:35:31 raspberrypi4-64 AducIotAgent[16387]: WARNING: Cannot create a folder for logging file. ('/adu/logs')WARNING: Unable to start file logger. (Log folder: /adu/logs)

Can you use a JSON validator on your /adu/du-config.json and check json syntax (e.g. cat du-config.json | jq .)? Logs indicate it is invalid JSON format. Also:

# expected permissions and ownership
ls -latr /path/to/du-config.json
-rw-r-----   1 adu  adu 543 Feb  7 04:05 du-config.json

Also, there is warning about /adu/logs so check that this dir is owned by adu:adu and the dir has rwx permissions for user (either chmod 755 /adu/logs or chmod 750 /adu/logs should work) so that log files can be written to the dir.

manojrampur commented 4 months ago

Hi @jw-msft ,

These are our findings as per the commands that you have provided above inside the Rpi4 Yocto Image.

  root@raspberrypi4-64:~# ls -latr /adu/du-config.json
  -rw-r-----    1 adu      adu            535 Feb  8 06:58 /adu/du-config.json
root@raspberrypi4-64:/adu# ls -l
total 16
-rw-r--r--    1 root     root           540 Feb  7 07:04 adu-conf.txt
-rw-r-----    1 adu      adu            535 Feb  8 06:58 du-config.json
-r--r-----    1 adu      adu            256 Feb  7 06:54 du-diagnostics-config.json
drwxrwxrwt    2 adu      adu           4096 Feb  7 05:23 logs
-rw-r--r--    1 root     root             0 Feb  7 06:33 n
-rw-r--r--    1 root     root             0 Feb  8 06:59 test
root@raspberrypi4-64:~# lsblk -fs

NAME        FSTYPE  FSVER   LABEL           UUID                                    FSAVAIL     FSUSE%  MOUNTPOINTS
mmcblk0p1   vfat                    rpi4-64 5862-22CC                                   `-mmcblk0
mmcblk0p2   ext3                    613bd8f6-6dfc-427a-bd1d-b22b685323a8     24M        92% /   `-mmcblk0

Still, we are facing the same issue and also I can't see any partition available for /adu

  1. What is the next step that should be taken to proceed further?

  2. Is there any configuration that we have to add in our local.conf file or any other changes that we have to modify while building the Yocto Image?

jw-msft commented 4 months ago

I did not see output for JSON validation. Was JSON linter validation done for the du-config.json (e.g. via something like cat du-config.json | jq . or using jsonlint)?

Are you using adu-provided yocto recipes? There is not currently support for poky kirkstone yet and no support yet for RPI4. Both are currently being worked on (I have assigned this issue appropriately)

There are kirkstone branches for some of the following adu yocto-related repos that would also receive further updates for rpi4: azure/meta-azure-device-update azure/meta-iot-hub-device-update-delta azure/meta-raspberrypi-adu

more info here for how to use adu yocto recipes: https://github.com/Azure/iot-hub-device-update-yocto

manojrampur commented 4 months ago

Hi @jw-msft,

Could you please tell us the expected time for support of RPI4 and poky kirkstone?

eshashah-msft commented 4 months ago

Hi @manojrampur,

We are currently working to add support for Yocto Kirkstone with RPi 4 and will have an update in the next few weeks. I will update the issue here as well.

eshashah-msft commented 2 months ago

Hi @manojrampur,

Please find our update meta layers for Yocto Kirkstone here: https://github.com/Azure/meta-azure-device-update/tree/kirkstone Updated example to build ADU with Yocto on Raspberry Pi 4: https://github.com/Azure/iot-hub-device-update-yocto/tree/kirkstone