Giter VIP home page Giter VIP logo

Comments (20)

jimson-msft avatar jimson-msft commented on July 30, 2024 1

Hi @SaraOlsson, the DO SDK is the only piece installed when running install-deps.sh -a. At runtime, the deliveryoptimization (DO) agent is also required. The plugin-apt is an additional component which will route apt's download requests through DO.

I think this is a good signal that we may want to consider adding the build and install of the deliveryoptimization agent as a part of the install-deps.sh script.

In regards to you following the instructions on the DO github page, that's pretty odd that it gets hung on that step. The cpprest build does take awhile - did you ever see it complete?

Yes, if you complete installing the DO dependencies, then you can run our python script to build a debian package, and install our agent that way. Another alternative is to do a cmake build & install, similar to what's being done by the DU install-deps.sh script.

from iot-hub-device-update.

Voxel07 avatar Voxel07 commented on July 30, 2024

Maybe I am wrong, but you didn't provide a connection string like it´s mentioned here

AducIotAgent 'IoT device connection string' [options...]

don't forget the ' ' before and after your string.

Edit: I just noticed that git doesn't show the text when it's enclosed in <> so maybe that's why there is no string display in your command.

from iot-hub-device-update.

arlotito avatar arlotito commented on July 30, 2024

thanks @Voxel07.

Actually I built the agent with the "--provision-with-iotedge" flag, which allows the agent for automatically getting the conn string from the edge identity service (i have an iot edge 1.2 already provisioned and running), without the need for passing it as a parameter.
That's confirmed by the log:
2021-04-12T14:40:02.4600Z [I] Requesting connection string from the Edge Identity Service [GetConnectionInfoFromIdentityService]

I'm sure that the agent got a proper conn string and connected to the iot hub, as the device twin is properly updated with the reported properties.

Then, looking at the warning:
2021-04-12T14:40:02.4638Z [W] Failed to pass connection string to DO, error: -1 [StartupAgent]
...my guess is that there are issues with the Delivery Optimization (DO) agent, and not with the conn string itself.

Does it make sense?

from iot-hub-device-update.

Voxel07 avatar Voxel07 commented on July 30, 2024

I'm quite new to this whole thing and I have to port everything to Fedora before testing something. At the moment I'm not able to add to compile the DO Agent, and I'm not able to pares additional arguments to the Adu Agent. I filed an issue here, maybe @arlotito you can help me over there.
After reading the log, I came to the same conclusion as you, but unfortunately I'm not able to test this at the moment.

from iot-hub-device-update.

ValOlson avatar ValOlson commented on July 30, 2024

@arlotito thank you for your question.

Responding to the questions on the original thread first to see if it unblocks you and @Voxel07:

  1. Failed to pass connection string to DO
  • This warning can be ignored. It is only relevant if you are testing devices in a disconnected environment using Microsoft Connected Cache.
  1. Failed to create content handler, updateType:(null)
  • This warning can be ignored as well.
  1. IsInstalled call failed. ExtendedResultCode: -536870781
  • Details about this error can be found here.
  • If you’re running the AducIotAgent at any point, please note that the agent must be run as ‘adu’ user. Otherwise, you’ll run into permission-related issue.

from iot-hub-device-update.

arlotito avatar arlotito commented on July 30, 2024

Thanks @ValOlson.

regarding the error: from here I understand that -536870781 is Error Code = 0x83.

But then where to get info around such error code 0x83?
Maybe this table? But it's missing the dec/hex error code column besides the string literal...

or maybe I should look at the link below, which seems to be broken?
image

Thanks!

from iot-hub-device-update.

Jerry-GeGarcia avatar Jerry-GeGarcia commented on July 30, 2024

Hi @arlotito,

-536870781 in HEX is: E0000083, where the facility code of that ExtendedResultCode maps to a standard errno (defined in errno.h and errno-base.h).

Thanks for pointing out the broken link, we'll take care of that and expand on details like the above in our documentation.

from iot-hub-device-update.

Voxel07 avatar Voxel07 commented on July 30, 2024

I switched form fedora to Ubuntu to minimize the possible errors. I have successfully built and installed the agent. But when running it I get the same error msg as @arlotito.

I think my problem is related to the failed test im getting when running the do-agent tests mentioned in this issue.

@ValOlson mentioned running the agent as the 'adu' user. Can you link the Documentation, where this is mentioned and how this user has to be set up.

from iot-hub-device-update.

ValOlson avatar ValOlson commented on July 30, 2024

Hello @arlotito and @Voxel07,

We will be adding the below to our documentation 'How to run the Device Update Agent', in the meanwhile let us know if the below steps worked for you:

  1. Create 'adu' group and 'adu' user by follow these steps:

(Add 'adu' group):
sudo addgroup --system "adu"
(Add 'adu' user (with no shell, and no login)):
sudo adduser --system "adu" --ingroup "adu" --no-create-home --shell /bin/false
(Add 'adu' user to the 'syslog' group to allow the Agent to write to /var/log folder):
sudo usermod -aG "syslog" "adu"
(Add 'adu' user to the 'do' group to allow access to delivery optimization resources):
sudo usermod -aG "do" "adu"

  1. Set adu-shell file permissions to perform download and install tasks with "root" privilege

(Note: Install adu-shell to /usr/lib/adu/ directory before running following commands):
sudo chown "root:adu" "/usr/lib/adu/adu-shell"
sudo chmod u=rxs "/usr/lib/adu/adu-shell"
(Optional: If 'setfacl' command is available):
sudo setfacl -m "group::---" "/usr/lib/adu/adu-shell"
sudo setfacl -m "user::r--" "/usr/lib/adu/adu-shell"
sudo setfacl -m "user:adu:r-x" "/usr/lib/adu/adu-shell"

from iot-hub-device-update.

Voxel07 avatar Voxel07 commented on July 30, 2024

@ValOlson That's roughly what I have done, except the Optional part, but I deleted everything and set it up exactly the same way.

User and Groups

matthias@matthias-VirtualBox:/var/cache$ cat etc/passwd
do:x:129:adu
adu:x:998:
matthias@matthias-VirtualBox:/var/cache$ cat /etc/passwd
do:x:122:129::/home/do:/bin/false
adu:x:123:998::/home/adu:/bin/false

Permissions

matthias@matthias-VirtualBox:~/Desktop/azure$ sudo ls -ld /var/log/adu 
drwxr-x--- 2 adu adu 4096 Apr 26 09:48 /var/log/adu
matthias@matthias-VirtualBox:/tmp$ ls -ld aduc-dl-210426074003/
drwxrwx--- 2 adu adu 4096 Apr 26 09:40 aduc-dl-210426074003/
matthias@matthias-VirtualBox:/tmp$ sudo ls -la aduc-dl-210426095427/
total 8
drwxrwx---  2 adu  adu  4096 Apr 26 11:54 .
drwxrwxrwt 17 root root 4096 Apr 26 11:55 ..
matthias@matthias-VirtualBox:/usr/lib/adu$ ll -a
total 1084
drwxr-xr-x    2 root root    4096 Apr 22 11:58 ./
drwxr-xr-x  126 root root    4096 Apr 23 14:11 ../
-r-Sr-x---+   1 root adu  1094928 Apr 26 08:19 adu-shell*
-rwxr-xr-x    1 root root    3911 Apr 26 08:19 adu-swupdate.sh*
matthias@matthias-VirtualBox:/usr/lib/adu$ ll -a
total 1084
drwxr-xr-x    2 root root    4096 Apr 22 11:58 ./
drwxr-xr-x  126 root root    4096 Apr 23 14:11 ../
-r-Sr-x---+   1 root adu  1094928 Apr 26 08:19 adu-shell*
-rwxr-xr-x    1 root root    3911 Apr 26 08:19 adu-swupdate.sh*

For some reason again in

matthias@matthias-VirtualBox:/usr/local/lib/adu$ ll -a
total 1084
drwxr-xr-x    2 root root    4096 Apr 22 11:58 ./
drwxr-xr-x  126 root root    4096 Apr 23 14:11 ../
-r-Sr-x---+   1 root root    1094928 Apr 26 08:19 adu-shell*
-rwxr-xr-x    1 root root    3911 Apr 26 08:19 adu-swupdate.sh*
matthias@matthias-VirtualBox:/var/cache$ ll -ld deliveryoptimization-agent/
drwxrwxr-x 3 do do 4096 Apr 22 09:13 deliveryoptimization-agent//

When running the agent with:

matthias@matthias-VirtualBox:~/Desktop/azure/do-client$ sudo -H -u adu bash -c AducIotAgent

I'm still getting the same error as in my other issue

I'm not sure how to validate if do is running as do user. But that might be the issue, because after setting the rights up this way no error log is being created by do. I had this happen in the past, and I'm not sure why.

But the Do user is allowed to write to tmp/aduc-..

matthias@matthias-VirtualBox:/tmp$ sudo -H -u adu bash -c 'mkdir aduc-dl-210426124154/test'
matthias@matthias-VirtualBox:/tmp$ sudo -H -u do bash -c 'mkdir aduc-dl-210426124154/test2'
matthias@matthias-VirtualBox:/tmp$ sudo ls -la aduc-dl-210426124154
total 16
drwxrwx--- 4 adu adu 4096 Apr 26 16:06 .
drwxrwxrwt 20 root root 4096 Apr 26 16:04 ..
drwxr-xr-x 2 adu adu 4096 Apr 26 16:06 test
drwxr-xr-x 2 do do 4096 Apr 26 16:06 test2

from iot-hub-device-update.

Nox-MSFT avatar Nox-MSFT commented on July 30, 2024

@arlotito, you've mentioned that the Agent successfully reported its properties to the Device Twin. Could you please share what what the Agent reported please (resultCode, extendedResultCode, state, etc.)

from iot-hub-device-update.

ValOlson avatar ValOlson commented on July 30, 2024

Just some additional details, here are the updated instructions on how to create 'adu' user and group that includes the DO agent.

from iot-hub-device-update.

Voxel07 avatar Voxel07 commented on July 30, 2024
  • If I am looking at this correctly then this is (at least in my case) is not a permission problem. I get this error when a previous update failed and there is no active deployment for this device, and when starting up the agent. The call is successful after the agent entered the Idle mode once.

Please correct me if this is wrong. Thanks.

  • If I followed the steps taken by the agent correctly then the missing value in updateType should be stored in the device twin. When the previous update failed this part is removed from the device twin, so this info will always be null.

I'm not sure why the agent is looking for this when there is no deployment ready, but maybe @ValOlson can clarify this.

from iot-hub-device-update.

Nox-MSFT avatar Nox-MSFT commented on July 30, 2024

@Voxel07 ,

If you're referring to this error:

2021-04-12T14:40:04.1629Z [D] OrchestratorUpdateCallback received property JSON string ({"action":255,"updateManifest":"","updateManifestSignature":" "}), property version (3) [OrchestratorUpdateCallback]
2021-04-12T14:40:04.1630Z [I] Perform startup tasks. [ADUC_Workflow_HandleStartupWorkflowData]
2021-04-12T14:40:04.1630Z [I] Calling IsInstalledCallback to check if content is installed. [ADUC_MethodCall_IsInstalled]
2021-04-12T14:40:04.1631Z [I] IsInstalledCallback called [IsInstalledCallback]
2021-04-12T14:40:04.1631Z [I] IsInstalled called workflowId: , installed criteria: (null) [IsInstalled]
2021-04-12T14:40:04.1633Z [E] Failed to create content handler, updateType:(null) [IsInstalled]
2021-04-12T14:40:04.1634Z [W] IsInstalled call failed. ExtendedResultCode: -536870781 - setting state to Idle [ADUC_Workflow_HandleStartupWorkflowData]

This is expected because the current action is "255" which is "Cancel". This action doesn't contains any update data.
We can change our workflow code to skip 'isInstalled' check to avoid this confusion in the future.

from iot-hub-device-update.

Voxel07 avatar Voxel07 commented on July 30, 2024

@jimson-msft I was referring to this error. Thanks for clarifying. A change would be appreciated, especially because the [E] error was confusing at first.

from iot-hub-device-update.

SaraOlsson avatar SaraOlsson commented on July 30, 2024

Hi, I would be very thankful if someone would like to list the commands needed to set up the adu-agent for APT updates on Raspberry PI 4. I've tried several times flashing a new SD-card, installing IoT Edge 1.2 (following this guide) and building the adu-agent.

The agent keeps restarting and I get error as: Could not create directory /var/lib/adu
I've tried to follow the added guide about adding "adu" as an user, add to group etc. However, I get stuck on steps like I have "no group named syslog" or "do" and "Failed to restart deliveryoptimization-agent.service: Unit deliveryoptimization-agent.service not found" (shouldn't it be installed along with install-deps.sh -a ?). I've tried to add permissions and groups manually etc but it still does not work and I it does not feel good to deviate from the intended installation process.

What I do:

  1. flash sd card with Raspberry OS arm32
  2. install IoT Edge 1.2 with this guide (provision with symmetric keys)
  3. clone this repo to Documents folder on Raspberry.
  4. from here, I've both tried
    • same steps as @arlotito
    • enable and start the adu-agent service with systemctl, and enter device connection string with AducIotAgent ''

Also wondering:
q1. if I install with sudo cmake --build out --target install, then I should not touch the .deb file?
q2. what is the best command to see the logs from the adu-agent? I know I can run systemctl status adu-agent but I also see logs with AducIotAgent but if I got that correct this command also restarts the AducIotAgent?

Many thanks,

from iot-hub-device-update.

ValOlson avatar ValOlson commented on July 30, 2024

Hello @SaraOlsson,

  1. Does your Raspberry Pi 4 device have an OS/architectures in this list of supported Delivery Optimization ("do") OS/architectures? Device Update and Delivery Optimization does not officially support Raspberry Pi 4 yet and all our validations were done on Raspberry Pi B3+.

  2. For errors with installation of components, as pre-requisite to run the Device Update agent please do the following

  1. For adu-agent logs please refer to this guidance. APT is used for the Device Update packaged client so you can use those commands.

Thanks!

from iot-hub-device-update.

SaraOlsson avatar SaraOlsson commented on July 30, 2024

Hi @ValOlson,

  1. yes the device runs Debian 10 (arm32).
  2. okay, however, my question remains: isn't the "do" installed when running install-deps.sh -a which is the first step for installing Device Update agent? I can see the do-client repo being cloned there as well, or what is the difference?
  3. ok thanks!

When I tried to install Delivery Optimization SDK:
`

cd (to working directory of your choosing)
git clone https://github.com/microsoft/do-client
cd build/bootstrap
sudo ./bootstrap-debian-10.sh -c
it runs until Build files have been written to: /tmp/cpprestsdk/build
but is then stuck at [1/29] Building CXX object Release/src/CMakeFiles/cpprest.dir/http/client/http_client_msg.cpp.o

If I get the above bootstrap step to work, I would run:

python3 build/build.py --project agent --package-for deb
`

from iot-hub-device-update.

arlotito avatar arlotito commented on July 30, 2024

Hi @ValOlson, @Nox-MSFT,
I finally managed to build and run the DO-client and ADU-agent on both RPI3B+ and RPI4, using a Raspberry OS 32bit Lite with an IoT Edge 1.2 as starting point.

DO Client

I built the debian packages as per here.
That went smoothly.

ADU Agent

As per here:

sudo ./scripts/install-deps.sh -a
sudo ./scripts/build.sh -c -p linux --provision-with-iotedge --content-handlers microsoft/apt --build-packages

...and you get the 'deviceupdate-agent-0.6.0-public-preview-Linux.deb' package.

The installation is the tricky part now.

If you install by sudo cmake --build out --target install as suggested in the docs, you have then to manually add the user, adjust the permissions (as per @ValOlson' suggestion)... and it fails anyway (at least in my case, both on rpi3 and rpi4).

The solution is installing via the debian package, and not via cmake.

But before installing the package, you have to fix a couple of issues:

  • add the 'syslog' group (because the adu client will assign the 'adu' user to such group to get r/w permissions to /var/log)

    sudo addgroup --system "syslog"
    

    WARNING: this is a quick&dirty workaround just to complete the installation. Proper solution has to be defined.
    Without doing this, you will get this error when trying to install the adu client .deb package:
    image

  • install 'acl'

    sudo apt install acl
    

    Without this, you'll get this errer when installing the adu client .deb package:
    image

Now you can install the debian package:

sudo apt-get install ./deviceupdate-agent-0.6.0-public-preview-Linux.deb

...and this is what you get:
image

As you can see, it creates all the required users.

Then you restart the agent:

sudo apt-get install ./deviceupdate-agent-0.6.0-public-preview-Linux.deb

...and if you deploy an update, it will work!
image

Summary

  • build and install DO client as per here
  • build and install ADU agent as follows:
sudo ./scripts/install-deps.sh -a
sudo ./scripts/build.sh -c -p linux --provision-with-iotedge --content-handlers microsoft/apt --build-packages
sudo addgroup --system "syslog"
sudo apt install acl
sudo apt-get install ./deviceupdate-agent-0.6.0-public-preview-Linux.deb

If you like, I can share:

  • pre-built deb packages for both do-client and adu agent
  • img.xz embedding iot edge 1.2 and do/adu, ready to be flashed on a RPI3/4

from iot-hub-device-update.

ValOlson avatar ValOlson commented on July 30, 2024

Hi @arlotito,

Thank you for sharing details of your solution, we really appreciate it. For privacy reasons we do not want you to share your binaries with us, but we encourage the community to contribute to our GitHub repo by creating a branch and a pull request with adu-client as the approver. Our engineering team will be happy to review it and we can consider adding it as part of the solution in upcoming releases as well.

from iot-hub-device-update.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.